/* ==========================================================================
   HMIF Photobooth - Individual Screen Layouts
   ========================================================================== */

/* --------------------------------------------------------------------------
   SCREEN 1: WELCOME SCREEN
   -------------------------------------------------------------------------- */
#screen-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 48px 36px;
  background: radial-gradient(circle at 50% 30%, #FAFAFA 0%, #FFFFFF 70%);
  text-align: center;
}

.welcome-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.welcome-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 680px;
  margin: auto 0;
  gap: 24px;
}

.welcome-title {
  font-size: clamp(42px, 6vw, 76px);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text-primary);
  line-height: 1.05;
}

.welcome-subtitle {
  font-size: clamp(16px, 2vw, 20px);
  color: var(--text-secondary);
  font-weight: 400;
  max-width: 480px;
}

/* Mode Selection Pills */
.mode-selector {
  display: flex;
  align-items: center;
  background: var(--surface-color);
  padding: 5px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  gap: 4px;
  margin-top: 10px;
}

.mode-pill {
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mode-pill.active {
  background: #FFFFFF;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.welcome-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.welcome-meta {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   SCREEN 2 & 3: CAMERA & CAPTURE SESSION
   -------------------------------------------------------------------------- */
#screen-camera {
  background-color: #0D0D0D;
  color: #FFFFFF;
}

#screen-camera .top-nav {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
}

#screen-camera .top-nav .nav-title {
  color: #FFFFFF;
}

.camera-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
}

.viewfinder-wrapper {
  position: relative;
  max-width: 900px;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: calc(100vh - 220px);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000000;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Default mirror effect */
}

#camera-video.unmirrored {
  transform: scaleX(1);
}

/* Viewfinder Framing Guidelines */
.viewfinder-guide {
  position: absolute;
  inset: 24px;
  pointer-events: none;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-md);
}

/* Big Countdown Overlay */
.countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 150ms ease;
  z-index: 20;
}

.countdown-overlay.active {
  opacity: 1;
  visibility: visible;
}

.countdown-number {
  font-size: clamp(100px, 20vw, 190px);
  font-weight: 800;
  color: #FFFFFF;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  transform: scale(0.8);
  animation: countdownPulse 1s ease infinite;
}

/* Camera Loading Overlay */
.camera-loading-overlay {
  position: absolute;
  inset: 0;
  background: #000000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 15;
  transition: opacity 200ms ease;
}

.camera-loading-overlay.hidden {
  display: none;
}

.camera-spinner {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.camera-loading-text {
  font-size: 14px;
  color: #CCCCCC;
  letter-spacing: 0.05em;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Camera Error Overlay */
.camera-error-overlay {
  position: absolute;
  inset: 0;
  background: #111111;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  gap: 16px;
  z-index: 30;
}

.camera-error-overlay.hidden {
  display: none;
}

.camera-error-title {
  font-size: 22px;
  font-weight: 600;
  color: #FFFFFF;
}

.camera-error-desc {
  font-size: 15px;
  color: #A0A0A0;
  max-width: 400px;
}

/* Bottom Capture Control Bar */
.camera-controls {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 48px;
  background: #0D0D0D;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.camera-control-slot {
  flex: 1;
  display: flex;
  align-items: center;
}

.camera-control-slot.center {
  justify-content: center;
}

.camera-control-slot.right {
  justify-content: flex-end;
}

/* Shutter Trigger Button */
.shutter-btn {
  width: 76px;
  height: 76px;
  border-radius: var(--radius-full);
  background: #FFFFFF;
  border: 4px solid #333333;
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

.shutter-btn:active {
  transform: scale(0.92);
  border-color: #555555;
}

.shutter-btn-inner {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-full);
  background: #FFFFFF;
  transition: background 150ms ease;
}

.shutter-btn:hover .shutter-btn-inner {
  background: #EAEAEA;
}

.shot-counter-pill {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #CCCCCC;
  background: rgba(255, 255, 255, 0.08);
  padding: 8px 18px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* --------------------------------------------------------------------------
   SCREEN 4: REVIEW & RETAKE
   -------------------------------------------------------------------------- */
#screen-review {
  display: flex;
  flex-direction: column;
  background: var(--surface-color);
}

.review-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px;
  gap: 28px;
  overflow-y: auto;
}

.review-header-text {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.review-reel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  max-width: 1100px;
  width: 100%;
}

.review-card {
  position: relative;
  width: 220px;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000000;
  box-shadow: var(--shadow-md);
  border: 2px solid transparent;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  cursor: pointer;
}

.review-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-color);
}

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

.review-card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  backdrop-filter: blur(4px);
}

.review-card-action {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.review-card:hover .review-card-action {
  opacity: 1;
}

.review-card-btn {
  background: #FFFFFF;
  color: #111111;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.review-bottom-bar {
  height: 90px;
  background: var(--bg-color);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 48px;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   SCREEN 5, 6 & 7: STUDIO & RESULT CUSTOMIZATION
   -------------------------------------------------------------------------- */
#screen-studio {
  display: flex;
  flex-direction: column;
  background: var(--surface-color);
}

.studio-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Left: Print Preview Stage */
.studio-stage {
  flex: 1.1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  position: relative;
  background: radial-gradient(circle at center, #F5F5F5 0%, #EAEAEA 100%);
  overflow: hidden;
}

.canvas-container {
  max-height: 100%;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#preview-canvas {
  max-height: calc(100vh - 180px);
  max-width: 100%;
  height: auto;
  width: auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-print);
  transition: all var(--transition-smooth);
}

/* Right: Customization Controls Panel */
.studio-panel {
  flex: 0.9;
  max-width: 480px;
  background: var(--bg-color);
  border-left: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 32px;
  gap: 28px;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-section-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* Template Select Cards */
.template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.template-card {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-light);
  background: var(--surface-color);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.template-card:hover {
  border-color: #BDBDBD;
}

.template-card.active {
  border-color: var(--accent-color);
  background: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

.template-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.template-card-shots {
  font-size: 12px;
  color: var(--text-muted);
}

.template-card-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 4px;
  background: #EFF6FF;
  color: #1D4ED8;
  border: 1px solid #DBEAFE;
  margin-top: 2px;
}

/* Color Swatches */
.swatch-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.swatch-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-light);
  cursor: pointer;
  outline: none;
  position: relative;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  padding: 0;
}

.swatch-btn:hover {
  transform: scale(1.08);
}

.swatch-btn.active {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Input Fields */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.text-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface-color);
  outline: none;
  transition: border-color var(--transition-fast);
}

.text-input:focus {
  border-color: var(--accent-color);
  background: #FFFFFF;
}

.studio-panel-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 16px;
}

/* --------------------------------------------------------------------------
   SCREEN 8 & 9: FINAL SCREEN & QR CODE HANDOFF
   -------------------------------------------------------------------------- */
#screen-final {
  background: var(--surface-color);
}

.final-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.final-stage {
  flex: 1.1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at center, #F4F4F4 0%, #E8E8E8 100%);
  overflow: hidden;
}

.final-media-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-height: 100%;
  max-width: 100%;
}

.final-media-tabs {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.08);
  padding: 4px;
  border-radius: var(--radius-full);
  gap: 4px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.final-media-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.final-media-tab:hover {
  color: var(--text-primary);
}

.final-media-tab.active {
  background: #FFFFFF;
  color: #111111;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.final-media-display {
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: calc(100vh - 200px);
  max-width: 100%;
}

#final-canvas-preview,
#final-boomerang-preview {
  max-height: calc(100vh - 200px);
  max-width: 100%;
  height: auto;
  width: auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-elevated);
  transition: opacity 0.2s ease;
}

.final-panel {
  flex: 0.9;
  max-width: 500px;
  background: var(--bg-color);
  border-left: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  text-align: center;
  gap: 28px;
}

.final-header-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.final-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.final-desc {
  font-size: 15px;
  color: var(--text-secondary);
}

/* QR Code Display Box */
.qr-card {
  padding: 20px;
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

#qr-container {
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#qr-container img, #qr-container canvas {
  width: 220px !important;
  height: 220px !important;
  display: block;
}

.qr-caption {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Final Screen Button Group */
.final-actions {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 320px;
  gap: 12px;
}

.kiosk-reset-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}

.kiosk-reset-indicator:hover {
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   PHOTO HISTORY & ACCESSIBLE QR MODALS
   -------------------------------------------------------------------------- */
.history-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  color: #FFFFFF !important;
  background-color: var(--primary-color, #111111) !important;
  border-radius: var(--radius-full);
  line-height: 1;
  letter-spacing: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 860px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-light);
  transform: scale(0.96) translateY(10px);
  transition: transform var(--transition-normal) cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-container {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-light);
  background: #FAFAFA;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  background: #FAFAFA;
}

/* History Grid */
.history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-stats {
  font-size: 14px;
  color: var(--text-secondary);
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
}

.history-card {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: all var(--transition-fast);
  cursor: pointer;
  position: relative;
}

.history-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-color);
}

.history-card-thumb-wrap {
  width: 100%;
  height: 200px;
  background: #F0F0F0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-card-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #222;
}

.history-card-info {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-card-date {
  font-size: 12px;
  color: var(--text-muted);
}

.history-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.history-card-actions .btn {
  flex: 1;
  padding: 6px 10px;
  font-size: 12px;
  height: 32px;
}

/* Empty State */
.history-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  gap: 14px;
  color: var(--text-muted);
}

.history-empty-icon {
  width: 64px;
  height: 64px;
  stroke: #DDD;
}

.history-empty-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
}

.history-empty-desc {
  font-size: 14px;
  max-width: 320px;
  line-height: 1.5;
}

/* Photo Detail & Large QR Modal */
.detail-modal-container {
  max-width: 720px;
}

.detail-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: center;
}

@media (max-width: 680px) {
  .detail-content {
    grid-template-columns: 1fr;
  }
}

.detail-preview-box {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #F4F4F5;
  border-radius: var(--radius-md);
  padding: 12px;
  max-height: 420px;
}

.detail-preview-img {
  max-width: 100%;
  max-height: 380px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.detail-qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: #FAFAFA;
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  text-align: center;
}

.detail-qr-code {
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #FFF;
  padding: 10px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.detail-qr-code img, .detail-qr-code canvas {
  width: 180px !important;
  height: 180px !important;
  display: block;
}

.detail-url-box {
  font-size: 12px;
  color: var(--text-secondary);
  background: #FFF;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  word-break: break-all;
  width: 100%;
  text-align: center;
  user-select: all;
}

.qr-clickable-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #F0F4FF;
  color: #2563EB;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  margin-top: 4px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.qr-clickable-badge:hover {
  background: #DBEAFE;
}

/* --------------------------------------------------------------------------
   NEW FEATURES: TIMER PILLS, TONE FILTERS, FULLSCREEN TOGGLE
   -------------------------------------------------------------------------- */
.timer-pills {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}

.timer-pill {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.timer-pill.active {
  background: #FFFFFF;
  color: #111111;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.filter-pills-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-pill {
  flex: 1 1 calc(50% - 6px);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border-light);
  background: var(--surface-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.filter-pill:hover {
  border-color: #BDBDBD;
  color: var(--text-primary);
}

.filter-pill.active {
  border-color: #111111;
  background: #111111;
  color: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

#btn-toggle-fullscreen {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 999;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  cursor: pointer;
}

#btn-toggle-fullscreen:hover {
  background: #FFFFFF;
  transform: scale(1.06);
  box-shadow: var(--shadow-md);
}

.camera-active-fullscreen {
  background: rgba(30, 30, 30, 0.8) !important;
  border-color: rgba(255, 255, 255, 0.25) !important;
  color: #FFFFFF !important;
}

/* ==========================================================================
   RESPONSIVE & SAFARI / WEBKIT MOBILE ADAPTATIONS
   ========================================================================== */

/* iOS Safari Safe Area Inset Helpers */
.camera-controls {
  padding-bottom: max(0px, var(--safe-bottom));
}

.review-bottom-bar {
  padding-bottom: max(0px, var(--safe-bottom));
  padding-left: max(20px, var(--safe-left));
  padding-right: max(20px, var(--safe-right));
}

.top-nav {
  padding-top: max(0px, var(--safe-top));
  padding-left: max(16px, var(--safe-left));
  padding-right: max(16px, var(--safe-right));
}

/* Tablet & Mobile Breakpoint (<= 860px) */
@media (max-width: 860px) {
  /* Floating Fullscreen button adjustment */
  #btn-toggle-fullscreen {
    top: max(12px, var(--safe-top));
    right: max(12px, var(--safe-right));
    width: 36px;
    height: 36px;
  }

  /* Screen 1: Welcome */
  #screen-welcome {
    padding: max(24px, var(--safe-top)) max(16px, var(--safe-left)) max(24px, var(--safe-bottom)) max(16px, var(--safe-right));
  }

  .welcome-title {
    font-size: clamp(32px, 8vw, 48px);
  }

  .welcome-subtitle {
    font-size: 15px;
  }

  .mode-selector {
    width: 100%;
    max-width: 320px;
    justify-content: center;
  }

  .mode-pill {
    flex: 1;
    padding: 10px 12px;
    font-size: 13px;
    text-align: center;
  }

  /* Screen 2: Camera */
  .camera-stage {
    padding: 10px;
  }

  .viewfinder-wrapper {
    max-height: calc(100dvh - 200px);
    border-radius: var(--radius-md);
  }

  .camera-controls {
    height: 105px;
    padding: 0 max(16px, var(--safe-left)) max(10px, var(--safe-bottom)) max(16px, var(--safe-right));
  }

  .shutter-btn {
    width: 68px;
    height: 68px;
  }

  .shutter-btn-inner {
    width: 52px;
    height: 52px;
  }

  /* Screen 4: Review */
  .review-stage {
    padding: 16px 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .review-reel {
    gap: 12px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    max-width: 480px;
  }

  .review-card {
    width: 100%;
  }

  .review-bottom-bar {
    height: 76px;
    padding: 0 max(16px, var(--safe-left)) max(8px, var(--safe-bottom)) max(16px, var(--safe-right));
  }

  /* Screen 5, 6, 7: Studio */
  .studio-body {
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .studio-stage {
    flex: none;
    min-height: 42dvh;
    max-height: 48dvh;
    padding: 16px 12px;
  }

  #preview-canvas {
    max-height: calc(48dvh - 32px);
    max-width: 90vw;
  }

  .studio-panel {
    flex: 1;
    max-width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-light);
    padding: 20px 16px max(24px, var(--safe-bottom)) 16px;
    gap: 20px;
  }

  .template-grid {
    grid-template-columns: 1fr;
  }

  .studio-panel-actions {
    position: sticky;
    bottom: 0;
    background: var(--bg-color);
    padding-top: 12px;
    padding-bottom: max(6px, var(--safe-bottom));
  }

  /* Screen 8 & 9: Final Screen */
  .final-body {
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .final-stage {
    flex: none;
    min-height: 44dvh;
    max-height: 50dvh;
    padding: 16px 12px;
  }

  .final-media-display {
    max-height: calc(50dvh - 70px);
  }

  #final-canvas-preview,
  #final-boomerang-preview {
    max-height: calc(50dvh - 70px);
    max-width: 90vw;
  }

  .final-panel {
    flex: 1;
    max-width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-light);
    padding: 24px 16px max(24px, var(--safe-bottom)) 16px;
    gap: 20px;
  }

  .final-title {
    font-size: 24px;
  }

  .qr-card {
    padding: 16px;
  }

  .qr-code-wrapper {
    width: 160px;
    height: 160px;
  }

  .qr-code-wrapper img,
  .qr-code-wrapper canvas {
    width: 140px !important;
    height: 140px !important;
  }

  .final-actions {
    width: 100%;
    flex-direction: column;
    gap: 10px;
  }

  .final-actions .btn {
    width: 100%;
  }

  /* Modals on Mobile */
  .modal-overlay {
    padding: 10px;
  }

  .modal-container {
    width: 100%;
    max-height: 92dvh;
    border-radius: var(--radius-md);
  }

  .history-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

/* Small Smartphone Viewports (<= 480px) */
@media (max-width: 480px) {
  #btn-toggle-fullscreen {
    top: max(10px, var(--safe-top));
    right: max(10px, var(--safe-right));
    width: 32px;
    height: 32px;
  }

  .top-nav {
    height: 56px;
    padding: 0 10px;
    padding-top: max(0px, var(--safe-top));
    padding-right: 46px; /* Leave breathing space for floating fullscreen button */
  }

  .top-nav .nav-title {
    font-size: 12px;
    letter-spacing: 0.04em;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .top-nav .nav-actions {
    gap: 6px;
  }

  .top-nav .btn {
    padding: 6px 10px;
    font-size: 12px;
    gap: 4px;
  }

  .top-nav .btn-icon {
    width: 34px;
    height: 34px;
  }

  .timer-pills {
    padding: 2px;
  }

  .timer-pill {
    padding: 3px 8px;
    font-size: 11px;
  }

  .badge {
    padding: 4px 10px;
    font-size: 11px;
  }

  .welcome-title {
    font-size: clamp(28px, 7.5vw, 36px);
  }

  .swatch-btn {
    width: 38px;
    height: 38px;
  }

  .filter-pill {
    flex: 1 1 calc(50% - 6px);
    font-size: 12px;
    padding: 8px 10px;
  }
}

