.home-panel[hidden],
.ar-panel[hidden] {
  display: none !important;
}

body.ar-mode {
  overflow: hidden;
  background: #eaf1f5;
}

body.ar-mode .app-viewport {
  padding:
    max(10px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
}

.ar-panel {
  width: min(100%, 700px);
  height: min(980px, calc(100svh - 20px));
  min-height: 560px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(190, 211, 225, 0.9);
  border-radius: clamp(22px, 3.8vw, 34px);
  background: #fff;
  box-shadow: var(--shadow);
}

.ar-header {
  min-height: 72px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  padding: 10px 16px 8px;
}

.ar-back-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0 0 5px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--interojo-blue-deep);
  font-size: 2.5rem;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.ar-back-button:hover {
  background: #edf5fa;
}

.ar-back-button:focus-visible {
  outline: 3px solid rgba(7, 88, 143, 0.2);
  outline-offset: 2px;
}

.ar-home-button {
  justify-self: center;
  width: min(55%, 220px);
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.ar-home-button:focus-visible {
  outline: 3px solid rgba(7, 88, 143, 0.2);
  outline-offset: 5px;
  border-radius: 8px;
}

.ar-brand-logo {
  display: block;
  width: 100%;
  height: auto;
}

.ar-stage {
  position: relative;
  min-height: 0;
  flex: 1 1 auto;
  margin: 0 16px;
  overflow: hidden;
  border-radius: 19px;
  background: #000;
}

#cameraVideo {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

#arCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
}

.ar-status {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: 50%;
  width: min(82%, 420px);
  padding: 14px 16px;
  color: #fff;
  font-size: clamp(0.9rem, 2.6vw, 1.12rem);
  font-weight: 750;
  line-height: 1.5;
  text-align: center;
  word-break: keep-all;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.75);
  transform: translate(-50%, -50%);
  transition: opacity 180ms ease;
}

.ar-status.ready {
  opacity: 0;
  pointer-events: none;
}

.ar-selected-name {
  position: absolute;
  z-index: 3;
  top: 14px;
  right: 14px;
  min-width: 52px;
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(7, 30, 47, 0.58);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  backdrop-filter: blur(8px);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.camera-shot {
  position: absolute;
  left: 18px;
  bottom: 20px;
  z-index: 4;
  width: 50px;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.camera-shot img {
  width: 42px;
  height: 34px;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55));
}

.camera-shot span {
  font-size: 0.66rem;
  font-weight: 850;
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
}

.camera-shot:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.72);
  outline-offset: 3px;
  border-radius: 12px;
}

.camera-shot:active {
  transform: scale(0.96);
}

.intensity-control {
  position: absolute;
  left: 78px;
  right: 22px;
  bottom: 34px;
  z-index: 4;
  display: flex;
  align-items: center;
}

.intensity-control input {
  width: 100%;
  height: 20px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  --slider-value: 85%;
  --track-fill: #fff;
  --track-rest: rgba(255, 255, 255, 0.42);
  --track-height: 4px;
  --thumb-size: 20px;
}

.intensity-control input::-webkit-slider-runnable-track {
  height: var(--track-height);
  border-radius: 999px;
  background: linear-gradient(to right, var(--track-fill) 0 var(--slider-value), var(--track-rest) var(--slider-value) 100%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.42);
}

.intensity-control input::-webkit-slider-thumb {
  width: var(--thumb-size);
  height: var(--thumb-size);
  margin-top: calc((var(--track-height) - var(--thumb-size)) / 2);
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  -webkit-appearance: none;
}

.intensity-control input::-moz-range-track {
  height: var(--track-height);
  border: 0;
  border-radius: 999px;
  background: var(--track-rest);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.42);
}

.intensity-control input::-moz-range-progress {
  height: var(--track-height);
  border-radius: 999px;
  background: var(--track-fill);
}

.intensity-control input::-moz-range-thumb {
  width: var(--thumb-size);
  height: var(--thumb-size);
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.capture-feedback {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: #fff;
  animation: captureFlash 420ms ease-out both;
}

.capture-feedback[hidden],
.capture-review[hidden] {
  display: none;
}

.capture-feedback span {
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.58);
  font-size: 0.95rem;
  font-weight: 850;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  animation: captureMessage 760ms ease-out both;
}

.capture-review {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 12px;
  padding: 12px;
  background: rgba(12, 17, 24, 0.82);
}

.capture-review-frame {
  min-height: 0;
  overflow: hidden;
  border-radius: 14px;
  background: #000;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.38);
}

.capture-review-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.capture-review-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
}

.capture-review-location {
  margin: 0;
  color: #fff;
  font-size: clamp(0.72rem, 2.2vw, 0.9rem);
  font-weight: 750;
  line-height: 1.4;
  text-align: center;
  text-wrap: balance;
}

.capture-review-button {
  min-width: 96px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 850;
  cursor: pointer;
}

.capture-review-button.secondary {
  color: #11283b;
  background: rgba(255, 255, 255, 0.94);
}

.capture-review-button.primary {
  color: #fff;
  background: var(--interojo-blue);
}

@keyframes captureFlash {
  0% { background: rgba(255, 255, 255, 0.72); }
  100% { background: rgba(255, 255, 255, 0); }
}

@keyframes captureMessage {
  0% { opacity: 0; transform: translateY(8px) scale(0.96); }
  18% { opacity: 1; transform: translateY(0) scale(1); }
  76% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-5px) scale(0.98); }
}

.lens-dock {
  flex: 0 0 auto;
  padding: 14px 16px max(14px, env(safe-area-inset-bottom));
  background: #fff;
}

.lens-strip {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 1px 8px;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: #9aa7af #eef2f4;
  -webkit-overflow-scrolling: touch;
}

.lens-strip::-webkit-scrollbar {
  height: 6px;
}

.lens-strip::-webkit-scrollbar-track {
  border-radius: 999px;
  background: #eef2f4;
}

.lens-strip::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #9aa7af;
}

.lens-tile {
  width: 82px;
  flex: 0 0 82px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 5px 5px 7px;
  overflow: hidden;
  border: 1px solid #d6e2ea;
  border-radius: 13px;
  background: #fff;
  color: #233b4d;
  cursor: pointer;
  scroll-snap-align: center;
  -webkit-tap-highlight-color: transparent;
}

.lens-tile:hover {
  border-color: rgba(7, 88, 143, 0.55);
}

.lens-tile:focus-visible {
  outline: 3px solid rgba(7, 88, 143, 0.2);
  outline-offset: 2px;
}

.lens-tile.active {
  border-color: var(--interojo-blue);
  box-shadow: 0 0 0 2px rgba(7, 88, 143, 0.13);
}

.lens-tile img {
  width: 70px;
  height: 70px;
  display: block;
  object-fit: contain;
  border-radius: 9px;
  background: #fff;
}

.lens-tile span {
  overflow: hidden;
  font-size: 0.69rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 700px) {
  .ar-header {
    min-height: 82px;
    padding-inline: 22px;
  }

  .ar-stage {
    margin-inline: 22px;
    border-radius: 23px;
  }

  .lens-dock {
    padding: 16px 22px max(18px, env(safe-area-inset-bottom));
  }

  .lens-tile {
    width: 92px;
    flex-basis: 92px;
  }

  .lens-tile img {
    width: 80px;
    height: 80px;
  }
}

@media (max-width: 520px) {
  body.ar-mode .app-viewport {
    padding: 0;
  }

  .ar-panel {
    width: 100%;
    height: 100svh;
    min-height: 520px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .ar-header {
    min-height: 62px;
    padding: max(5px, env(safe-area-inset-top)) 10px 5px;
  }

  .ar-home-button {
    width: min(52%, 190px);
  }

  .ar-stage {
    margin: 0 10px;
    border-radius: 14px;
  }

  .camera-shot {
    left: 12px;
    bottom: 14px;
  }

  .intensity-control {
    left: 70px;
    right: 16px;
    bottom: 29px;
  }

  .lens-dock {
    padding: 11px 10px max(10px, env(safe-area-inset-bottom));
  }

  .lens-tile {
    width: 76px;
    flex-basis: 76px;
    padding-inline: 4px;
    border-radius: 11px;
  }

  .lens-tile img {
    width: 66px;
    height: 66px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ar-status,
  .lens-strip {
    scroll-behavior: auto;
    transition: none;
  }
}
