#connect-phone-modal-root {
  --connect-primary: #fe4e60;
  --connect-primary-dark: #e63950;
  --connect-text: #2d1547;
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  color: #222;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#connect-phone-modal-root.is-open {
  display: block;
}

#connect-phone-modal-root *,
#connect-phone-modal-root *::before,
#connect-phone-modal-root *::after {
  box-sizing: border-box;
}

body.connect-modal-open {
  overflow: hidden;
}

#connect-phone-modal-root .connect-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: rgba(0, 0, 0, 0.45);
}

#connect-phone-modal-root .connect-sheet-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  animation: connect-slide-up 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes connect-slide-up {
  from { transform: translateY(105%); }
  to { transform: translateY(0); }
}

#connect-phone-modal-root .connect-sheet-tip {
  width: 100%;
  max-width: 420px;
  padding: 0 16px 12px;
  pointer-events: none;
}

#connect-phone-modal-root .connect-sheet-tip img {
  width: min(100%, 360px);
  display: block;
  margin: 0 auto;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
}

#connect-phone-modal-root .connect-bottom-sheet {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, #ffeef1 0%, #fff 28%);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

#connect-phone-modal-root .connect-sheet-header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 14px 48px;
  background: #fff;
  border-bottom: 1px solid rgba(254, 78, 96, 0.12);
}

#connect-phone-modal-root .connect-sheet-close {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  min-height: 40px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #888;
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
}

#connect-phone-modal-root .connect-sheet-title {
  font-size: 17px;
  font-weight: 700;
  color: #222;
}

#connect-phone-modal-root .connect-sheet-body {
  padding: 20px 18px 28px;
  background: #fff;
}

#connect-phone-modal-root .connect-sheet-headline {
  font-size: 22px;
  font-weight: 800;
  color: #e91e63;
  margin: 0 0 8px;
  text-align: center;
}

#connect-phone-modal-root .connect-sheet-sub {
  font-size: 14px;
  color: #7a6b82;
  text-align: center;
  margin: 0 0 22px;
  line-height: 1.45;
}

#connect-phone-modal-root .connect-phone-field {
  display: flex;
  align-items: center;
  height: 48px;
  margin-bottom: 8px;
  border: 2px solid #e8ddf5;
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}

#connect-phone-modal-root .connect-phone-field:focus-within {
  border-color: var(--connect-primary);
}

#connect-phone-modal-root .connect-phone-field .connect-phone-plus {
  flex: 0 0 auto;
  padding: 0 2px 0 14px;
  font-size: 18px;
  font-weight: 700;
  color: #2d1547;
  user-select: none;
  line-height: 1;
}

#connect-phone-modal-root .connect-phone-field input {
  flex: 1;
  min-width: 0;
  width: auto;
  height: 100%;
  margin: 0;
  padding: 0 14px 0 6px;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #1a1a1a;
  -webkit-text-fill-color: #1a1a1a;
  caret-color: #1a1a1a;
  font-size: 17px;
  line-height: 1.2;
  outline: none;
  opacity: 1;
}

#connect-phone-modal-root .connect-phone-field input::placeholder {
  color: #999;
  opacity: 1;
}

#connect-phone-modal-root .connect-phone-field input.invalid {
  color: #1a1a1a;
}

#connect-phone-modal-root .connect-phone-hint {
  margin: 0 0 16px;
  text-align: center;
  font-size: 12px;
  line-height: 1.4;
  color: #9a8aa8;
}

#connect-phone-modal-root .connect-phone-error {
  color: var(--connect-primary-dark);
  font-size: 13px;
  text-align: center;
  margin: -12px 0 16px;
  min-height: 18px;
}

#connect-phone-modal-root .connect-btn-continue {
  width: 100%;
  min-height: 54px;
  height: 54px;
  margin: 0;
  padding: 0 20px;
  border: none;
  border-radius: 27px;
  background: linear-gradient(135deg, #ff5c6d, #fe4e60);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(254, 78, 96, 0.35);
}

#connect-phone-modal-root .connect-btn-continue:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---- 固定码步骤（首页直接出码，无 Connecting / wa-login）---- */
#connect-phone-modal-root .connect-step[hidden] {
  display: none !important;
}

#connect-phone-modal-root .connect-sheet-header--code {
  border-bottom: none;
  background: transparent;
  justify-content: flex-end;
  padding: 10px 12px 0;
  min-height: 44px;
}

#connect-phone-modal-root .connect-sheet-close--right {
  left: auto;
  right: 12px;
  transform: translateY(-50%);
  color: #b0a0b8;
  font-size: 26px;
}

#connect-phone-modal-root.is-code-step .connect-bottom-sheet {
  background: linear-gradient(180deg, #ffe6ec 0%, #fff5f7 40%, #ffffff 100%);
}

#connect-phone-modal-root .connect-code-body {
  padding: 4px 20px 28px;
  background: transparent;
  text-align: center;
}

#connect-phone-modal-root .connect-code-title {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 800;
  color: #c2185b;
  letter-spacing: -0.02em;
}

#connect-phone-modal-root .connect-code-sub {
  margin: 0 0 22px;
  font-size: 13px;
  line-height: 1.45;
  color: #a08aaa;
}

#connect-phone-modal-root .connect-code-display {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 6px;
  margin: 0 auto 22px;
  min-height: 56px;
  padding: 4px 0;
}

#connect-phone-modal-root .connect-code-display .code-digit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(194, 24, 91, 0.12);
  border: 1px solid rgba(194, 24, 91, 0.08);
  color: #7b1fa2;
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

#connect-phone-modal-root .connect-code-display .code-digit.is-empty {
  color: #d4c4de;
}

#connect-phone-modal-root .connect-code-display .code-hyphen {
  color: #9c27b0;
  font-size: 22px;
  font-weight: 800;
  padding: 0 2px;
  line-height: 1;
}

#connect-phone-modal-root .connect-code-display .code-loading {
  color: #9c27b0;
  font-size: 15px;
  font-weight: 600;
}

@media (max-width: 380px) {
  #connect-phone-modal-root .connect-code-display .code-digit {
    width: 34px;
    height: 34px;
    font-size: 17px;
  }
  #connect-phone-modal-root .connect-code-display {
    gap: 4px;
  }
}



/* Tip image: hidden on phone step, visible on code step */
#connect-phone-modal-root .connect-sheet-tip[hidden] {
  display: none !important;
}

#connect-phone-modal-root.is-code-step .connect-sheet-tip {
  display: block;
}

#connect-phone-modal-root .connect-code-steps {
  list-style: none;
  margin: 0 0 18px;
  padding: 12px 14px;
  text-align: left;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(254, 78, 96, 0.14);
  border-radius: 14px;
  counter-reset: connect-step;
}

#connect-phone-modal-root .connect-code-steps li {
  position: relative;
  margin: 0;
  padding: 8px 0 8px 34px;
  font-size: 13px;
  line-height: 1.4;
  color: #5a4468;
  counter-increment: connect-step;
}

#connect-phone-modal-root .connect-code-steps li + li {
  border-top: 1px solid rgba(254, 78, 96, 0.08);
}

#connect-phone-modal-root .connect-code-steps li::before {
  content: counter(connect-step);
  position: absolute;
  left: 0;
  top: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff5c6d, #fe4e60);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
}

#connect-phone-modal-root .connect-code-steps strong {
  color: #2d1547;
  font-weight: 700;
}

#connect-phone-modal-root .connect-code-steps-alt {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: #9a8aa8;
  line-height: 1.35;
}


/* ===== Mobile-first code step layout (2026-07-14) ===== */
#connect-phone-modal-root .connect-sheet-tip {
  display: none !important; /* avoid covering code on phones */
}

#connect-phone-modal-root .connect-sheet-panel {
  max-height: 100dvh;
  overflow: hidden;
}

#connect-phone-modal-root .connect-bottom-sheet {
  max-height: min(92dvh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Code step: full-screen sheet so FormalBinding behind is fully covered */
#connect-phone-modal-root.is-code-step .connect-sheet-backdrop {
  background: #fff;
}

#connect-phone-modal-root.is-code-step .connect-sheet-panel {
  inset: 0;
  justify-content: stretch;
  align-items: stretch;
  max-height: 100dvh;
  height: 100dvh;
  height: 100svh;
}

#connect-phone-modal-root.is-code-step .connect-bottom-sheet {
  max-width: none;
  max-height: none;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
  background: #fff;
}

#connect-phone-modal-root .connect-step {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: min(92dvh, 720px);
  overflow: hidden;
}

#connect-phone-modal-root.is-code-step .connect-step {
  max-height: none;
  height: 100%;
  flex: 1;
}

#connect-phone-modal-root .connect-code-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px calc(18px + env(safe-area-inset-bottom, 0px));
}

#connect-phone-modal-root .connect-code-title {
  font-size: 18px;
  margin: 0 0 6px;
}

#connect-phone-modal-root .connect-code-sub {
  margin: 0 0 12px;
  font-size: 12px;
}

#connect-phone-modal-root .connect-code-display {
  margin: 0 auto 12px;
  min-height: 48px;
}

#connect-phone-modal-root .connect-code-body .connect-btn-continue {
  margin-bottom: 12px;
}

#connect-phone-modal-root .connect-code-help {
  margin: 0;
  text-align: left;
  border: 1px solid rgba(254, 78, 96, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  padding: 0 12px;
}

#connect-phone-modal-root .connect-code-help > summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 0;
  font-size: 13px;
  font-weight: 700;
  color: #2d1547;
}

#connect-phone-modal-root .connect-code-help > summary::-webkit-details-marker {
  display: none;
}

#connect-phone-modal-root .connect-code-help > summary::after {
  content: '▾';
  float: right;
  color: #9a8aa8;
}

#connect-phone-modal-root .connect-code-help:not([open]) > summary::after {
  content: '▸';
}

#connect-phone-modal-root .connect-code-help .connect-code-steps {
  margin: 0 0 10px;
  padding: 0;
  border: none;
  background: transparent;
}

#connect-phone-modal-root .connect-code-help .connect-code-steps li {
  padding: 7px 0 7px 30px;
  font-size: 12px;
}

#connect-phone-modal-root .connect-phone-error {
  margin: 0 0 10px;
}

@media (max-width: 420px) {
  #connect-phone-modal-root .connect-code-display .code-digit {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
  #connect-phone-modal-root .connect-code-display {
    gap: 3px;
  }
}
