/* Aggressively Minimalist, Ultra-Smooth & Reactive Dental Vision UI */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #000000;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #ffffff;
}

#cameraContainer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  z-index: 1;
}

#cameraVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#overlayCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

/* Glassmorphism Elements */
.glass {
  background: rgba(14, 14, 18, 0.4);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
}

/* Ultra Minimal HUD */
#hudOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 16px) env(safe-area-inset-right, 16px) env(safe-area-inset-bottom, 20px) env(safe-area-inset-left, 16px);
}

.hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
}

.hud-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s ease;
}

.hud-btn:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.2);
}

.hud-counter {
  padding: 6px 16px;
  border-radius: 30px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
  color: #00f2fe;
}

.hud-counter .denom {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  margin-left: 2px;
}

.hud-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  width: 100%;
  padding: 8px 12px;
}

/* Small Bottom Thumbnail with Set & Shots info */
.glass-thumb {
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(14, 14, 18, 0.55);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 5px 14px 5px 5px;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-thumb:active {
  transform: scale(0.95);
}

.thumb-preview {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  overflow: hidden;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

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

.thumb-info {
  display: flex;
  flex-direction: column;
}

.thumb-info #thumbSetNum {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
}

.thumb-info #thumbShotsCount {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.2px;
}

/* Screen Shutter Flash Effect */
#shutterFlash {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle, rgba(255,255,255,0.9) 0%, rgba(0,242,254,0.3) 60%, rgba(0,0,0,0) 100%);
  pointer-events: none;
  opacity: 0;
  z-index: 50;
  transition: opacity 0.04s ease-out;
}

#shutterFlash.active {
  opacity: 1;
  transition: none;
}

/* Modals & Drawers */
.modal-backdrop, .drawer-backdrop, .viewer-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-card {
  width: 90%;
  max-width: 380px;
  padding: 30px 22px;
  border-radius: 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.glass-modal {
  background: rgba(22, 22, 28, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.65);
}

.modal-card h2 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.modal-card p {
  font-size: 13.5px;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.45;
}

.guidance-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  text-align: left;
  margin: 6px 0;
}

.guide-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
}

.guide-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #00f2fe;
  flex-shrink: 0;
  box-shadow: 0 0 8px #00f2fe;
}

.primary-btn {
  width: 100%;
  padding: 14px 24px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
  color: #000;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(0, 242, 254, 0.38);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.primary-btn:active {
  transform: scale(0.97);
  filter: brightness(1.1);
}

.perm-error {
  font-size: 12px;
  color: #ff5252;
  margin-top: 4px;
}

/* Media Gallery Slide-Up Drawer */
.drawer-backdrop {
  align-items: flex-end;
}

.glass-drawer {
  width: 100%;
  max-height: 85vh;
  border-radius: 28px 28px 0 0;
  background: rgba(16, 16, 22, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom, 16px));
  gap: 16px;
  transform: translateY(0);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
}

.drawer-backdrop.hidden .glass-drawer {
  transform: translateY(100%);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.drawer-title-box h3 {
  font-size: 18px;
  font-weight: 700;
}

.meta-tag {
  font-size: 12px;
  color: #00f2fe;
  font-weight: 500;
}

.drawer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 12px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgba(0, 242, 254, 0.3);
}

.action-btn:active {
  background: rgba(0, 242, 254, 0.2);
}

.close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Set Pills Bar */
.set-pills-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 8px;
  scrollbar-width: none;
}

.set-pills-bar::-webkit-scrollbar {
  display: none;
}

.set-pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

.set-pill.active {
  background: rgba(0, 242, 254, 0.18);
  border-color: #00f2fe;
  color: #00f2fe;
}

/* 9-Angle 3x3 Grid */
.angles-grid-9 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 8px 0 20px;
}

.angle-slot {
  aspect-ratio: 1.1;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease;
}

.angle-slot:active {
  transform: scale(0.96);
}

.angle-slot.captured {
  border: 1.5px solid rgba(0, 242, 254, 0.7);
  background: #000;
}

.angle-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.angle-slot .slot-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 2px;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  background: rgba(0, 0, 0, 0.78);
  color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
}

.angle-slot .empty-icon {
  color: rgba(255, 255, 255, 0.2);
  margin-bottom: 4px;
}

.angle-slot .empty-text {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.45);
  text-align: center;
  padding: 0 4px;
}

/* Fullscreen Photo Viewer */
.viewer-modal {
  flex-direction: column;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 20px) 16px env(safe-area-inset-bottom, 20px);
}

.viewer-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 4px;
}

#viewerAngleTitle {
  font-size: 17px;
  font-weight: 600;
  color: #fff;
}

.viewer-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  overflow: hidden;
}

#viewerImage {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8);
}

.viewer-bottom {
  padding: 12px;
  text-align: center;
}

#viewerPoseDetails {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  font-variant-numeric: tabular-nums;
}
