* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #000;
  color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

.view {
  height: 100%;
  width: 100%;
}

.hidden {
  display: none !important;
}

/* Editor view */

#editor-view {
  display: flex;
  flex-direction: column;
  padding: 20px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  gap: 16px;
}

#editor-view h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
  text-align: center;
}

#script-input {
  flex: 1;
  width: 100%;
  resize: none;
  background: #111;
  color: #fff;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 14px;
  font-size: 1.1rem;
  line-height: 1.5;
}

.editor-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.editor-actions button,
.file-btn {
  flex: 1;
  min-width: 140px;
  text-align: center;
  padding: 14px 16px;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid #333;
  background: #1a1a1a;
  color: #fff;
  cursor: pointer;
}

#start-btn {
  background: #2f6fed;
  border-color: #2f6fed;
  font-weight: 600;
}

/* Prompter view */

#prompter-view {
  position: relative;
  display: flex;
  flex-direction: column;
}

#scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

#scroll-area::-webkit-scrollbar {
  display: none;
}

#script-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  padding: 50vh 24px;
  font-size: 48px;
  line-height: 1.5;
  font-weight: 600;
}

/* Camera preview + overlay mode */

#camera-preview {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

#camera-preview.mirrored {
  transform: scaleX(-1);
}

#prompter-view.camera-active #scroll-area {
  position: relative;
  z-index: 1;
  background: transparent;
}

#prompter-view.camera-active #script-text {
  text-shadow: 0 0 4px #000, 0 0 10px #000, 0 2px 6px #000;
}

#rec-indicator {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  color: #ff4b4b;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  pointer-events: none;
  animation: rec-pulse 1.4s ease-in-out infinite;
}

@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

#countdown-overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

#countdown-number {
  font-size: clamp(96px, 40vw, 260px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
}

#countdown-number.pop {
  animation: countdown-pop 0.9s ease-out;
}

@keyframes countdown-pop {
  0% { transform: scale(1.6); opacity: 0; }
  30% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

#controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  border-top: 1px solid #222;
}

#controls button {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #333;
  background: #1a1a1a;
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}

#play-pause-btn {
  background: #2f6fed;
  border-color: #2f6fed;
}

#camera-toggle-btn.active {
  background: #2f6fed;
  border-color: #2f6fed;
}

#record-btn {
  color: #ff4b4b;
}

#record-btn.recording {
  background: #ff4b4b;
  border-color: #ff4b4b;
  color: #fff;
  animation: rec-pulse 1.4s ease-in-out infinite;
}

.control-label {
  flex: 1;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  font-size: 0.65rem;
  color: #aaa;
  gap: 2px;
}

.control-label input[type="range"] {
  width: 100%;
}

/* Result modal */

#result-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.95);
}

#result-video {
  width: 100%;
  max-width: 480px;
  max-height: 60vh;
  border-radius: 12px;
  background: #000;
}

.result-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.result-actions button {
  padding: 14px 18px;
  min-width: 130px;
  border-radius: 10px;
  border: 1px solid #333;
  background: #1a1a1a;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}

#download-btn {
  background: #2f6fed;
  border-color: #2f6fed;
  font-weight: 600;
}
