/* Стили PWA «Примерочная».
 *
 * Тёмная витрина в духе fashion-ритейла: глубокий фон, мягкие световые пятна,
 * стеклянные карточки и градиентный акцент. Никакой внешней зависимости —
 * всё держится на переменных, чтобы телефон не тянул лишний вес.
 */

:root {
  --bg: #07070a;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f5f5f7;
  --muted: #9b9baa;
  --accent: #ff3d71;
  --accent-2: #a855f7;
  --accent-3: #ffb457;
  --radius: 20px;
  --radius-sm: 13px;
  --shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.9);
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  margin: 0;
  padding: 0 0 calc(28px + var(--safe-bottom));
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Световые пятна: дают глубину, не мешая читаемости. */
body::before {
  content: "";
  position: fixed;
  inset: -20% -10% auto;
  height: 70vh;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(46% 42% at 18% 8%, rgba(255, 61, 113, 0.28), transparent 68%),
    radial-gradient(40% 40% at 88% 2%, rgba(168, 85, 247, 0.26), transparent 66%);
  filter: blur(10px);
}

/* --------------------------------------------------------------- каркас */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(12px + var(--safe-top)) 18px 12px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  min-width: 0;
}

.brand-mark {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2) 70%, var(--accent-3));
  box-shadow: 0 6px 18px -6px rgba(255, 61, 113, 0.9);
}

.brand-text {
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-text em {
  font-style: normal;
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

main {
  position: relative;
  z-index: 1;
  max-width: 620px;
  margin: 0 auto;
  padding: 18px 16px 8px;
  display: grid;
  gap: 16px;
}

.screen {
  display: grid;
  gap: 16px;
  animation: rise 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* ---------------------------------------------------------------- герой */

.hero {
  padding: 14px 4px 4px;
  display: grid;
  gap: 10px;
}

.hero.compact {
  padding-bottom: 0;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 8vw, 38px);
  line-height: 1.06;
  letter-spacing: -0.035em;
  font-weight: 800;
}

h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.015em;
}

.lede {
  margin: 0;
  color: var(--muted);
  font-size: 14.5px;
  max-width: 46ch;
}

.pill {
  justify-self: start;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
}

/* -------------------------------------------------------------- карточки */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.step-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.step-num {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(140deg, rgba(255, 61, 113, 0.9), rgba(168, 85, 247, 0.9));
  box-shadow: 0 8px 20px -10px rgba(168, 85, 247, 0.9);
}

.step-title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.muted {
  color: var(--muted);
  font-weight: 400;
  font-size: 13.5px;
  margin: 0;
}

.stack {
  display: grid;
  gap: 12px;
}

label {
  font-size: 13.5px;
  color: var(--muted);
}

/* ------------------------------------------------------------- контролы */

input[type="password"],
input[type="text"],
select {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
  transition: border-color 0.18s, box-shadow 0.18s;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

input[type="password"]:focus,
input[type="text"]:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.16);
}

.password-field {
  position: relative;
  display: flex;
  align-items: center;
}

.password-field input {
  padding-right: 100px;
}

.password-field .reveal {
  position: absolute;
  right: 6px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

button,
.ghost,
a.ghost,
a.primary {
  font: inherit;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 12px 18px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: transform 0.14s, border-color 0.18s, opacity 0.18s;
}

button:active,
a.primary:active {
  transform: scale(0.975);
}

button.primary,
a.primary {
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  border: none;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 16px 34px -18px rgba(255, 61, 113, 0.95);
}

button.wide {
  width: 100%;
  padding: 16px;
}

.cta {
  font-size: 16.5px;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.chip {
  padding: 8px 14px;
  font-size: 13.5px;
  border-radius: 999px;
  background: var(--surface);
}

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

/* ------------------------------------------------------ источник фото */

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
}

.seg {
  border: none;
  background: transparent;
  padding: 10px 8px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

.seg.is-active {
  color: #fff;
  background: linear-gradient(100deg, rgba(255, 61, 113, 0.95), rgba(168, 85, 247, 0.95));
  box-shadow: 0 10px 24px -14px rgba(168, 85, 247, 1);
}

.picker {
  display: grid;
  gap: 12px;
}

.pane {
  animation: fade 0.22s ease;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.dropzone {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 18px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--line-strong);
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.dropzone:hover,
.dropzone:active {
  border-color: var(--accent-2);
  background: rgba(168, 85, 247, 0.08);
}

.dz-icon {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(140deg, rgba(255, 61, 113, 0.85), rgba(168, 85, 247, 0.85));
}

.dz-text {
  display: grid;
  gap: 1px;
  font-size: 14.5px;
}

/* --------------------------------------------------------- демо-набор */

.demo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}

.demo-item {
  position: relative;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
  aspect-ratio: 3 / 4;
  cursor: pointer;
  transition: border-color 0.18s, transform 0.14s;
}

.demo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.demo-item:hover {
  transform: translateY(-2px);
}

.demo-item.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 61, 113, 0.25);
}

.demo-item .check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.16s, transform 0.16s;
}

.demo-item.is-selected .check {
  opacity: 1;
  transform: scale(1);
}

/* -------------------------------------------------------- выбранное */

.selection {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 8px;
}

.selection:empty {
  display: none;
}

.thumb {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line);
  aspect-ratio: 3 / 4;
  background: rgba(0, 0, 0, 0.35);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(6, 6, 10, 0.72);
  border-color: var(--line);
  backdrop-filter: blur(6px);
}

.counter {
  font-size: 13px;
}

/* --------------------------------------------------------- результат */

.preview {
  display: grid;
  gap: 10px;
}

.preview.big img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  display: block;
}

/* ------------------------------------------------------------ статус */

.status {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(12px);
}

.progress {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.progress > i {
  display: block;
  height: 100%;
  width: 38%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  animation: slide 1.5s ease-in-out infinite;
}

@keyframes slide {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(320%);
  }
}

/* ------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 40;
  max-width: min(92vw, 520px);
  padding: 13px 18px;
  border-radius: 16px;
  font-size: 14.5px;
  color: #fff;
  background: rgba(20, 20, 26, 0.94);
  border: 1px solid var(--line-strong);
  box-shadow: 0 20px 44px -20px rgba(0, 0, 0, 1);
  backdrop-filter: blur(14px);
  animation: toast-in 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.toast.is-error {
  border-color: rgba(255, 61, 113, 0.6);
  background: rgba(46, 12, 24, 0.95);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 14px);
  }
}

.error {
  color: #ff8fa8;
  font-size: 13.5px;
  margin: 0;
}

.hidden {
  display: none !important;
}

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

  .progress > i {
    animation: none;
    width: 100%;
  }
}
