.modal {
  position: fixed; inset: 0;
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .2s var(--ease);
}

.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(5px);
}

.modal-card {
  position: relative;
  background: var(--sidebar);
  border-radius: var(--r-lg);
  overflow: hidden;
  width: min(460px, 92vw);
  box-shadow: var(--shadow-md);
  animation: cardIn .22s var(--ease);
}

@keyframes cardIn {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: scale(1); }
}

.modal-close {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 10;
  background: rgba(0,0,0,.38) !important;
  color: #fff !important;
  border-radius: 50% !important;
}

#cam-stream {
  width: 100%;
  flex: 1;
  min-height: 0;
  object-fit: contain;
  display: block;
  background: #000;
}

#cam-canvas { display: none; }

#camera-modal .modal-card {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  border-radius: 0;
  background: #000;
}

#camera-modal .cam-controls {
  background: #000;
  padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
}

#camera-modal .modal-close {
  top: calc(10px + env(safe-area-inset-top, 0px));
}

#camera-modal .rec-timer {
  top: calc(14px + env(safe-area-inset-top, 0px));
}

@media (min-width: 769px) {
  #camera-modal .modal-card {
    width: min(960px, 94vw);
    height: min(88dvh, 720px);
    border-radius: var(--r-lg);
  }
}

.prev-item img,
.bubble-attachment img { cursor: zoom-in; }

.image-viewer {
  position: fixed; inset: 0;
  z-index: 600;
  display: flex; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
  background: rgba(0,0,0,.92);
  animation: fadeIn .2s var(--ease);
}

.image-viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.image-viewer-close {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: 10px;
  background: rgba(255,255,255,.14) !important;
  color: #fff !important;
  border-radius: 50% !important;
}

.cam-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  padding: 18px;
}

.capture-btn {
  width: 62px; height: 62px;
  border-radius: 50%;
  background: var(--iris);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 18px var(--iris-glow);
  transition: transform .14s, background var(--t);
}

.capture-btn:hover  { transform: scale(1.07); }
.capture-btn:active { transform: scale(.95); }
.capture-btn .material-symbols-outlined { font-size: 28px; }

.record-btn {
  width: 62px; height: 62px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: transform .14s, background var(--t);
}

.record-btn:hover  { transform: scale(1.07); }
.record-btn:active { transform: scale(.95); }
.record-btn .material-symbols-outlined { font-size: 28px; }

.record-btn.grabando { animation: recPulse 1.3s ease infinite; }

@keyframes recPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192,57,43,.45); }
  55%      { box-shadow: 0 0 0 12px transparent; }
}

.rec-timer {
  position: absolute;
  top: 12px; left: 14px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.rec-timer::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: blink .75s ease infinite;
}
