:root {
  color-scheme: light;
  --page: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #f3f6f9;
  --text: #17212b;
  --muted: #66717d;
  --line: #e3e8ed;
  --blue: #168bd2;
  --blue-dark: #0878bd;
  --blue-soft: #eaf6fd;
  --success: #217a52;
  --success-soft: #eaf7f0;
  --danger: #a13d3d;
  --danger-soft: #fdf0f0;
  --shadow: 0 16px 40px rgba(25, 45, 65, 0.08);
}

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

html {
  background: var(--page);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 50% -180px, rgba(22, 139, 210, 0.11), transparent 430px),
    var(--page);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.page {
  width: min(780px, 100%);
  margin: 0 auto;
  padding: 40px 20px 56px;
}

.header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
  text-align: center;
}

.logo-box {
  display: grid;
  width: 76px;
  height: 76px;
  margin-bottom: 16px;
  place-items: center;
  border: 1px solid rgba(22, 139, 210, 0.18);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 12px 30px rgba(22, 139, 210, 0.12);
}

.logo-box img {
  display: block;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.flow {
  display: grid;
  gap: 14px;
}

.step {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.step-primary {
  border-color: rgba(22, 139, 210, 0.28);
  box-shadow:
    0 16px 44px rgba(22, 139, 210, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.step-marker {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid #d7e0e7;
  border-radius: 14px;
  color: #4f5f6d;
  background: var(--surface-soft);
  font-weight: 800;
}

.step-primary .step-marker {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(145deg, var(--blue), var(--blue-dark));
  box-shadow: 0 8px 18px rgba(22, 139, 210, 0.24);
}

.step-body {
  min-width: 0;
}

.step-body h2 {
  margin-bottom: 7px;
  font-size: 1.28rem;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.step-body > p {
  margin-bottom: 18px;
  color: var(--muted);
  line-height: 1.55;
}

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

.button-grid,
.connect-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.button {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 12px 15px;
  color: var(--text);
  background: var(--surface);
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.button:hover {
  border-color: #c8d2da;
  background: #f9fbfc;
  transform: translateY(-1px);
}

.button:focus-visible,
.connect-option:focus-visible,
.copy-button:focus-visible,
.subscription-input:focus-visible,
.pin-input:focus-visible,
.pin-button:focus-visible {
  outline: 3px solid rgba(22, 139, 210, 0.2);
  outline-offset: 2px;
}

.access-gate {
  display: grid;
  place-items: center;
}

.access-card {
  width: min(520px, 100%);
  border: 1px solid rgba(22, 139, 210, 0.2);
  border-radius: 22px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.access-card h2 {
  margin-bottom: 8px;
  font-size: 1.28rem;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.access-card p {
  margin-bottom: 16px;
  color: var(--muted);
  line-height: 1.55;
}

.pin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.pin-input {
  width: 100%;
  min-width: 0;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 13px;
  color: var(--text);
  background: var(--surface);
  letter-spacing: 0.08em;
}

.pin-button {
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  padding: 0 18px;
  color: #fff;
  background: var(--blue);
  font-weight: 800;
  cursor: pointer;
  transition:
    background 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.pin-button:hover {
  background: var(--blue-dark);
  box-shadow: 0 7px 18px rgba(22, 139, 210, 0.2);
  transform: translateY(-1px);
}

.pin-error {
  margin-top: 10px;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 0.88rem;
}

.tip {
  margin-top: 12px;
  border-radius: 11px;
  padding: 10px 12px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.86rem;
  line-height: 1.45;
}

.connect-option {
  display: flex;
  min-height: 86px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 15px 16px;
  color: var(--text);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
}

.connect-option:hover {
  border-color: rgba(22, 139, 210, 0.55);
  background: var(--blue-soft);
  box-shadow: 0 8px 20px rgba(22, 139, 210, 0.08);
  transform: translateY(-1px);
}

.connect-option:disabled {
  cursor: wait;
  opacity: 0.58;
  transform: none;
}

.connect-option-title {
  font-weight: 800;
  line-height: 1.25;
}

.connect-option-description {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.3;
}

.status {
  margin-top: 12px;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.9rem;
  line-height: 1.48;
}

.status-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #42677f;
  background: var(--blue-soft);
}

.status-success {
  color: var(--success);
  background: var(--success-soft);
}

.status-error {
  color: var(--danger);
  background: var(--danger-soft);
}

.spinner {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  border: 2px solid rgba(22, 139, 210, 0.2);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.manual-result {
  margin-top: 12px;
  border: 1px solid rgba(22, 139, 210, 0.2);
  border-radius: 15px;
  padding: 16px;
  background: var(--blue-soft);
  opacity: 0;
  transform: translateY(10px) scale(0.985);
  transform-origin: top center;
  transition:
    opacity 280ms ease,
    transform 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.manual-result.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.manual-result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.manual-result-header strong {
  display: block;
  margin-bottom: 4px;
}

.manual-result-header p {
  margin-bottom: 0;
  color: #527086;
  font-size: 0.88rem;
  line-height: 1.4;
}

.demo-label {
  width: fit-content;
  margin-top: 7px;
  border-radius: 999px;
  padding: 4px 8px;
  color: #775b1d !important;
  background: #fff5cf;
  font-size: 0.74rem !important;
  font-weight: 700;
}

.profile-name {
  flex: 0 0 auto;
  border-radius: 8px;
  padding: 5px 8px;
  color: #337093;
  background: rgba(255, 255, 255, 0.78);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
}

.subscription-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 13px;
}

.subscription-input {
  width: 100%;
  min-width: 0;
  height: 46px;
  border: 1px solid rgba(22, 139, 210, 0.2);
  border-radius: 11px;
  padding: 0 12px;
  color: #294759;
  background: #fff;
  font-size: 0.86rem;
  cursor: copy;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.subscription-input:hover {
  border-color: rgba(22, 139, 210, 0.48);
}

.subscription-input.is-copied {
  border-color: rgba(33, 122, 82, 0.48);
  background: #f8fffb;
  box-shadow: 0 0 0 4px rgba(33, 122, 82, 0.1);
}

.copy-button {
  position: relative;
  display: inline-flex;
  min-height: 46px;
  min-width: 128px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 11px;
  padding: 0 16px;
  color: #fff;
  background: var(--blue);
  font-weight: 800;
  cursor: pointer;
  transition:
    background 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.copy-button:hover {
  background: var(--blue-dark);
  box-shadow: 0 7px 18px rgba(22, 139, 210, 0.2);
  transform: translateY(-1px);
}

.copy-button:active {
  transform: scale(0.97);
}

.copy-check {
  width: 0;
  height: 0;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  opacity: 0;
  transform: rotate(45deg) scale(0);
  transition:
    width 180ms ease,
    height 180ms ease,
    opacity 140ms ease,
    transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

.copy-button.is-copied {
  background: var(--success);
  box-shadow: 0 8px 20px rgba(33, 122, 82, 0.22);
}

.copy-button.is-copied .copy-check {
  width: 7px;
  height: 12px;
  opacity: 1;
  transform: rotate(45deg) scale(1);
}

.copy-button.is-copied .copy-button-label {
  animation: copyLabelIn 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

.manual-steps {
  margin: 14px 0 0;
  padding-left: 21px;
  color: #526a7b;
  font-size: 0.88rem;
  line-height: 1.6;
}

.hidden {
  display: none !important;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes copyLabelIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  body {
    background:
      radial-gradient(circle at 50% -130px, rgba(22, 139, 210, 0.1), transparent 320px),
      var(--page);
  }

  .page {
    padding: 24px 12px 34px;
  }

  .header {
    margin-bottom: 20px;
  }

  .logo-box {
    width: 66px;
    height: 66px;
    margin-bottom: 13px;
    border-radius: 19px;
  }

  .logo-box img {
    width: 42px;
    height: 42px;
  }

  h1 {
    font-size: 1.7rem;
  }

  .flow {
    gap: 10px;
  }

  .step {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 12px;
    padding: 17px 14px;
    border-radius: 17px;
  }

  .step-marker {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    font-size: 0.9rem;
  }

  .step-body h2 {
    font-size: 1.12rem;
  }

  .step-body > p {
    margin-bottom: 14px;
    font-size: 0.92rem;
  }

  .button-grid,
  .connect-options,
  .pin-row {
    grid-template-columns: 1fr;
  }

  .access-card {
    padding: 18px 14px;
    border-radius: 17px;
  }

  .button {
    min-height: 48px;
  }

  .connect-option {
    min-height: 76px;
  }

  .manual-result-header {
    display: block;
  }

  .profile-name {
    display: inline-block;
    margin-top: 9px;
  }

  .subscription-row {
    grid-template-columns: 1fr;
  }

  .copy-button {
    width: 100%;
  }
}

@media (max-width: 390px) {
  .page {
    padding-right: 9px;
    padding-left: 9px;
  }

  .step {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 10px;
    padding-right: 11px;
    padding-left: 11px;
  }

  .step-marker {
    width: 32px;
    height: 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
