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

body {
  background: #000;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

#ar-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* MindAR рендерит вложенный div + canvas + video — наши div-ы исключаем */
#ar-container > div:not(#loading),
#ar-container canvas,
#ar-container video {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}

#loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  color: #fff;
  font-family: sans-serif;
  font-size: 16px;
  gap: 16px;
  z-index: 10;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#no-targets-msg {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-family: sans-serif;
  font-size: 15px;
  padding: 10px 20px;
  border-radius: 20px;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#no-targets-msg.visible { opacity: 1; }

/* Баннер установки PWA */
#install-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-family: sans-serif;
  font-size: 14px;
  padding: 10px 14px;
  border-radius: 24px;
  z-index: 20;
  white-space: nowrap;
  backdrop-filter: blur(4px);
}

#install-btn {
  background: #fff;
  color: #000;
  border: none;
  border-radius: 14px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

#install-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

/* Модальное окно */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal.hidden { display: none; }

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}

.modal-content {
  position: relative;
  background: #fff;
  width: 100%;
  max-width: 640px;
  max-height: 50vh;
  border-radius: 20px 20px 0 0;
  padding: 20px 16px 28px;
  overflow-y: auto;
  overflow-x: hidden;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: #f0f0f0;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
}

#modal-body {
  margin-top: 8px;
  font-family: sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #222;
  overflow-wrap: break-word;
  word-break: break-word;
}

#modal-body img  { max-width: 100%; height: auto; border-radius: 8px; margin: 6px 0; }
#modal-body video { max-width: 100%; height: auto; border-radius: 8px; margin: 6px 0; }
#modal-body h1, #modal-body h2, #modal-body h3 { margin: 10px 0 4px; }
#modal-body p { margin-bottom: 6px; }

/* Превьюшка привязанная к таргету (создаётся динамически) */
.ar-target-preview {
  position: fixed;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.85);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  transform: translate(-50%, -50%);
  z-index: 45;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.1s ease;
}

.ar-target-preview.fading { opacity: 0; }

.ar-target-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Стек превью-баров */
#preview-stack {
  position: fixed;
  bottom: 20px;
  left: 16px;
  right: 88px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

/* Превью карточки (создаётся динамически) */
.card-preview {
  background: rgba(0,0,0,0.78);
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  animation: slideUp 0.25s ease;
  backdrop-filter: blur(4px);
  cursor: pointer;
  pointer-events: all;
  -webkit-tap-highlight-color: transparent;
  opacity: 1;
  transition: opacity 0.1s ease;
}

.card-preview.fading { opacity: 0; }

.card-preview img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #333;
}

.card-preview .preview-title {
  flex: 1;
  min-width: 0;
  color: #fff;
  font-family: sans-serif;
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#cam-switch-btn {
  position: fixed;
  bottom: 32px;
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.55);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
}

#cam-switch-btn:active { background: rgba(0,0,0,0.85); }
