:root {
  --bg-dark: #090b10;
  --accent-red: #ef4444;
  --accent-red-glow: rgba(239, 68, 68, 0.45);
  --accent-amber: #f59e0b;
  --text-light: #f9fafb;
  --text-muted: #9ca3af;
  --prompter-font-size: 26px;
  --prompter-height: 32vh;
  --prompter-bg-opacity: 0.55;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #000;
  color: var(--text-light);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

.hidden {
  display: none !important;
}

/* App Shell & 9:16 Portrait Stage */
.app-shell {
  width: 100vw;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: calc(100dvh * 9 / 16);
  aspect-ratio: 9 / 16;
  background: #111318;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

@media (max-width: 640px) {
  .stage {
    max-width: 100vw;
    width: 100vw;
    height: 100dvh;
    aspect-ratio: auto;
  }
}

@media (min-width: 641px) {
  .stage {
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.12);
  }
}

/* Live Camera Video */
.camera-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  background: #0d1117;
}

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

/* Camera Fallback Card */
.camera-fallback {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at center, #1f2937 0%, #090b10 100%);
}

.fallback-card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(16px);
  border-radius: 20px;
  padding: 28px 22px;
  text-align: center;
  max-width: 320px;
}

.fallback-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.fallback-card h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.fallback-card p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 18px;
}

/* Top-Pinned Eye-Line Teleprompter */
.prompter-wrapper {
  position: relative;
  z-index: 10;
  padding-top: calc(var(--safe-top) + 6px);
  padding-left: 10px;
  padding-right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lens-guide {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  padding: 5px 12px;
  border-radius: 999px;
  align-self: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.lens-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
}

.recording-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(239, 68, 68, 0.22);
  border: 1px solid rgba(239, 68, 68, 0.6);
  color: #fecaca;
  padding: 2px 8px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  margin-left: 4px;
}

.rec-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-red);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.85); }
}

.prompter-box {
  position: relative;
  width: 100%;
  height: var(--prompter-height);
  background: rgba(10, 12, 16, var(--prompter-bg-opacity));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  transition: border-color 0.2s ease;
}

/* Eye-line reading highlight band right near the top of the box */
.reading-band {
  position: absolute;
  top: 22%;
  left: 0;
  right: 0;
  height: calc(var(--prompter-font-size) * 1.65);
  background: linear-gradient(
    90deg,
    rgba(250, 204, 21, 0.22) 0%,
    rgba(250, 204, 21, 0.1) 50%,
    rgba(250, 204, 21, 0.22) 100%
  );
  border-top: 1px solid rgba(250, 204, 21, 0.38);
  border-bottom: 1px solid rgba(250, 204, 21, 0.38);
  pointer-events: none;
  z-index: 2;
}

.reading-band::before {
  content: "▸";
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  color: #facc15;
  font-size: 16px;
}

.prompter-scroll {
  position: relative;
  z-index: 3;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 22px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  cursor: pointer;
}

.prompter-scroll::-webkit-scrollbar {
  display: none;
}

.prompter-spacer-top {
  height: 24%;
}

.prompter-spacer-bottom {
  height: 75%;
}

.prompter-content {
  font-size: var(--prompter-font-size);
  line-height: 1.42;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
  white-space: pre-wrap;
  word-break: break-word;
}

.scroll-status-pill {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  background: rgba(0, 0, 0, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fde047;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  pointer-events: none;
}

/* Quick Action Chips under the Prompter Box */
.prompter-footer-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chip-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(15, 18, 24, 0.68);
  backdrop-filter: blur(10px);
  color: #f3f4f6;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.chip-btn:active {
  transform: scale(0.96);
}

.chip-btn.active {
  background: rgba(250, 204, 21, 0.24);
  border-color: #facc15;
  color: #fef08a;
}

/* 3-Second Countdown Overlay */
.countdown-overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.countdown-number {
  font-size: 112px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 8px 30px rgba(0, 0, 0, 0.7);
  animation: countPop 0.9s ease-out infinite;
}

.countdown-sub {
  margin-top: 8px;
  font-size: 16px;
  font-weight: 600;
  color: #fde047;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

@keyframes countPop {
  0% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.75; }
}

/* Appearance Popover Panel */
.popover-panel {
  position: absolute;
  top: calc(var(--safe-top) + 56px);
  left: 14px;
  right: 14px;
  z-index: 30;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 15px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.control-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
}

.control-row label {
  display: flex;
  justify-content: space-between;
  color: #d1d5db;
  font-weight: 500;
}

.control-row.toggle-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
}

.control-row input[type="range"] {
  width: 100%;
  accent-color: #facc15;
}

.control-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #ef4444;
}

/* Bottom HUD */
.bottom-hud {
  position: relative;
  z-index: 10;
  padding: 12px 16px calc(var(--safe-bottom) + 16px);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.82) 0%, rgba(0, 0, 0, 0.4) 70%, transparent 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.speed-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 18, 25, 0.72);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 8px 14px;
  border-radius: 999px;
}

.speed-label {
  font-size: 15px;
}

.speed-bar input[type="range"] {
  flex: 1;
  accent-color: #facc15;
  height: 6px;
  cursor: pointer;
}

.speed-readout {
  font-size: 13px;
  font-weight: 700;
  color: #fde047;
  min-width: 38px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.shutter-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.hud-side-btn {
  appearance: none;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  width: 64px;
  height: 54px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

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

.hud-icon {
  font-size: 18px;
}

.hud-text {
  font-size: 11px;
  font-weight: 600;
}

/* Shutter / Record Button */
.record-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 4px solid #ffffff;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease, border-color 0.2s ease;
}

.record-btn:active {
  transform: scale(0.93);
}

.record-btn-inner {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-red);
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 16px var(--accent-red-glow);
}

.record-btn.is-recording {
  border-color: #fecaca;
}

.record-btn.is-recording .record-btn-inner {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

/* Modals (Script Editor & Video Review) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}

@media (min-width: 641px) {
  .modal-backdrop {
    align-items: center;
  }
}

.modal-sheet {
  width: 100%;
  max-width: 440px;
  background: #141821;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 22px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8);
}

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

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.icon-close-btn {
  appearance: none;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
}

.modal-hint {
  font-size: 13px;
  color: var(--text-muted);
}

.script-textarea {
  width: 100%;
  min-height: 210px;
  background: #0b0e14;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  padding: 14px;
  color: #ffffff;
  font-size: 16px;
  line-height: 1.5;
  resize: vertical;
  font-family: inherit;
  user-select: text;
  -webkit-user-select: text;
}

.script-textarea:focus {
  outline: none;
  border-color: #facc15;
}

.script-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.script-quick-actions {
  display: flex;
  gap: 8px;
}

/* Review Modal Specifics */
.review-video-wrap {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 56dvh;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.recorded-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.review-tip {
  font-size: 12px;
  color: #d1d5db;
  line-height: 1.4;
  text-align: center;
}

.review-actions {
  display: flex;
  gap: 10px;
}

.review-actions > button {
  flex: 1;
}

/* Buttons */
.btn-primary {
  appearance: none;
  border: none;
  background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
  color: #ffffff;
  font-weight: 700;
  font-size: 15px;
  padding: 12px 18px;
  border-radius: 12px;
  cursor: pointer;
}

.btn-secondary {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-weight: 600;
  font-size: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-block {
  width: 100%;
}
