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

html, body {
  height: 100%;
  overflow: hidden;
  background: #0d0b10;
  color: #f5f2f7;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- Видео-сцена ---------- */

#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
  overflow: hidden;
}

#video, #overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#video.mirror, #overlay.mirror {
  transform: scaleX(-1);
}

/* ползунок длины: поверх видео сверху, жест остаётся у ползунка */
.slider-top {
  position: absolute;
  top: 104px;
  left: 12px;
  right: 12px;
  z-index: 24;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.52);
  font-size: 13px;
  font-weight: 600;
}
.slider-top input { flex: 1; }

#length {
  touch-action: none;
  height: 34px;
}

/* кнопка-затвор фото-режима и возврат к камере */
.shutter {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 25;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.22);
  font-size: 24px;
  line-height: 1;
  color: #fff;
  cursor: pointer;
}
.shutter:active { transform: translateX(-50%) scale(0.92); }

.back-live {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 25;
  padding: 11px 20px;
  border: none;
  border-radius: 24px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

/* плашка замера скорости нейросети */
.perf {
  position: absolute;
  left: 10px;
  top: 60px;
  z-index: 30;
  padding: 7px 11px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.65);
  color: #7cffb2;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: linear-gradient(to bottom, rgba(0,0,0,0.45), transparent);
}

.brand {
  font-weight: 700;
  font-size: 17px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

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

.icon-btn {
  width: 42px; height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(20, 18, 26, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: 19px;
  cursor: pointer;
  transition: background .15s;
}
.icon-btn:active { background: rgba(60, 55, 75, 0.7); }

.settings {
  position: absolute;
  top: 64px; right: 12px;
  width: min(320px, calc(100% - 24px));
  background: rgba(20, 18, 26, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 6px 14px;
  z-index: 5;
}

.switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  font-size: 14px;
  cursor: pointer;
}
.switch-row + .switch-row { border-top: 1px solid rgba(255,255,255,0.08); }
.switch-row small { color: #a99fb8; }
.switch-row input { width: 20px; height: 20px; accent-color: #e91e63; flex-shrink: 0; }

.status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(13, 11, 16, 0.85);
  z-index: 10;
  text-align: center;
  padding: 20px;
  font-size: 15px;
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: #e91e63;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: rgba(20, 18, 26, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 9px 18px;
  border-radius: 22px;
  font-size: 14px;
  white-space: nowrap;
  transition: opacity .3s;
}

.hidden { display: none !important; }

/* ---------- Нижняя панель ---------- */

#panel {
  flex-shrink: 0;
  background: #16131c;
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px 0;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  color: #a99fb8;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab.active {
  background: rgba(233, 30, 99, 0.16);
  color: #ff6ea0;
}

.tab-panel {
  display: none;
  padding: 12px 14px 16px;
  min-height: 96px;
}
.tab-panel.active { display: block; }

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.swatch {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.18);
  cursor: pointer;
  transition: transform .12s, border-color .12s;
}
.swatch.active {
  border-color: #fff;
  transform: scale(1.15);
  box-shadow: 0 0 0 3px rgba(233, 30, 99, 0.35);
}

.custom-color {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 14px;
  color: #a99fb8;
}
.custom-color input {
  width: 46px; height: 30px;
  border: none;
  background: none;
  cursor: pointer;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.05);
  color: #ddd6e8;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.chip.active {
  background: rgba(233, 30, 99, 0.2);
  border-color: #e91e63;
  color: #ff9dbd;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  font-size: 14px;
  color: #a99fb8;
}
.slider-row input {
  flex: 1;
  accent-color: #e91e63;
  /* не даём браузеру/Telegram превращать движение по ползунку в свайп страницы */
  touch-action: none;
  height: 34px;
  cursor: pointer;
}

#panel {
  /* вертикальные жесты внутри панели не должны сворачивать Mini App */
  touch-action: pan-x;
  overscroll-behavior: none;
}

/* ---------- Экран доступа (пейволл) ---------- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(120% 90% at 50% 0%, #2a1030 0%, #0d0b10 62%);
}

.gate-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.gate-logo { font-size: 54px; line-height: 1; margin-bottom: 10px; }

.gate-card h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.gate-lead, .gate-card p {
  font-size: 15px;
  line-height: 1.5;
  color: #cbc2d4;
  margin-bottom: 22px;
}

.gate-price {
  font-size: 46px;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(92deg, #ff7bb0, #e91e63 55%, #b46bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.gate-price span { -webkit-text-fill-color: initial; color: #ffd54f; }

.gate-term {
  font-size: 13px;
  color: #9c92a8;
  margin-bottom: 24px;
}

.gate-btn {
  display: block;
  width: 100%;
  padding: 15px 18px;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(92deg, #e91e63, #b02a8f);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(233, 30, 99, 0.32);
}
.gate-btn:active { transform: scale(0.985); }
.gate-btn:disabled { opacity: 0.55; box-shadow: none; }

.gate-note {
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.45;
  color: #9c92a8;
  min-height: 19px;
}

/* кнопка сохранения результата примерки (фото-режим) */
.save-photo {
  position: absolute;
  left: 50%;
  bottom: 74px;                 /* над кнопкой возврата к камере */
  transform: translateX(-50%);
  z-index: 25;
  padding: 12px 22px;
  border: none;
  border-radius: 24px;
  background: linear-gradient(92deg, #e91e63, #b02a8f);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(233, 30, 99, 0.35);
}
.save-photo:active { transform: translateX(-50%) scale(0.97); }
.save-photo:disabled { opacity: 0.65; box-shadow: none; }

/* уведомление о сборе кадров — показывается один раз на устройство */
.collect-notice {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 16px;
  z-index: 90;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(20, 16, 24, 0.92);
  color: #d9d2e0;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  opacity: 1;
  transition: opacity 0.8s ease;
}
.collect-notice.hide { opacity: 0; }
