/* Мастер Happ (index.html) — оформление только здесь */

body.miniapp-wizard {
  padding: max(8px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px));
}

.shell:has(#screen-main) {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 20px);
}

#screen-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#screen-main>.app-head {
  flex-shrink: 0;
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 6px 4px 2px;
}

body.miniapp-wizard .app-head-ico {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(139, 124, 255, 0.35), rgba(139, 124, 255, 0.08));
  border: 1px solid rgba(139, 124, 255, 0.35);
  box-shadow: 0 8px 28px rgba(107, 91, 220, 0.22);
}

body.miniapp-wizard .app-head-title {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text);
}

#screen-main,
#screen-load {
  position: relative;
  z-index: 1;
}

/* Каркас мастера: одна «карта» на экран, контент по центру, низ — панель действий */
.phase-wizard,
#phase-wizard,
.phase-final,
#phase-final {
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  min-height: 0;
}

#phase-wizard>.err {
  flex-shrink: 0;
  margin-bottom: 8px;
}

.wizard-sub-banner {
  flex-shrink: 0;
  margin: 0 0 10px;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.45;
  color: rgba(242, 242, 246, 0.88);
  background: rgba(255, 186, 120, 0.1);
  border: 1px solid rgba(255, 186, 120, 0.28);
}

.wizard-sub-banner.hidden {
  display: none;
}

.wizard-card {
  flex: 1 1 0%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    linear-gradient(168deg, rgba(139, 124, 255, 0.11) 0%, transparent 42%),
    linear-gradient(205deg, rgba(22, 22, 30, 0.98) 0%, rgba(11, 11, 15, 0.94) 45%, rgba(18, 18, 26, 0.97) 100%);
  box-shadow:
    0 0 0 1px rgba(139, 124, 255, 0.07) inset,
    0 32px 64px rgba(0, 0, 0, 0.55),
    0 1px 0 rgba(255, 255, 255, 0.04) inset;
  overflow: hidden;
}

.wizard-progress {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  padding: 16px 14px 12px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.15);
}

.wiz-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  transition:
    width 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.25s ease,
    box-shadow 0.25s ease,
    transform 0.2s ease;
}

.wiz-dot.is-current {
  width: 26px;
  background: linear-gradient(90deg, #6b5bdc, var(--accent) 55%, #c4b8ff);
  box-shadow:
    0 0 20px rgba(139, 124, 255, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.12) inset;
}

.wizard-body {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.wizard-middle {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  /* Не center: при разной высоте блока заголовок «прыгает» между шагами */
  justify-content: flex-start;
  align-items: center;
  padding: clamp(16px, calc(2.2vh + 8px), 30px) 0 20px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.wizard-panel {
  width: 100%;
  max-width: 26.5rem;
  margin: 0 auto;
  padding: 0 14px;
}

#step-inner {
  margin-top: 0.35rem;
  text-align: left;
  width: 100%;
}

.no-access-wrap {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0 16px;
}

.no-access-card {
  width: 100%;
  max-width: 26.5rem;
  border-radius: 16px;
  padding: 22px 20px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  text-align: center;
}

.no-access-title {
  margin: 0 0 10px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.no-access-desc {
  margin: 0 0 20px;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--muted);
}

.no-access-card .btn-primary {
  width: 100%;
  justify-content: center;
}

.btn-skip-unobtrusive {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  opacity: 0.85;
}

.btn-skip-unobtrusive:active {
  opacity: 1;
}

.step-sheet {
  will-change: transform, opacity;
  width: 100%;
  margin: 0 auto;
  text-align: center;
}

@keyframes sheetOutL {
  to {
    transform: translateX(-14px) scale(0.99);
    opacity: 0;
  }
}

@keyframes sheetOutR {
  to {
    transform: translateX(14px) scale(0.99);
    opacity: 0;
  }
}

@keyframes sheetInR {
  from {
    transform: translateX(18px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes sheetInL {
  from {
    transform: translateX(-18px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.step-sheet.anim-outL {
  animation: sheetOutL 0.22s ease forwards;
}

.step-sheet.anim-outR {
  animation: sheetOutR 0.22s ease forwards;
}

.step-sheet.anim-inR {
  animation: sheetInR 0.38s cubic-bezier(0.22, 1, 0.32, 1) forwards;
}

.step-sheet.anim-inL {
  animation: sheetInL 0.38s cubic-bezier(0.22, 1, 0.32, 1) forwards;
}

.step-hero {
  margin: 0 auto 1.15rem;
  max-width: 22.5rem;
  padding: 0 2px;
}

.step-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(139, 124, 255, 0.95);
}

.step-name {
  margin: 0 0 0.5rem;
  font-size: clamp(1.22rem, 4.2vw, 1.48rem);
  font-weight: 700;
  letter-spacing: -0.048em;
  line-height: 1.12;
  color: var(--text);
  text-wrap: balance;
}

.step-desc {
  margin: 0 auto;
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.48;
  letter-spacing: 0.01em;
  color: rgba(242, 242, 246, 0.62);
  text-wrap: balance;
}

#step-inner>.card:last-child {
  margin-bottom: 0;
}

#step-inner .link-row {
  text-align: center;
  font-size: 0.8rem;
  line-height: 1.45;
}

.connect-lead {
  margin: 0 auto 1rem;
  max-width: 21rem;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.48;
  letter-spacing: 0.01em;
  color: rgba(242, 242, 246, 0.88);
  text-align: center;
  text-wrap: balance;
}

.connect-tuning {
  margin: 0 0 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.22);
  text-align: left;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.connect-tuning[open] {
  border-color: rgba(139, 124, 255, 0.35);
  box-shadow: 0 0 0 1px rgba(139, 124, 255, 0.12);
}

.connect-tuning-sum {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  position: relative;
  padding: 14px 40px 14px 16px;
  cursor: pointer;
  list-style: none;
  text-align: left;
}

.connect-tuning-sum::-webkit-details-marker {
  display: none;
}

.connect-tuning-sum::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -5px;
  border-right: 2px solid rgba(180, 180, 195, 0.75);
  border-bottom: 2px solid rgba(180, 180, 195, 0.75);
  transform: rotate(45deg);
  transition: transform 0.22s ease;
}

.connect-tuning[open] .connect-tuning-sum::after {
  transform: rotate(225deg);
  margin-top: -2px;
}

.connect-tuning-sum-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(139, 124, 255, 0.92);
}

.connect-tuning-sum-os {
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
}

.connect-tuning-text {
  margin: 0;
  padding: 0 16px 16px;
  font-size: 0.76rem;
  font-weight: 400;
  line-height: 1.48;
  letter-spacing: 0.015em;
  color: rgba(242, 242, 246, 0.55);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  padding-top: 12px;
}

.card-connect .btn-ghost {
  margin-top: 2px;
}

.card-os {
  padding-top: 16px;
  border-color: rgba(139, 124, 255, 0.2);
  box-shadow: 0 0 0 1px rgba(139, 124, 255, 0.06) inset;
  text-align: left;
}

.device-summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.device-summary-ico {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  background: var(--accent-soft);
  border: 1px solid rgba(139, 124, 255, 0.28);
  flex-shrink: 0;
  overflow: hidden;
}

.os-icon {
  display: block;
  object-fit: contain;
  pointer-events: none;
}

.os-icon--lg {
  width: 28px;
  height: 28px;
}

.os-icon--sm {
  width: 22px;
  height: 22px;
}

.os-icon--tv {
  width: 22px;
  height: 22px;
  filter: invert(1);
  opacity: 0.88;
}

.device-summary-text p {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 500;
  color: rgba(242, 242, 246, 0.55);
  line-height: 1.42;
  letter-spacing: 0.01em;
}

#os-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

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

.chip {
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  padding: 10px 4px 11px;
  border-radius: 12px;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  min-height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.chip:active {
  transform: scale(0.97);
}

.chip-ico {
  font-size: 1.05rem;
  line-height: 1;
  min-height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chip-lbl {
  font-size: 0.65rem;
  line-height: 1.1;
}

.chip:hover {
  border-color: rgba(139, 124, 255, 0.45);
}

.chip.active {
  border-color: var(--accent);
  background: rgba(139, 124, 255, 0.12);
  box-shadow: 0 0 0 1px rgba(139, 124, 255, 0.35);
}

.downloads {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.dl-btn {
  display: block;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 14px;
  padding: 15px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  background:
    linear-gradient(150deg, rgba(139, 124, 255, 0.12) 0%, rgba(139, 124, 255, 0.02) 44%, rgba(255, 255, 255, 0.02) 100%),
    rgba(255, 255, 255, 0.04);
  color: var(--text);
  line-height: 1.3;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.22),
    0 0 0 1px rgba(139, 124, 255, 0.07) inset;
  transition: border-color 0.18s, background 0.18s, transform 0.12s ease, box-shadow 0.18s;
}

.dl-btn:hover {
  border-color: rgba(139, 124, 255, 0.48);
  background:
    linear-gradient(150deg, rgba(139, 124, 255, 0.18) 0%, rgba(139, 124, 255, 0.04) 44%, rgba(255, 255, 255, 0.03) 100%),
    rgba(255, 255, 255, 0.05);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(139, 124, 255, 0.16) inset;
}

.dl-btn:active {
  transform: translateY(1px) scale(0.996);
}

.link-row {
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.link-row a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(139, 124, 255, 0.35);
}

.mode-hint {
  margin: 0 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.mode-opt {
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  padding: 12px 10px;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.mode-opt-title {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.mode-opt-sub {
  display: block;
  margin-top: 4px;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.35;
}

.mode-opt.active {
  border-color: var(--accent);
  background: rgba(139, 124, 255, 0.12);
  box-shadow: 0 0 0 1px rgba(139, 124, 255, 0.35);
}

.mode-desc {
  margin: 0 0 14px;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
  min-height: 2.85em;
}

.tips-disclosure {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  text-align: left;
  overflow: hidden;
}

.tips-disclosure-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 12px 14px;
  background: transparent;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.35;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
}

.tips-disclosure-toggle:active {
  background: rgba(255, 255, 255, 0.05);
}

.tips-disclosure-label {
  flex: 1;
  min-width: 0;
}

.tips-disclosure-hint {
  display: block;
  margin-top: 3px;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--muted);
}

.tips-disclosure-chevron {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  margin-right: 2px;
  border-right: 2px solid rgba(154, 154, 168, 0.85);
  border-bottom: 2px solid rgba(154, 154, 168, 0.85);
  transform: rotate(45deg);
  transition: transform 0.24s ease, border-color 0.15s ease;
}

.tips-disclosure.is-open .tips-disclosure-chevron {
  transform: rotate(225deg);
  margin-top: 3px;
}

.tips-disclosure.is-open .tips-disclosure-toggle .tips-disclosure-hint {
  display: none;
}

.tips-disclosure-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease;
}

.tips-disclosure.is-open .tips-disclosure-wrap {
  grid-template-rows: 1fr;
}

.tips-disclosure-inner {
  overflow: hidden;
  min-height: 0;
}

.tips-disclosure.is-open .tips-disclosure-inner {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.tips-disclosure .tips-list {
  margin: 0;
  padding: 12px 14px 14px 1.05rem;
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--muted);
}

.tips-disclosure .tips-list li {
  margin: 0 0 6px;
}

.tips-disclosure .tips-list li:last-child {
  margin-bottom: 0;
}

.nav-row,
.wizard-footer {
  flex-shrink: 0;
  width: 100%;
  margin-top: auto;
  padding: 20px 16px max(16px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: linear-gradient(180deg, rgba(12, 12, 18, 0.2) 0%, rgba(8, 8, 12, 0.72) 55%, rgba(6, 6, 10, 0.88) 100%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.wizard-footer .wizard-btn-next {
  border-radius: 14px;
  padding: 16px 20px;
  font-size: 1rem;
  letter-spacing: -0.02em;
  box-shadow:
    0 12px 36px rgba(107, 91, 220, 0.38),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.wizard-footer .wizard-btn-back {
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(242, 242, 246, 0.75);
}

/* Карточки и списки внутри мастера */
#phase-wizard #step-inner>.card {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 18px;
  padding: 18px 16px;
  margin-bottom: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
}

#phase-wizard #step-inner>.card.card-connect {
  padding: 1.2rem 1.1rem 1.05rem;
  border-radius: 19px;
  background:
    linear-gradient(155deg, rgba(139, 124, 255, 0.12) 0%, transparent 46%),
    rgba(255, 255, 255, 0.04);
  border-color: rgba(139, 124, 255, 0.22);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(139, 124, 255, 0.08) inset;
}

#phase-wizard .dl-btn {
  border-radius: 14px;
  padding: 16px 15px;
  font-size: 0.92rem;
  background:
    linear-gradient(150deg, rgba(139, 124, 255, 0.14) 0%, rgba(139, 124, 255, 0.03) 42%, rgba(255, 255, 255, 0.03) 100%),
    rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

#phase-wizard .chip {
  border-radius: 14px;
  min-height: 68px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

#phase-wizard .btn-ghost {
  border-radius: 12px;
  margin-top: 4px;
}

.phase-fade-out {
  animation: phFadeOut 0.28s ease forwards;
}

.phase-fade-in {
  animation: phFadeIn 0.45s ease forwards;
}

@keyframes phFadeOut {
  to {
    opacity: 0;
  }
}

@keyframes phFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

#phase-final .wizard-panel .trust {
  margin-top: 4px;
}

.final-wrap {
  text-align: center;
  padding-top: 20px;
  /* было 8px + ~50px воздуха над блоком «Готово» */
}

.final-icon-wrap {
  width: 88px;
  height: 88px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.final-check {
  width: 88px;
  height: 88px;
  color: var(--ok);
  overflow: visible;
}

.final-check .fc-circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-dasharray: 214;
  stroke-dashoffset: 214;
  opacity: 0.95;
  transform: rotate(-90deg);
  transform-origin: 40px 40px;
}

.final-check .fc-path {
  fill: none;
  stroke: currentColor;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 64;
  stroke-dashoffset: 64;
}

.final-check.draw .fc-circle {
  animation: fcDrawCircle 0.55s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.final-check.draw .fc-path {
  animation: fcDrawPath 0.45s cubic-bezier(0.4, 0, 0.2, 1) 0.42s forwards;
}

@keyframes fcDrawCircle {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes fcDrawPath {
  to {
    stroke-dashoffset: 0;
  }
}

.final-check.morph-in {
  animation: checkPop 0.55s cubic-bezier(0.34, 1.4, 0.32, 1) forwards;
}

@keyframes checkPop {
  from {
    transform: scale(0.35) rotate(-8deg);
    opacity: 0;
  }

  to {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

.final-title {
  margin: 0 0 10px;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.final-text {
  margin: 0 auto 20px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--muted);
  max-width: 22rem;
}

.trust {
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 14px;
  padding: 12px 14px;
  text-align: left;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
}