.agreement-page {
  padding-top: 36px;
  padding-bottom: 48px;
}

.agreement-page .agreement-card {
  max-width: 820px;
  margin: 0 auto;
  padding: 28px 24px 24px;
  position: relative;
  overflow: hidden;
}

.agreement-page .agreement-card::before {
  content: "";
  position: absolute;
  right: -90px;
  top: -90px;
  width: 220px;
  height: 220px;
  border-radius: 999px;
  background: rgba(45, 212, 191, .16);
  filter: blur(28px);
  pointer-events: none;
}

.agreement-hero {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.agreement-hero-copy .eyebrow {
  margin-bottom: 10px;
}

.agreement-hero-copy h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 4vw, 34px);
  line-height: 1.25;
  letter-spacing: -.02em;
}

.agreement-panel {
  position: relative;
  z-index: 1;
  border: 1px solid rgba(226, 232, 240, .95);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(248, 250, 252, .92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8);
  overflow: hidden;
}

.agreement-body {
  max-height: min(58vh, 560px);
  overflow: auto;
  padding: 22px 20px;
  line-height: 1.85;
  color: #334155;
  font-size: 15px;
  -webkit-overflow-scrolling: touch;
}

.agreement-body::-webkit-scrollbar {
  width: 8px;
}

.agreement-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.agreement-body h2,
.agreement-body h3 {
  margin: 0 0 12px;
  color: var(--text);
  line-height: 1.35;
}

.agreement-body h2 {
  font-size: 20px;
}

.agreement-body h3 {
  font-size: 17px;
  margin-top: 18px;
}

.agreement-body p {
  margin: 0 0 12px;
}

.agreement-body p:last-child {
  margin-bottom: 0;
}

.agreement-body ul,
.agreement-body ol {
  margin: 0 0 12px;
  padding-left: 1.25em;
}

.agreement-body li + li {
  margin-top: 6px;
}

.agreement-body img,
.agreement-image {
  display: block;
  width: 100%;
  max-width: 100%;
  border-radius: 16px;
  margin: 14px 0;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .08);
}

.agreement-empty {
  text-align: center;
  color: #64748b;
  padding: 48px 20px;
  font-weight: 700;
}

.agreement-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: min(42vh, 320px);
  padding: 48px 28px;
  text-align: center;
  background:
    radial-gradient(ellipse 80% 70% at 50% 20%, rgba(45, 212, 191, .14), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(240, 253, 250, .88));
}

.agreement-done.is-hidden {
  display: none;
}

.agreement-done-badge {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #0f766e;
  background: linear-gradient(145deg, #ecfdf5, #ccfbf1);
  border: 1px solid rgba(45, 212, 191, .35);
  box-shadow:
    0 10px 28px rgba(13, 148, 136, .16),
    inset 0 1px 0 rgba(255, 255, 255, .9);
  animation: agreement-done-pop .55s cubic-bezier(.22, 1, .36, 1) both;
}

.agreement-done-title {
  margin: 4px 0 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: #0f172a;
  animation: agreement-done-fade .5s ease .12s both;
}

.agreement-done-text {
  margin: 0;
  max-width: 22em;
  font-size: 15px;
  line-height: 1.7;
  font-weight: 600;
  color: #0f766e;
  animation: agreement-done-fade .5s ease .2s both;
}

.agreement-card.is-done .agreement-panel {
  border-color: rgba(45, 212, 191, .28);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .85),
    0 18px 40px rgba(13, 148, 136, .06);
}

.agreement-card.is-done .agreement-body,
.agreement-card.is-done .agreement-empty {
  display: none;
}

.agreement-card.is-done .agreement-nav {
  justify-content: flex-start;
}

.agreement-card.is-done #backBtn {
  min-width: 128px;
  border-radius: 999px;
  border-color: rgba(148, 163, 184, .55);
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 8px 18px rgba(15, 23, 42, .04);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.agreement-card.is-done #backBtn:hover {
  border-color: rgba(13, 148, 136, .45);
  box-shadow: 0 10px 22px rgba(13, 148, 136, .12);
  transform: translateY(-1px);
}

@keyframes agreement-done-pop {
  from {
    opacity: 0;
    transform: scale(.72);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes agreement-done-fade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .agreement-done {
    min-height: min(36vh, 280px);
    padding: 40px 20px;
  }

  .agreement-done-badge {
    width: 56px;
    height: 56px;
  }

  .agreement-done-title {
    font-size: 17px;
  }

  .agreement-done-text {
    font-size: 14px;
  }
}

.agreement-actions {
  position: relative;
  z-index: 1;
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

.agreement-consent {
  margin: 0;
}

.signature-block {
  border: 1px solid rgba(6, 182, 212, .2);
  border-radius: 22px;
  background: linear-gradient(180deg, #f0fdff, #ffffff);
  padding: 16px;
  box-shadow: 0 14px 30px rgba(6, 182, 212, .08);
}

.signature-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.signature-head .field-label {
  margin-bottom: 4px;
}

.signature-tip {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.signature-pad {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 200px;
  border: 1.5px dashed #67e8f9;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(240, 253, 255, .7));
  touch-action: none;
  cursor: crosshair;
}

.agreement-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
}

.agreement-nav .btn {
  min-width: 120px;
}

.agreement-nav .btn-primary {
  flex: 1;
  max-width: 280px;
  margin-left: auto;
}

@media (max-width: 720px) {
  .agreement-page {
    padding-top: 24px;
  }

  .agreement-page .agreement-card {
    padding: 20px 16px 18px;
    border-radius: 24px;
  }

  .agreement-hero {
    flex-direction: column;
  }

  .agreement-body {
    max-height: min(52vh, 460px);
    padding: 18px 14px;
    font-size: 14px;
  }

  .signature-head {
    flex-direction: column;
  }

  .signature-pad {
    height: 180px;
  }

  .agreement-nav {
    flex-direction: column-reverse;
  }

  .agreement-nav .btn,
  .agreement-nav .btn-primary {
    width: 100%;
    max-width: none;
    margin-left: 0;
  }
}

/* ---------- 协议预览弹框 ---------- */
body.agreement-preview-open {
  overflow: hidden;
  overscroll-behavior: none;
}

html.agreement-preview-open {
  overflow: hidden;
  overscroll-behavior: none;
}

.agreement-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  box-sizing: border-box;
}

.agreement-preview-modal.is-hidden {
  display: none;
}

.agreement-preview-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .52);
  backdrop-filter: blur(8px);
}

.agreement-preview-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(640px, 100%);
  height: fit-content;
  max-height: min(70vh, 620px);
  max-height: min(70dvh, 620px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  align-self: center;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, .8);
  background: linear-gradient(180deg, #ffffff, #f8fdff);
  box-shadow: 0 30px 90px rgba(15, 23, 42, .28);
  overflow: hidden;
}

.agreement-preview-modal__handle {
  display: none;
}

.agreement-preview-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(226, 232, 240, .9);
  flex: 0 0 auto;
}

.agreement-preview-modal__header h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
  color: #0f172a;
}

.agreement-preview-modal__close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: #f1f5f9;
  color: #475569;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
}

.agreement-preview-modal__close:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.agreement-preview-modal__body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px 20px 22px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  line-height: 1.85;
  color: #334155;
  font-size: 15px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, .45) transparent;
}

.agreement-preview-modal__body::-webkit-scrollbar {
  width: 4px;
}

.agreement-preview-modal__body::-webkit-scrollbar-track {
  background: transparent;
}

.agreement-preview-modal__body::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, .45);
  border-radius: 999px;
}

.agreement-preview-modal__body h2,
.agreement-preview-modal__body h3 {
  margin: 0 0 12px;
  color: #0f172a;
}

.agreement-preview-modal__body p {
  margin: 0 0 12px;
}

.agreement-preview-modal__body p:last-child {
  margin-bottom: 0;
}

.agreement-preview-modal__body img,
.agreement-preview-modal__body .agreement-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 16px;
  margin: 12px 0;
}

.agreement-preview-modal__loading,
.agreement-preview-modal__error {
  margin: 24px 0;
  text-align: center;
  color: #64748b;
  font-weight: 700;
}

.agreement-preview-modal__error {
  color: #b91c1c;
}

@media (max-width: 720px) {
  .agreement-preview-modal {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }

  .agreement-preview-modal__dialog {
    width: 100%;
    max-width: none;
    align-self: flex-end;
    height: 60vh;
    height: 60dvh;
    max-height: 60vh;
    max-height: 60dvh;
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .agreement-preview-modal__handle {
    display: block;
    width: 40px;
    height: 5px;
    margin: 10px auto 0;
    border-radius: 999px;
    background: #cbd5e1;
    flex: 0 0 auto;
  }

  .agreement-preview-modal__header {
    padding: 10px 14px 10px 18px;
  }

  .agreement-preview-modal__header h2 {
    font-size: 17px;
  }

  .agreement-preview-modal__close {
    width: 40px;
    height: 40px;
  }

  .agreement-preview-modal__body {
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    font-size: 14px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .agreement-preview-modal__body::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }
}
