/* ============================================
   ПОДКЛЮЧЕНИЕ ШРИФТА Liu Jian Mao Cao
   ============================================ */
@font-face {
  font-family: 'LiuJianMaoCao';
  src: url('Fonts/LiuJianMaoCao-Regular.ttf') format('truetype'); 
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ============================================
   БАЗОВЫЕ СТИЛИ
   ============================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
  font-family: 'Roboto', sans-serif; 
  background: #ffffff;
  overflow: hidden;
}

/* ============================================
   ГЛАВНЫЙ КОНТЕЙНЕР
   ============================================ */
.app-container {
  width: 100%;
  max-width: 420px;
  height: 100vh;
  height: 100dvh;
  max-height: 950px;
  margin: 0 auto;
  position: relative;
  background: #ffffff;
  overflow: hidden;
}

/* Десктоп */
@media (min-width: 768px) {
  body { background: #FFFFFF; display: flex; justify-content: center; align-items: center; min-height: 100vh; }
  .app-container {
    height: 90vh;
    max-height: 850px;
    border-radius: 30px;
    background: #FFFFFF;
    box-shadow: none;
  }
}

/* Адаптив для маленьких экранов */
@media (max-height: 700px) {
  .app-container { max-height: 100dvh; }
  .start-image { width: 220px; }
  .btn-outline { width: 240px; height: 44px; font-size: 15px; }
  
  #screen-settings { 
    padding: 20px 16px; 
  }
  .frame-container { height: 280px; min-height: 240px; }
  .frame-image { max-height: 270px; }
  
  .label { font-size: 11px; margin-bottom: 10px; }
  .color-scroll { padding: 4px 16px 8px 12px; margin-bottom: 24px; }
  .color-opt { width: 64px; height: 64px; }
  .color-opt.active { transform: scale(1.08); }
  
  .btn-primary-black { height: 48px; font-size: 15px; }
  
  #screen-camera { padding: 12px 16px 16px; }
  .camera-container { margin-bottom: 10px; }
  .toggle-track { width: 250px; height: 38px; }
  .toggle-btn { height: 30px; font-size: 14px; }
  .btn-capture-circle { width: 90px; height: 90px; border-width: 8px; }
  #screen-result { padding: 20px 16px 20px; }
  .result-area { height: 38vh; margin-bottom: 160px; }
  .photo-wrapper { width: 90px; }
  .photo-wrapper.quadrate { width: 170px; }
  .result-actions { margin-top: 32px; }
}

@media (min-height: 701px) and (max-height: 850px) {
  .app-container { max-height: 100dvh; }
  .start-image { width: 260px; }
  .btn-outline { width: 250px; height: 46px; }
  #screen-settings { padding: 24px 18px; }
  .frame-container { height: 300px; min-height: 260px; }
  .frame-image { max-height: 290px; }
  .color-opt { width: 76px; height: 76px; }
  .btn-primary-black { height: 50px; }
  #screen-camera { padding: 16px 18px 24px; }
  .camera-container { }
  .btn-capture-circle { width: 100px; height: 100px; border-width: 8px; }
  #screen-result { padding: 28px 18px 24px; }
  .result-area { height: 40vh; margin-bottom: 180px; }
  .photo-wrapper { width: 100px; }
  .photo-wrapper.quadrate { width: 200px; }
  .result-actions { margin-top: 36px; }
}

@media (min-height: 851px) {
  .app-container { max-height: 950px; }
}

/* ============================================
   ОБЩИЕ СТИЛИ ЭКРАНОВ
   ============================================ */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 24px;
  background: #ffffff;
  overflow: hidden;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
  z-index: 10;
}
.screen.bg-white { background: #FFFFFF; }

/* ============================================
   ЭКРАН 1
   ============================================ */
#screen-start {
  justify-content: center;
  background: #ffffff;
  z-index: 20;
}
.start-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}
.start-image { width: 340px; display: block; }

/* Стиль кнопки как на скриншоте */
.btn-outline {
  width: 290px;
  height: 48px;
  background: linear-gradient(180deg, #F4F4F4 0%, #FFFFFF 100%);
  color: #393939;
  border: 2px solid #FFFFFF;
  font-size: 16px;
  border-radius: 50px;
  cursor: pointer;
  font-family: 'Roboto', sans-serif;
  font-weight: 500;
  z-index: 30;
  position: relative;
  box-shadow: 
    0 7px 8px rgba(31, 31, 31, 0.046),
    0 0 2px rgba(231, 231, 231, 0.57);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-outline:hover {
  transform: translateY(-1px);
  box-shadow: 
    0 8px 6px rgba(0, 0, 0, 0.15),
    0 0 2px rgba(231, 231, 231, 1);
}

.btn-outline:active {
  transform: translateY(0);
}

/* ============================================
   ЭКРАН 2
   ============================================ */
#screen-settings {
  background: #FFFFFF;
  justify-content: flex-start;
  padding: 32px 20px 20px;
  z-index: 15;
  overflow: hidden;
}
.frame-switcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  flex-shrink: 0;
}
.arrow-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
  opacity: 0.5;
  transition: opacity 0.2s;
}
.arrow-btn:hover { opacity: 1; }
.arrow-btn img { width: 24px; height: 24px; display: block; }
.frame-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 320px;
  min-height: 280px;
}
.frame-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: opacity 0.3s ease;
  border: none;
}

/* КНОПКА И ВАРИАНТЫ ПРИЖАТЫ К НИЗУ */
.bottom-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  margin-top: auto;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  flex-shrink: 0;
}

.color-section { width: 100%; padding: 0; }
.label { 
  display: block; 
  color: #818286; 
  font-size: 12px; 
  letter-spacing: 0.5px; 
  margin-bottom: 12px;
  text-align: left; 
}

.color-scroll { 
  display: flex; 
  gap: 8px; 
  overflow-x: auto; 
  padding: 8px 16px 8px 12px; 
  margin: 0 -4px; 
  scrollbar-width: none; 
  margin-bottom: 32px;
}
.color-scroll::-webkit-scrollbar { display: none; }
.color-opt { 
  width: 89px;
  height: 89px;
  border-radius: 18px; 
  border: 3px solid transparent; 
  cursor: pointer; 
  flex-shrink: 0; 
  transition: all 0.3s ease; 
  padding: 0;
  background: none; 
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.color-opt img { 
  width: 100%;
  height: 100%;
  object-fit: cover; 
  border-radius: 15px; 
}
.color-opt.active { 
  transform: scale(1.12);
  border-color: #BABBBC; 
  border-radius: 22px;
}

/* ============================================
   ОБНОВЛЁННЫЙ СТИЛЬ КНОПОК (КАК "НАЧАТЬ")
   ============================================ */
.btn-primary-black {
  width: 100%;
  max-width: 420px;
  height: 52px;
  background: linear-gradient(180deg, #F4F4F4 0%, #FFFFFF 100%);
  color: #393939;
  border: 2px solid #FFFFFF;
  border-radius: 50px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  font-family: 'Roboto', sans-serif;
  align-self: center;
  margin: 0;
  flex-shrink: 0;
  box-shadow: 
    0 7px 8px rgba(31, 31, 31, 0.046),
    0 0 2px rgba(231, 231, 231, 0.57);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary-black:hover {
  transform: translateY(-1px);
  box-shadow: 
    0 8px 6px rgba(0, 0, 0, 0.15),
    0 0 2px rgba(231, 231, 231, 1);
}

.btn-primary-black:active {
  transform: translateY(0);
}

/* ============================================
   ЭКРАН 3: КАМЕРА
   ============================================ */
#screen-camera {
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 42px 24px;
  gap: 0;
  z-index: 15;
}
.camera-container {
  width: 100%;
  aspect-ratio: 3/4;
  background: #EBECED;
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  margin: 0 auto 12px;
  flex-shrink: 0;
  border: 2px solid #D7DAE1;
}
#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
.camera-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.camera-overlay.active { opacity: 1; }
.camera-overlay.flash {
  animation: smoothFlash 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes smoothFlash {
  0% { opacity: 0; background: rgba(255, 255, 255, 0); }
  20% { opacity: 1; background: rgba(255, 255, 255, 0.92); }
  100% { opacity: 0; background: rgba(255, 255, 255, 0); }
}
.overlay-text {
  font-size: 72px;
  font-weight: 700;
  color: #FFFFFF;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}
.toggle-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-bottom: 12px;
}
.toggle-track {
  width: 220px; /* Уменьшено с 290px */
  height: 38px; /* Чуть меньше */
  background: #EBECED;
  border-radius: 30px;
  display: flex;
  position: relative;
  overflow: hidden;
  padding: 3px;
}
.toggle-slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: 32px;
  background: #FFFFFF;
  border-radius: 30px;
  z-index: 1;
  box-shadow: 0 2px 4px rgba(117, 118, 124, 0.25), 0 0 4.5px rgba(171, 176, 190, 0.25);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.toggle-track.bw-active .toggle-slider { transform: translateX(100%); }
.toggle-btn {
  width: 50%;
  height: 32px;
  border: none;
  background: transparent;
  font-family: 'Roboto', sans-serif;
  font-size: 14px; /* Уменьшен шрифт */
  font-weight: 500;
  cursor: pointer;
  transition: color 0.3s ease;
  z-index: 2;
  text-align: center;
  padding: 0;
  line-height: 32px;
}
.toggle-btn.active { color: #111010; font-weight: 500; }
.toggle-btn.inactive { color: #71747C; }

/* Ползунки */
.camera-controls {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 0 12px;
  margin: 0 auto;
}

.control-item {
  display: flex;
  flex-direction: column;
  gap: 8px; /* Увеличено с 4px */
  margin-bottom: 6px; /* Добавлен отступ снизу */
}

.control-label {
  font-size: 12px;
  color: #818286;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
  margin-left: 2px; /* Небольшой отступ слева */
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  background: #EBECED;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  border: 1px solid #D7DAE1;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  background: #111010;
  border-radius: 50%;
  border: 3px solid #FFFFFF;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: transform 0.2s ease;
  margin-top: -1px;
}

input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(1.1);
}

.camera-bottom-section {
  width: 100%;
  display: flex;
  justify-content: center;
  padding-top: 8px;
  padding-bottom: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.btn-capture-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #111010;
  border: 8px solid #e3e3e4;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}
.btn-capture-circle:active { transform: scale(0.94); box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.btn-capture-circle:disabled { opacity: 0.6; cursor: not-allowed; }

/* ============================================
   ЭКРАН 4: РЕЗУЛЬТАТ
   ============================================ */
#screen-result {
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 40px 20px 30px;
  gap: 0;
  z-index: 15;
}
.result-area {
  position: relative;
  width: 100%;
  max-width: 320px;
  height: 45vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  margin-bottom: 240px;
}
.photo-wrapper {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) translateY(-100%);
  width: 110px;
  z-index: 2;
  opacity: 0;
}
.photo-wrapper.quadrate { width: 240px; }
.photo-wrapper.animate {
  opacity: 1;
  animation: slideDown 2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
@keyframes slideDown {
  0% { transform: translateX(-50%) translateY(-100%); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translateX(-50%) translateY(20px); opacity: 1; }
}
#result-image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.1);
}
.result-actions {
  width: 100%;
  max-width: 100%;
  margin-top: 40px;
  padding-bottom: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.btn-text {
  background: none;
  border: none;
  color: #A0A0A0;
  font-size: 14px;
  cursor: pointer;
  font-family: 'Roboto', sans-serif;
  padding: 8px;
}
.btn-text:hover { color: #111010; }