*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000 !important;
}

.page {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  margin: 0;
}

.stage {
  position: absolute;
  inset: 0;
  background: #000;
  overflow: hidden;
}

.video-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #000;
  touch-action: none;
}

.stage video {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: auto;
  max-width: none;
  max-height: none;
  object-fit: fill;
  display: block;
  opacity: 0;
  transition: opacity 0.35s ease;
  will-change: transform, opacity;
  transform: translate(-50%, -50%);
  transform-origin: center center;
}

.stage video.is-ready {
  opacity: 1;
}

.btn-switch {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 4;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.btn-switch:active {
  transform: scale(0.94);
}

.btn-today {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  z-index: 4;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.btn-today:active {
  transform: scale(0.94);
}

.today-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #0b0f17;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.today-panel.hidden {
  display: none !important;
}

.today-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.95);
}

.today-back,
.today-refresh {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 10px;
  cursor: pointer;
  flex-shrink: 0;
}

.today-back {
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 600;
}

.today-refresh {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.today-head-text {
  flex: 1;
  min-width: 0;
}

.today-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.today-sub {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: #94a3b8;
}

.today-status {
  margin: 0;
  padding: 12px 16px;
  font-size: 0.9rem;
  color: #94a3b8;
}

.today-status.hidden {
  display: none;
}

.today-grid {
  flex: 1;
  overflow: auto;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
}

.today-grid.empty::after {
  content: "No photos yet today";
  grid-column: 1 / -1;
  text-align: center;
  color: #64748b;
  padding: 48px 16px;
  font-size: 0.95rem;
}

.today-thumb {
  appearance: none;
  border: none;
  padding: 0;
  margin: 0;
  background: #111827;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1;
  cursor: pointer;
}

.today-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.today-viewer {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}

.today-viewer.hidden {
  display: none !important;
}

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

.today-viewer-close {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: 12px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

.camera-iframe-hint {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  text-align: center;
  font-size: 0.8rem;
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.92);
}

.camera-iframe-hint a {
  color: #93c5fd;
  font-weight: 600;
}

.flash {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.12s ease-out;
}

.flash.active {
  opacity: 1;
}

.flash.ok {
  background: rgba(255, 255, 255, 0.55);
}

.flash.err {
  background: rgba(220, 38, 38, 0.35);
}

.actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 4;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  pointer-events: none;
}

.actions-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.zoom-label {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.94);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.65);
  font-variant-numeric: tabular-nums;
  min-width: 3.25rem;
  text-align: center;
}

.actions .btn-capture {
  pointer-events: auto;
}

.btn-capture {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.92);
  background: transparent;
  padding: 0;
  cursor: pointer;
  position: relative;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}

.btn-capture:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-capture .ring {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.1s ease;
}

.btn-capture:active:not(:disabled) .ring {
  transform: scale(0.92);
}

.btn-capture.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

.hidden {
  display: none !important;
}
