@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700;800&display=swap');

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-standard: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --glass-bg: rgba(18, 20, 28, 0.45);
  --glass-border: rgba(255, 255, 255, 0.15);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  color-scheme: dark;
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
}

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

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
  overscroll-behavior: none;
  touch-action: none;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.app-shell {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 100%;
  overflow: hidden;
  background: #000;
  isolation: isolate;
}

.camera-video,
.overlay-canvas,
.camera-vignette,
.ui-root {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.camera-video {
  z-index: 1;
  object-fit: cover;
  background: #000;
}

.camera-video.is-selfie {
  transform: scaleX(-1);
}

.overlay-canvas {
  display: block;
  object-fit: cover;
  pointer-events: none;
}

.warp-layer {
  z-index: 2;
  opacity: 0;
  transition: opacity 180ms var(--ease-standard);
}

.warp-layer.is-active {
  opacity: 1;
}

.ar-layer {
  z-index: 3;
}

.camera-vignette {
  z-index: 4;
  pointer-events: none;
  background:
    radial-gradient(circle at center, rgba(0, 0, 0, 0) 38%, rgba(0, 0, 0, 0.18) 73%, rgba(0, 0, 0, 0.42) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0) 18%, rgba(0, 0, 0, 0) 74%, rgba(0, 0, 0, 0.26));
}

.ui-root {
  z-index: 10;
  pointer-events: none;
}

.ui-root button,
.ui-root a,
.ui-root [role="button"] {
  pointer-events: auto;
}

.loading-screen {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: calc(28px + var(--safe-top)) calc(24px + var(--safe-right)) calc(28px + var(--safe-bottom)) calc(24px + var(--safe-left));
  background:
    radial-gradient(circle at 50% -20%, rgba(120, 50, 255, 0.25), transparent 60%),
    radial-gradient(circle at -20% 120%, rgba(50, 200, 255, 0.2), transparent 50%),
    linear-gradient(135deg, #0a0510, #130a20 50%, #05020a);
  transition: opacity 400ms var(--ease-standard), visibility 400ms var(--ease-standard);
}

.loading-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.loading-card {
  width: min(330px, 88vw);
  display: grid;
  justify-items: center;
  gap: 18px;
  color: #fff;
  text-align: center;
}

.loading-logo {
  width: 100px;
  height: 100px;
  display: grid;
  place-items: center;
  border-radius: 32px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.05)),
    linear-gradient(135deg, #8b5cf6, #ec4899 44%, #f43f5e);
  box-shadow: 0 30px 80px rgba(236, 72, 153, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.4);
  font-size: 50px;
  animation: logoPulse 2s var(--ease-spring) infinite;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.loading-title {
  margin: 0;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
}

.loading-copy {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  line-height: 1.45;
}

.progress-track {
  width: 100%;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}

.progress-fill {
  width: 12%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f43f5e, #ec4899, #8b5cf6, #3b82f6);
  background-size: 200% 100%;
  animation: gradientPan 2s linear infinite;
  transition: width 350ms var(--ease-spring);
  box-shadow: 0 0 10px rgba(236, 72, 153, 0.6);
}

.top-bar {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: calc(12px + var(--safe-left));
  right: calc(12px + var(--safe-right));
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.top-bar-group {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.icon-button,
.install-action,
.preview-action {
  min-width: 46px;
  min-height: 46px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--glass-bg);
  color: #fff;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  transition: transform 250ms var(--ease-spring), background 250ms var(--ease-standard), box-shadow 250ms var(--ease-standard);
}

@media (hover: hover) {
  .icon-button:hover,
  .install-action:hover,
  .preview-action:hover {
    transform: scale(1.1);
    background: rgba(40, 44, 56, 0.6);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.3);
  }
}

.icon-button:active,
.install-action:active,
.preview-action:active {
  transform: scale(0.9);
}

.icon-button span {
  font-size: 22px;
  line-height: 1;
}

.quality-button span {
  min-width: 24px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

.quality-button.is-active {
  background: rgba(255, 255, 255, 0.92);
  color: #050505;
}

.no-face-guide {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  padding: calc(72px + var(--safe-top)) calc(24px + var(--safe-right)) calc(190px + var(--safe-bottom)) calc(24px + var(--safe-left));
  color: rgba(255, 255, 255, 0.84);
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 260ms var(--ease-standard), visibility 260ms var(--ease-standard);
}

.no-face-guide.is-visible {
  opacity: 1;
  visibility: visible;
}

.face-oval {
  position: relative;
  width: min(58vw, 290px);
  aspect-ratio: 0.72;
  display: grid;
  align-items: end;
  justify-items: center;
  padding-bottom: 24px;
  border: 2px solid rgba(255, 255, 255, 0.68);
  border-radius: 50% / 58%;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.08), 0 0 34px rgba(255, 255, 255, 0.16);
  animation: guideBreath 1.8s var(--ease-out) infinite;
}

.face-oval::after {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.guide-copy {
  width: max-content;
  max-width: min(76vw, 320px);
  margin: 0;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.44);
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  line-height: 1.35;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.bottom-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 16;
  display: grid;
  gap: 18px;
  padding: 0 0 calc(16px + var(--safe-bottom));
  pointer-events: none;
}

.filter-carousel {
  width: 100%;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 12px calc(16px + var(--safe-right)) 8px calc(16px + var(--safe-left));
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  pointer-events: auto;
  touch-action: pan-x;
}

.filter-carousel::-webkit-scrollbar {
  display: none;
}

.filter-button {
  flex: 0 0 auto;
  min-width: 96px;
  min-height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 20px;
  scroll-snap-align: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: rgba(255, 255, 255, 0.9);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: transform 300ms var(--ease-spring), background 300ms var(--ease-standard), color 300ms var(--ease-standard), box-shadow 300ms var(--ease-standard), border-color 300ms var(--ease-standard);
}

@media (hover: hover) {
  .filter-button:hover {
    transform: translateY(-4px) scale(1.02);
    background: rgba(40, 44, 56, 0.6);
    border-color: rgba(255, 255, 255, 0.4);
  }
}

.filter-button[aria-pressed="true"] {
  transform: translateY(-6px) scale(1.1);
  background: linear-gradient(135deg, #ffffff, #f0f0f0);
  color: #050505;
  border-color: transparent;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 255, 255, 0.4);
}

.filter-emoji {
  font-size: 22px;
  line-height: 1;
}

.filter-name {
  max-width: 112px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

.capture-row {
  position: relative;
  height: 78px;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.capture-button {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  transition: transform 200ms var(--ease-spring), box-shadow 200ms var(--ease-standard);
  pointer-events: auto;
  position: relative;
}

.capture-button::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #ec4899, #8b5cf6, #3b82f6, #10b981, #f59e0b, #ef4444, #ec4899);
  animation: rotateGradient 4s linear infinite;
  mask: radial-gradient(transparent 68%, black 70%);
  -webkit-mask: radial-gradient(transparent 68%, black 70%);
  opacity: 0.8;
  transition: opacity 300ms, transform 300ms var(--ease-spring);
}

.capture-button::after {
  content: "";
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.1);
  transition: width 300ms var(--ease-spring), height 300ms var(--ease-spring), border-radius 300ms var(--ease-spring), background 300ms var(--ease-standard);
}

@media (hover: hover) {
  .capture-button:hover::before {
    transform: scale(1.05);
    opacity: 1;
  }
}

.capture-button.is-pressed {
  transform: scale(0.9);
}

.capture-button.is-recording::before {
  background: #ef4444;
  mask: none;
  -webkit-mask: none;
  inset: -4px;
  animation: pulseRecordingRing 1.5s var(--ease-out) infinite;
}

.capture-button.is-recording::after {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #ef4444;
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.2);
}

.recording-hud {
  position: absolute;
  top: calc(68px + var(--safe-top));
  left: 50%;
  z-index: 17;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.56);
  color: #fff;
  font-variant-numeric: tabular-nums;
  transform: translateX(-50%);
  opacity: 0;
  visibility: hidden;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: opacity 180ms var(--ease-standard), visibility 180ms var(--ease-standard);
}

.recording-hud.is-visible {
  opacity: 1;
  visibility: visible;
}

.recording-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ef4444;
  animation: recordBlink 1s steps(2, end) infinite;
}

.flash-overlay {
  position: absolute;
  inset: 0;
  z-index: 24;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.flash-overlay.is-active {
  animation: shutterFlash 300ms var(--ease-out);
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(178px + var(--safe-bottom));
  z-index: 25;
  max-width: min(86vw, 380px);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(10, 12, 16, 0.66);
  color: #fff;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.3);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  transform: translate(-50%, 12px);
  opacity: 0;
  visibility: hidden;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: transform 240ms var(--ease-out), opacity 240ms var(--ease-standard), visibility 240ms var(--ease-standard);
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
  visibility: visible;
}

.install-banner {
  position: absolute;
  top: calc(64px + var(--safe-top));
  left: calc(12px + var(--safe-left));
  right: calc(12px + var(--safe-right));
  z-index: 26;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 10px 10px 14px;
  border-radius: 20px;
  background: rgba(10, 12, 16, 0.68);
  color: #fff;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: transform 240ms var(--ease-out), opacity 240ms var(--ease-standard), visibility 240ms var(--ease-standard);
}

.install-banner.is-visible {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

.install-copy {
  margin: 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 13px;
  line-height: 1.35;
}

.install-action {
  min-width: 74px;
  min-height: 38px;
  padding: 0 14px;
  background: #fff;
  color: #050505;
  font-weight: 800;
}

.gallery-overlay,
.preview-overlay {
  position: absolute;
  inset: 0;
  z-index: 28;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  padding: calc(14px + var(--safe-top)) calc(14px + var(--safe-right)) calc(14px + var(--safe-bottom)) calc(14px + var(--safe-left));
  background: rgba(0, 0, 0, 0.78);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: opacity 220ms var(--ease-standard), visibility 220ms var(--ease-standard);
}

.gallery-overlay.is-visible,
.preview-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.overlay-title {
  margin: 0;
  color: #fff;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.gallery-grid {
  align-content: start;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  overflow: auto;
  padding-bottom: 18px;
  touch-action: pan-y;
}

.gallery-empty {
  margin: 26vh auto 0;
  color: rgba(255, 255, 255, 0.68);
  text-align: center;
  font-size: 15px;
}

.gallery-item {
  position: relative;
  min-height: 168px;
  overflow: hidden;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
}

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

.gallery-kind {
  position: absolute;
  left: 8px;
  bottom: 8px;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.56);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.preview-body {
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 12px;
}

.preview-media {
  min-height: 0;
  display: grid;
  place-items: center;
}

.preview-media img,
.preview-media video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
}

.preview-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.preview-action {
  min-width: 96px;
  min-height: 44px;
  padding: 0 16px;
  font-weight: 800;
}

.error-panel {
  position: absolute;
  inset: 0;
  z-index: 31;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) calc(20px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(20px + var(--safe-left));
  background: #070707;
  color: #fff;
}

.error-card {
  width: min(420px, 92vw);
  display: grid;
  gap: 14px;
  text-align: center;
}

.error-card h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

.error-card p {
  margin: 0;
  color: rgba(255, 255, 255, 0.74);
  line-height: 1.5;
}

.primary-action {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  background: #fff;
  color: #050505;
  font-weight: 850;
}

@media (orientation: landscape) {
  .bottom-controls {
    left: auto;
    width: min(450px, 48vw);
  }

  .filter-carousel {
    padding-left: 12px;
  }

  .toast {
    bottom: calc(116px + var(--safe-bottom));
  }
}

@media (max-width: 390px) {
  .filter-button {
    min-width: 76px;
    padding-inline: 12px;
  }

  .filter-name {
    max-width: 70px;
    font-size: 12px;
  }
}

@keyframes logoPulse {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-4px) scale(1.04);
  }
}

@keyframes guideBreath {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.72;
  }
  50% {
    transform: scale(1.025);
    opacity: 1;
  }
}

@keyframes shutterFlash {
  0% {
    opacity: 0;
  }
  16% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
  }
}

@keyframes recordBlink {
  0%,
  44% {
    opacity: 1;
  }
  45%,
  100% {
    opacity: 0.28;
  }
}

@keyframes pulseRecordingRing {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 0; }
  100% { transform: scale(1); opacity: 0; }
}

@keyframes gradientPan {
  0% { background-position: 0% 50%; }
  100% { background-position: -200% 50%; }
}

@keyframes rotateGradient {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
