* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #000;
  color: #fff;
  overflow-x: hidden;
}

#app {
  max-width: 100vw;
  min-height: 100vh;
}

/* Header */
.header {
  background: #1a1a1a;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #333;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-logo {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.header h1 {
  font-size: 1.5rem;
  color: #2196f3;
}

.header-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

/* Main Camera View */
.main-view {
  position: relative;
}

.camera-container {
  position: relative;
  width: 100vw;
  min-height: 400px;
  max-height: 80vh;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 0 auto;
}

/* Floating capture button */
.floating-capture-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #2196f3;
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
  transition: all 0.2s ease;
  z-index: 1000;
}

.floating-capture-btn:hover {
  background: #1976d2;
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(33, 150, 243, 0.6);
}

.floating-capture-btn:active {
  transform: scale(0.95);
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.8);
}

/* Camera toggle button group */
.camera-toggle-group {
  position: absolute;
  bottom: 20px;
  left: 20px;
  display: flex;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 25px;
  padding: 4px;
  gap: 2px;
  z-index: 1000;
}

.camera-toggle-btn {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.camera-toggle-btn.active {
  background: #2196f3;
  color: white;
}

.camera-toggle-btn.active:hover {
  background: #1976d2;
}

/* Resolution overlay */
.resolution-overlay {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
  z-index: 1000;
  pointer-events: none;
}

#cameraPreview {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}

.edge-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.7;
}

/* Buttons */
.btn {
  background: #2196f3;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.btn:hover {
  background: #1976d2;
}

.btn-secondary {
  background: #666;
}

.btn-secondary:hover {
  background: #555;
}

.btn-danger {
  background: #f44336;
}

.btn-danger:hover {
  background: #d32f2f;
}

.btn-primary {
  background: #2196f3;
}

.btn-nav {
  background: #333;
  font-size: 1.2rem;
  padding: 0.75rem;
  border-radius: 50%;
  width: 50px;
  height: 50px;
}

.btn-close {
  background: transparent;
  color: #999;
  font-size: 1.2rem;
  padding: 0.25rem 0.5rem;
}

/* Selects */
.camera-select,
.resolution-select {
  background: #333;
  color: white;
  border: 1px solid #555;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  max-width: 180px;
  min-width: 120px;
}

.project-select {
  background: #333;
  color: white;
  border: 1px solid #555;
  padding: 0.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
}

/* Project Section */
.project-section {
  background: #1a1a1a;
  padding: 1rem;
  border-bottom: 1px solid #333;
}

.project-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.project-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.project-select {
  flex: 1;
}

/* Series Section */
.series-section {
  background: #222;
  padding: 1rem;
}

.series-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.series-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Film Strip */
.film-strip-container {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.5rem 0;
  background: #1a1a1a;
  border-radius: 8px;
  scroll-behavior: smooth;
}

.film-strip {
  display: flex;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  min-width: max-content;
}

.film-strip-item {
  position: relative;
  width: 120px;
  height: 90px;
  background: #333;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  flex-shrink: 0;
}

.film-strip-item:hover {
  transform: scale(1.05);
  border-color: #2196f3;
}

.film-strip-item.selected {
  border-color: #2196f3;
  box-shadow: 0 0 12px rgba(33, 150, 243, 0.5);
}

.film-strip-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.film-strip-item .item-number {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: bold;
}

.film-strip-item .item-timestamp {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.6rem;
  max-width: calc(100% - 8px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.film-strip-item .item-delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(244, 67, 54, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 2;
}

.film-strip-item:hover .item-delete-btn {
  opacity: 1;
}

.film-strip-item .item-delete-btn:hover {
  background: rgba(244, 67, 54, 1);
  transform: scale(1.1);
}

.film-strip-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 200px;
  height: 90px;
  background: #333;
  border-radius: 6px;
  color: #999;
  font-size: 0.9rem;
  margin: 0 auto;
}

#seriesCounter {
  color: #999;
  font-size: 0.9rem;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: #1a1a1a;
  padding: 1.5rem;
  border-radius: 12px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.modal-actions {
  margin-top: 1rem;
  text-align: right;
}

/* Movie Player */
#movieCanvas {
  max-width: 100%;
  max-height: 60vh;
  background: #000;
  margin-bottom: 1rem;
}

.movie-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
}

.speed-slider {
  width: 100px;
}

/* Project Input */
.project-input {
  width: 100%;
  padding: 0.75rem;
  background: #333;
  border: 1px solid #555;
  border-radius: 6px;
  color: white;
  font-size: 1rem;
}

.project-input:focus {
  outline: none;
  border-color: #2196f3;
}

/* Responsive Design */
@media (max-width: 768px),
  (max-height: 600px) and (orientation: landscape) and (pointer: coarse),
  (max-width: 1024px) and (orientation: landscape) and (hover: none) {
  /* Mobile layout optimizations for maximum camera preview space */

  /* Support for safe areas on notched devices */
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  /* Compact header */
  .header {
    padding: 0.5rem;
    padding-top: max(0.5rem, env(safe-area-inset-top));
    min-height: auto;
  }

  .header-title {
    gap: 0.5rem;
  }

  .header-logo {
    width: 24px;
    height: 24px;
  }

  .header h1 {
    font-size: 1.2rem;
  }

  .header-controls {
    gap: 0.5rem;
  }

  .header-controls .btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
  }

  .camera-select,
  .resolution-select {
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
    max-width: 140px;
    min-width: 100px;
  }

  /* Maximize camera container height */
  .camera-container {
    min-height: 60vh;
    max-height: 90vh;
  }

  /* Adjust floating button position for safe areas */
  .floating-capture-btn {
    bottom: max(20px, env(safe-area-inset-bottom, 20px));
    right: max(20px, env(safe-area-inset-right, 20px));
  }

  /* Adjust camera toggle position for safe areas */
  .camera-toggle-group {
    bottom: max(20px, env(safe-area-inset-bottom, 20px));
    left: max(20px, env(safe-area-inset-left, 20px));
  }

  /* Adjust resolution overlay position for safe areas */
  .resolution-overlay {
    top: max(20px, env(safe-area-inset-top, 20px));
    right: max(20px, env(safe-area-inset-right, 20px));
  }

  /* Compact project section */
  .project-section {
    padding: 0.5rem;
  }

  .project-header {
    margin-bottom: 0.5rem;
  }

  .project-header h2 {
    font-size: 1.1rem;
  }

  .project-controls {
    gap: 0.5rem;
  }

  .project-controls .btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
  }

  /* Compact series section */
  .series-section {
    padding: 0.5rem;
  }

  .series-header {
    margin-bottom: 0.5rem;
  }

  .series-header h3 {
    font-size: 1rem;
  }

  .series-controls .btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
  }

  #seriesCounter {
    font-size: 0.8rem;
  }

  /* Compact film strip */
  .film-strip-container {
    padding: 0.25rem 0;
  }

  .film-strip-item {
    width: 80px;
    height: 60px;
  }

  .film-strip {
    gap: 0.5rem;
    padding: 0.25rem 0.5rem;
  }

  .film-strip-item .item-number {
    font-size: 0.6rem;
    padding: 1px 4px;
  }

  .film-strip-item .item-timestamp {
    font-size: 0.5rem;
    padding: 1px 3px;
    max-width: calc(
      100% - 22px
    ); /* Account for smaller mobile frames and delete button */
  }

  .film-strip-item .item-delete-btn {
    width: 16px;
    height: 16px;
    font-size: 0.6rem;
    opacity: 1; /* Always visible on mobile for easier touch interaction */
  }

  .film-strip-placeholder {
    width: 150px;
    height: 60px;
    font-size: 0.8rem;
  }

  /* Modal adjustments */
  .modal-content {
    margin: 0.5rem;
    max-width: calc(100vw - 1rem);
  }
}
