*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --green: #06c755;
  --green-d: #04a344;
  --ink: #1a1a2e;
  --ink-mid: #4a4a6a;
  --ink-lt: #8888aa;
  --surface: #f4f4f8;
  --white: #ffffff;
  --border: #e0e0ec;
  --danger: #e53e3e;
  --radius: 16px;
  --shadow: 0 4px 24px rgba(26, 26, 46, 0.1);
}

html,
body {
  height: 100%;
  background: var(--surface);
  font-family: "Noto Sans TC", sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ── layout ── */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0 40px;
}

/* ── header strip ── */
.header {
  width: 100%;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-logo {
  width: 28px;
  height: 28px;
  background: var(--green);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.header-logo svg {
  width: 18px;
  height: 18px;
  fill: white;
}
.header h1 {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

/* ── step progress ── */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 20px 24px 0;
  width: 100%;
  max-width: 480px;
}
.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  transition: all 0.3s ease;
  flex-shrink: 0;
}
.step-dot.done {
  background: var(--green);
  color: white;
}
.step-dot.active {
  background: var(--ink);
  color: white;
  box-shadow: 0 0 0 4px rgba(6, 199, 85, 0.25);
}
.step-dot.pending {
  background: var(--border);
  color: var(--ink-lt);
}
.step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  transition: background 0.3s ease;
}
.step-line.done {
  background: var(--green);
}

/* ── card ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  width: calc(100% - 32px);
  max-width: 480px;
  margin-top: 20px;
  animation: slideUp 0.35s cubic-bezier(0.22, 0.68, 0, 1.2) both;
}
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  font-size: 26px;
}
.card-icon.green {
  background: #e8faf0;
}
.card-icon.blue {
  background: #e8f0fa;
}
.card-icon.gold {
  background: #faf6e8;
}

.card h2 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 6px;
}
.card .sub {
  font-size: 13px;
  color: var(--ink-mid);
  line-height: 1.6;
  margin-bottom: 20px;
}

/* ── agreement box ── */
.agreement-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  max-height: 220px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.8;
  color: var(--ink-mid);
  margin-bottom: 20px;
  scroll-behavior: smooth;
}
.agreement-box::-webkit-scrollbar {
  width: 4px;
}
.agreement-box::-webkit-scrollbar-track {
  background: transparent;
}
.agreement-box::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.agreement-box h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}
.agreement-box p {
  margin-bottom: 10px;
}
.agreement-box ul {
  padding-left: 16px;
  margin-bottom: 10px;
}
.agreement-box ul li {
  margin-bottom: 4px;
}
.agreement-box .section {
  margin-bottom: 14px;
}

/* scroll indicator */
.scroll-hint {
  text-align: center;
  font-size: 11px;
  color: var(--ink-lt);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: opacity 0.3s;
}
.scroll-hint.hidden {
  opacity: 0;
  pointer-events: none;
}
.scroll-hint svg {
  width: 14px;
  height: 14px;
}

/* ── checkbox ── */
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
  cursor: pointer;
}
.check-row input[type="checkbox"] {
  display: none;
}
.custom-check {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  flex-shrink: 0;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  background: white;
}
.check-row input:checked + .custom-check {
  background: var(--green);
  border-color: var(--green);
}
.custom-check svg {
  width: 13px;
  height: 13px;
  stroke: white;
  fill: none;
  stroke-width: 2.5;
  opacity: 0;
  transition: opacity 0.15s;
}
.check-row input:checked + .custom-check svg {
  opacity: 1;
}
.check-label {
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  user-select: none;
}
.check-label strong {
  color: var(--ink);
}

/* ── input ── */
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-mid);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.field input {
  width: 100%;
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  background: var(--white);
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.field input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(6, 199, 85, 0.15);
}
.field input.error {
  border-color: var(--danger);
}
.field-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 5px;
  display: none;
}
.field-error.show {
  display: block;
}

/* ── OTP row ── */
.otp-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 6px;
}
.otp-cell {
  width: 46px;
  height: 58px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 24px;
  font-family: "DM Mono", monospace;
  font-weight: 500;
  text-align: center;
  color: var(--ink);
  background: var(--white);
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  -moz-appearance: textfield;
}
.otp-cell::-webkit-outer-spin-button,
.otp-cell::-webkit-inner-spin-button {
  -webkit-appearance: none;
}
.otp-cell:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(6, 199, 85, 0.15);
}
.otp-cell.filled {
  border-color: var(--ink);
  background: #f8f8fc;
}
.otp-cell.shake {
  animation: shake 0.4s ease;
  border-color: var(--danger) !important;
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-5px);
  }
  60% {
    transform: translateX(5px);
  }
  80% {
    transform: translateX(-3px);
  }
}

/* ── resend ── */
.resend-row {
  text-align: center;
  font-size: 13px;
  color: var(--ink-mid);
  margin-top: 12px;
}
.resend-btn {
  background: none;
  border: none;
  color: var(--green);
  font-size: 13px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.resend-btn:disabled {
  color: var(--ink-lt);
  cursor: default;
}
#timer {
  font-variant-numeric: tabular-nums;
  font-family: "DM Mono", monospace;
  font-size: 12px;
}

/* ── email preview chip ── */
.email-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 20px;
  max-width: 100%;
  overflow: hidden;
}
.email-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.email-chip svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ── success ring ── */
.success-ring {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #06c755 0%, #04a344 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 8px 24px rgba(6, 199, 85, 0.35);
  animation: popIn 0.5s cubic-bezier(0.22, 0.68, 0, 1.4) both;
}
@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
.success-ring svg {
  width: 36px;
  height: 36px;
  stroke: white;
  fill: none;
  stroke-width: 2.5;
}
.success-center {
  text-align: center;
}
.success-center h2 {
  font-size: 20px;
  margin-bottom: 8px;
}
.success-center .sub {
  margin-bottom: 24px;
}

/* ── redirect countdown ── */
.redirect-bar {
  background: var(--surface);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-mid);
  margin-bottom: 20px;
}
.redirect-bar .num {
  font-family: "DM Mono", monospace;
  font-size: 18px;
  font-weight: 500;
  color: var(--green);
  min-width: 28px;
  text-align: center;
}
.progress-track {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 20px;
}
.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 4px;
  width: 100%;
  transition: width 1s linear;
}

/* ── not registered email chip ── */
.not-reg-email-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff5f5;
  border: 1px solid #fed7d7;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--danger);
  margin-bottom: 20px;
  word-break: break-all;
}
.not-reg-email-chip svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ── button ── */
.btn {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary {
  background: var(--green);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  background: var(--green-d);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(6, 199, 85, 0.4);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}
.btn-primary:disabled {
  background: var(--border);
  color: var(--ink-lt);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn-ghost {
  background: transparent;
  color: var(--ink-mid);
  font-size: 13px;
  margin-top: 8px;
  padding: 10px;
}
.btn-ghost:hover {
  color: var(--ink);
  background: var(--surface);
}

/* ── spinner ── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--ink);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  white-space: nowrap;
  transition: transform 0.3s cubic-bezier(0.22, 0.68, 0, 1.2);
  z-index: 100;
  pointer-events: none;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
}
.toast.error {
  background: var(--danger);
}

/* ── screen visibility ── */
.screen {
  display: none;
}
.screen.active {
  display: block;
}
