:root {
  color-scheme: dark;
  --gold: #d7b56d;
  --gold-soft: #ead9b6;
  --ink: #f8f2e7;
  --muted: #c4b7a4;
  --surface: #171211;
  --field: #100d0d;
  --line: rgba(255, 246, 232, 0.15);
  --danger: #f0a096;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  min-height: 100svh;
  background: #090707;
  color: var(--ink);
}

body.pwa-install-page {
  position: relative;
  isolation: isolate;
  overflow-x: clip;
}

.pwa-page-background {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.22;
  pointer-events: none;
  z-index: -1;
}

.pwa-page-shell {
  width: min(100%, 540px);
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom));
}

.pwa-back {
  display: inline-block;
  margin: 0 0 20px;
  padding: 8px 0;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.88rem;
  text-underline-offset: 4px;
  text-decoration: underline;
}

.pwa-guide {
  width: 100%;
  padding: clamp(24px, 5vw, 36px);
  background: rgba(23, 18, 17, 0.92);
  color: var(--ink);
  line-height: 1.55;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 24px 80px #0006;
  backdrop-filter: blur(10px);
}

.pwa-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.pwa-brand > div { min-width: 0; }

.pwa-icon {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  border-radius: 16px;
  object-fit: cover;
  border: 1px solid rgba(215, 181, 109, 0.35);
}

.pwa-eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.pwa-brand h1 {
  margin: 0;
  font-size: clamp(1.4rem, 5vw, 1.9rem);
  line-height: 1.18;
  letter-spacing: -0.025em;
}

.pwa-status {
  margin: 0 0 20px;
  font-size: 0.97rem;
}

.pwa-stepper {
  display: flex;
  gap: 10px;
  margin: 0 0 22px;
}

.step-item {
  flex: 1;
  min-width: 0;
}

.step-item .step-bar {
  display: block;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
  margin-bottom: 8px;
}

.step-item.on .step-bar {
  background: var(--gold);
}

.step-item small {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.step-item.on small {
  color: var(--gold-soft);
}

.panel[hidden],
.screen[hidden] { display: none !important; }

/* ---- Two main screens + motion ---- */
.screen.is-enter {
  animation: screenIn 0.48s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.screen.is-exit {
  animation: screenOut 0.28s ease both;
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
@keyframes screenOut {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(-10px) scale(0.99); }
}

.reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: revealUp 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: calc(var(--d, 0) * 70ms + 40ms);
}
@keyframes revealUp {
  to { opacity: 1; transform: none; }
}

.phase-pills {
  display: flex;
  gap: 8px;
  margin: 0 0 20px;
}
.phase-pills .pill {
  flex: 1;
  text-align: center;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.25);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.phase-pills .pill.on {
  color: #17110a;
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 24px rgba(215, 181, 109, 0.35);
}
.phase-pills .pill.done {
  color: var(--gold-soft);
  border-color: rgba(215, 181, 109, 0.4);
  background: rgba(215, 181, 109, 0.12);
}

.activate-steps {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: grid;
  gap: 12px;
}
.activate-steps li {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 246, 232, 0.12);
  background: rgba(16, 13, 13, 0.55);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.activate-steps li:hover {
  border-color: rgba(215, 181, 109, 0.4);
  transform: translateY(-1px);
}
.activate-steps .n {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--gold);
  padding-top: 2px;
}
.activate-steps b {
  display: block;
  margin: 0 0 4px;
  font-size: 0.95rem;
}
.activate-steps p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.cta-stack { margin-top: 4px; }

.btn-ico {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
}
.btn-glow {
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, filter 0.2s ease, box-shadow 0.25s ease;
  box-shadow: 0 8px 28px rgba(215, 181, 109, 0.28);
}
.btn-glow::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.35) 50%, transparent 60%);
  transform: translateX(-120%);
  animation: sheen 3.2s ease-in-out infinite;
}
.btn-glow:hover {
  filter: brightness(1.06);
  box-shadow: 0 10px 34px rgba(215, 181, 109, 0.42);
}
.btn-glow:active { transform: scale(0.97); }
@keyframes sheen {
  0%, 55% { transform: translateX(-120%); }
  75%, 100% { transform: translateX(120%); }
}

.btn-confirm {
  transition: opacity 0.25s ease, transform 0.2s ease, border-color 0.25s ease, color 0.25s ease, background 0.25s ease;
}
.btn-confirm:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: none;
}
.btn-confirm.is-ready:not(:disabled) {
  border-color: var(--gold);
  color: #17110a;
  background: var(--gold);
  animation: confirmPop 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 8px 28px rgba(215, 181, 109, 0.3);
}
@keyframes confirmPop {
  0% { transform: scale(0.96); }
  60% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.confirm-hint {
  text-align: center;
  margin-top: 4px !important;
}
.confirm-hint.is-ok { color: #9be7b0; }

.pulse-soft {
  animation: pulseSoft 2.8s ease-in-out infinite;
}
@keyframes pulseSoft {
  0%, 100% { box-shadow: 0 0 0 0 rgba(215, 181, 109, 0.35); }
  50% { box-shadow: 0 0 0 8px rgba(215, 181, 109, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .screen.is-enter,
  .screen.is-exit,
  .reveal,
  .btn-glow::after,
  .pulse-soft,
  .btn-confirm.is-ready:not(:disabled) {
    animation: none !important;
  }
  .reveal { opacity: 1; transform: none; }
}

.auth-form {
  display: grid;
  gap: 12px;
  margin: 0 0 8px;
}

.auth-form label {
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--muted);
}

.auth-form input {
  width: 100%;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid rgba(255, 246, 232, 0.28);
  background: var(--field);
  color: inherit;
  padding: 10px 14px;
  font: inherit;
  font-size: 1rem;
}

.auth-form input:focus {
  outline: 3px solid #f8f2e7;
  outline-offset: 3px;
}

.auth-form input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}

.otp-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.otp-row input {
  letter-spacing: 0.35em;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.form-hint, .form-status {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--muted);
}

.form-status.is-error { color: var(--danger); }
.form-status.is-ok { color: #9be7b0; }

.bot-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  color: var(--gold);
  font-weight: 700;
  text-underline-offset: 3px;
}

.profile-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(215, 181, 109, 0.28);
  background: rgba(16, 13, 13, 0.7);
}

.profile-chip b {
  display: block;
  font-size: 1rem;
}

.profile-chip span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.pwa-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto;
  min-height: 48px;
  padding: 11px 18px;
  border: 1px solid var(--gold);
  border-radius: 12px;
  background: var(--gold);
  color: #17110a;
  font: inherit;
  font-size: 0.94rem;
  font-weight: 800;
  line-height: 1.35;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
}

.pwa-button:hover { filter: brightness(1.08); }
.pwa-button:disabled { cursor: wait; opacity: 0.65; }
.pwa-button.btn-confirm:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}
.pwa-primary { width: 100%; margin: 0 0 12px; }
.pwa-full { width: 100%; margin: 0 0 10px; }
.pwa-secondary {
  background: transparent;
  color: var(--gold);
}
.pwa-platform-picker {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 8px 0 18px;
}

.pwa-platform-picker label {
  flex: 1;
  font-size: 0.83rem;
  color: var(--muted);
  font-weight: 500;
}

.pwa-platform-picker select {
  width: auto;
  max-width: 60%;
  min-height: 44px;
  border: 1px solid #fff3;
  border-radius: 10px;
  padding: 8px;
  color: var(--ink);
  background: var(--field);
  font: inherit;
  font-size: 0.9rem;
}

.pwa-steps h3 {
  margin: 0 0 16px;
  font-size: 1rem;
}

.pwa-steps ol {
  list-style: none;
  counter-reset: install-step;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 16px;
}

.pwa-steps li {
  counter-increment: install-step;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 0.94rem;
}

.pwa-steps li::before {
  content: counter(install-step);
  flex: 0 0 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(215, 181, 109, 0.47);
  border-radius: 50%;
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 800;
}

.pwa-steps > p,
.pwa-note {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.6;
}

.pwa-steps > p { margin: 18px 0 0; }
.pwa-note { margin: 22px 0; }

.pwa-link-field {
  box-sizing: border-box;
  width: 100%;
  margin-top: 14px;
  min-height: 48px;
  border: 1px solid #fff5;
  border-radius: 10px;
  background: var(--field);
  color: var(--ink);
  padding: 10px;
  font: inherit;
  font-size: 0.85rem;
}

.pwa-guide-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding-top: 20px;
  border-top: 1px solid #fff2;
  margin-top: 8px;
}

.pwa-text-link {
  color: var(--ink);
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.5;
  text-underline-offset: 4px;
  text-decoration: underline;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}

.pwa-footnote {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.pwa-steps[hidden],
.pwa-button[hidden],
.pwa-link-field[hidden] {
  display: none !important;
}

@media (max-width: 359px) {
  .pwa-brand { gap: 10px; }
  .pwa-icon {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
    border-radius: 12px;
  }
  .pwa-guide {
    padding-left: 20px;
    padding-right: 20px;
  }
}
