:root {
  --bg: #0b0d10;
  --panel: #15181d;
  --panel-border: #262b33;
  --text: #f2f0ea;
  --text-dim: #9aa0aa;
  --accent: #e8a33d;
  --record: #e5484d;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
}

/* ---------------- License gate ---------------- */

.license-gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 120% at 50% 0%, #1a1e24 0%, var(--bg) 60%);
  z-index: 100;
}

.license-card {
  width: 100%;
  max-width: 360px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #c97a1e);
}

.brand-name {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.license-copy {
  color: var(--text-dim);
  font-size: 14.5px;
  line-height: 1.5;
  margin: 0 0 16px;
}

.license-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  letter-spacing: 0.03em;
  margin-bottom: 12px;
}

.license-input::placeholder { color: #565c66; }

.btn-primary {
  display: block;
  width: 100%;
  text-align: center;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #14100a;
  font-size: 16px;
  font-weight: 650;
  text-decoration: none;
}

.btn-primary:disabled { opacity: 0.6; }

.btn-secondary {
  display: block;
  width: 100%;
  text-align: center;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 15px;
}

.license-error {
  display: none;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(229, 72, 77, 0.12);
  border: 1px solid rgba(229, 72, 77, 0.35);
  color: #ff9a9d;
  font-size: 13.5px;
  line-height: 1.4;
}

.license-hint {
  margin-top: 14px;
  color: #565c66;
  font-size: 12.5px;
  text-align: center;
}

/* ---------------- App shell ---------------- */

.app-root {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: #000;
}

.camera-feed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.script-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 46%;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.45);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.script-track {
  padding: 20px 24px;
  font-size: 36px;
  line-height: 1.5;
  font-weight: 600;
  color: #ffffff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
  white-space: pre-wrap;
  transform: translateY(100%);
  will-change: transform;
}

/* Horizontal scroll modes: single line, no wrapping, vertically centered
   in whatever height the overlay-size slider gives it. */
.script-track.horizontal {
  white-space: nowrap;
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 24px;
}

.script-track.mirrored { transform: translateY(100%) scaleX(-1); }

.rec-dot {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(0, 0, 0, 0.55);
  color: #ff6a6f;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

/* ---------------- Script editor ---------------- */

.editor-panel {
  padding: 16px;
  background: var(--panel);
  border-top: 1px solid var(--panel-border);
}

.script-textarea {
  width: 100%;
  height: 22vh;
  resize: vertical;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  background: #0f1216;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 10px;
}

/* ---------------- Bottom controls ---------------- */

.controls {
  background: var(--panel);
  border-top: 1px solid var(--panel-border);
  padding: 10px 16px 16px;
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.controls-row:first-child { margin-top: 4px; justify-content: center; gap: 18px; }

.icon-btn {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: #21252c;
  color: var(--text);
  font-size: 19px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.icon-btn-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}

.icon-btn.record { background: var(--record); color: #fff; }
.icon-btn.record .icon-btn-label { color: rgba(255,255,255,0.85); }
.icon-btn.record.active { background: #7a1216; }

.sliders {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.sliders label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  color: var(--text-dim);
  gap: 10px;
}

.sliders input[type="range"] { flex: 1; accent-color: var(--accent); }

.toggles {
  font-size: 13.5px;
  color: var(--text-dim);
  justify-content: space-between;
}

.toggles label { display: flex; align-items: center; gap: 8px; }

.toggles select {
  background: #0f1216;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12.5px;
}

.import-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.import-row input[type="file"] {
  color: var(--text-dim);
  font-size: 12px;
  max-width: 55%;
}

.import-status {
  font-size: 12.5px;
  color: var(--text-dim);
  min-height: 16px;
  margin-bottom: 8px;
}

.download-bar {
  display: flex;
  gap: 10px;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--panel-border);
}

/* BUG FIX: the rule above's unconditional `display: flex` was an author
   style, which beats the browser's own default `[hidden] { display: none }`
   rule regardless of matching specificity — so this bar was rendering
   immediately on load, overlapping the controls, before any recording had
   even happened. This explicit [hidden] override — a class+attribute
   selector, which does out-specify the plain class rule above — restores
   the correct hide-until-JS-shows-it behavior. */
.download-bar[hidden] { display: none; }

.download-bar .btn-primary, .download-bar .btn-secondary { width: auto; flex: 1; }
