/* ── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:       #9B59B6;
  --accent-dark:  #7d3f9b;
  --accent-glow:  rgba(155, 89, 182, 0.35);
  --accent-soft:  rgba(155, 89, 182, 0.12);
  --bg:           #0d0d14;
  --bg2:          #13131f;
  --surface:      rgba(255,255,255,0.04);
  --surface-hover:rgba(255,255,255,0.07);
  --border:       rgba(255,255,255,0.08);
  --text:         #eaeaf4;
  --text-muted:   #7878a0;
  --danger:       #e74c3c;
  --danger-dark:  #c0392b;
  --success:      #2ecc71;
  --radius:       16px;
  --radius-sm:    10px;
  --shadow:       0 8px 32px rgba(0,0,0,0.5);
  --transition:   0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ── Background glow ──────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(155,89,182,0.15) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── Compat banner ────────────────────────────────────── */
.compat-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: linear-gradient(90deg, #2c1a1a, #1e1218);
  border-bottom: 1px solid rgba(231,76,60,0.3);
  color: #f1a39a;
  font-size: 0.875rem;
}
.compat-banner svg { flex-shrink: 0; }
.compat-banner span { flex: 1; }
.compat-banner code {
  font-family: 'Courier New', monospace;
  background: rgba(255,255,255,0.1);
  padding: 2px 6px;
  border-radius: 4px;
}
#compat-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  transition: color var(--transition);
}
#compat-close:hover { color: var(--text); }

/* ── Header ───────────────────────────────────────────── */
.header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 60px 24px 24px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 12px;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 20px var(--accent-glow);
  color: #fff;
}
.logo-text {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.accent { color: var(--accent); }
.tagline {
  letter-spacing: 0.02em;
}

/* ── Hero Badges ───────────────────────────────────────── */
.hero-info { margin-bottom: 40px; margin-top: -10px; }
.info-badges {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(155, 89, 182, 0.1);
  border: 1px solid rgba(155, 89, 182, 0.2);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
}

/* ── Main layout ──────────────────────────────────────── */
.main {
  position: relative;
  z-index: 1;
  max-width: 780px;
  margin: 0 auto;
  padding: 0 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Card ─────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  transition: border-color var(--transition);
}
.card:hover { border-color: rgba(155,89,182,0.2); }

/* ── Controls card ────────────────────────────────────── */
.controls-card {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Timer */
.timer-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-direction: column;
}
.timer {
  font-size: 4rem;
  font-weight: 300;
  letter-spacing: 4px;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, #fff 30%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.status-label {
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  transition: color var(--transition);
}
.status-label.recording { color: var(--danger); }
.status-label.paused    { color: #f39c12; }

/* Recording pulse dot */
.rec-dot {
  width: 10px; height: 10px;
  background: var(--danger);
  border-radius: 50%;
  animation: pulse-dot 1.2s ease-in-out infinite;
  position: absolute;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}
.timer-wrap { position: relative; padding-top: 18px; }
.rec-dot { top: 0; left: 50%; transform: translateX(-50%); }

/* ── Toggles ──────────────────────────────────────────── */
.toggles {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}
.toggle-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  user-select: none;
  min-width: 160px;
}
.toggle-item:hover { background: rgba(255,255,255,0.06); border-color: rgba(155,89,182,0.3); }
.toggle-icon { color: var(--accent); display: flex; align-items: center; }
.toggle-label { flex: 1; font-size: 0.9rem; font-weight: 500; }

/* Switch */
.switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.12);
  border-radius: 22px;
  cursor: pointer;
  transition: background var(--transition);
}
.slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition), box-shadow var(--transition);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before {
  transform: translateX(18px);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ── Stats ────────────────────────────────────────────── */
.stats-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.stats-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.stats-val {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
}
.stats-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

/* ── Buttons ──────────────────────────────────────────── */
.btn-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 24px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), opacity var(--transition);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97) !important; }
.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 4px 15px var(--accent-glow);
}
.btn-primary:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--accent-glow);
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:not(:disabled):hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(155,89,182,0.4);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), var(--danger-dark));
  color: #fff;
  box-shadow: 0 4px 15px rgba(231,76,60,0.3);
}
.btn-danger:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(231,76,60,0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:not(:disabled):hover {
  color: var(--text);
  border-color: rgba(155,89,182,0.3);
  background: var(--surface);
  transform: translateY(-1px);
}

/* ── Webcam PiP overlay ───────────────────────────────── */
.webcam-pip {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid var(--accent);
  box-shadow: 0 8px 30px rgba(0,0,0,0.6), 0 0 20px var(--accent-glow);
  cursor: move;
  z-index: 900;
  user-select: none;
}
.webcam-pip video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror webcam */
  border-radius: 50%;
}
.pip-drag-handle {
  position: absolute;
  top: 6px; left: 6px;
  color: rgba(255,255,255,0.6);
  font-size: 1.1rem;
  line-height: 1;
  pointer-events: none;
  letter-spacing: 2px;
}

/* ── Preview card ─────────────────────────────────────── */
.preview-header {
  margin-bottom: 20px;
}
.preview-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}
.preview-title svg { color: var(--accent); }

.preview-video {
  width: 100%;
  border-radius: var(--radius-sm);
  background: #000;
  max-height: 400px;
  outline: none;
  display: block;
}
.preview-video:focus { box-shadow: 0 0 0 3px var(--accent-glow); }

/* trim container */
.trim-container {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-top: 24px;
}
.trim-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.trim-label { font-weight: 600; font-size: 0.95rem; }
.trim-values { font-family: monospace; font-size: 0.85rem; color: var(--accent); }

.trim-slider-wrap {
  position: relative;
  height: 36px;
  margin-bottom: 8px;
}
.trim-slider {
  position: absolute;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: none;
  pointer-events: none;
  z-index: 2;
  top: 50%;
  transform: translateY(-50%);
}
.trim-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 24px;
  background: var(--accent);
  border-radius: 4px;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 0 10px var(--accent-glow);
}
.trim-track {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 6px;
  width: 100%;
  background: var(--border);
  border-radius: 3px;
  z-index: 1;
}
.preview-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ── Info Section ─────────────────────────────────────── */
.info-section {
  margin-top: 60px;
  text-align: left;
  border-top: 1px solid var(--border);
  padding-top: 60px;
}
.section-header h2 { font-size: 2rem; margin-bottom: 8px; color: #fff; }
.section-header p { color: var(--text-muted); margin-bottom: 40px; font-size: 1.1rem; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 30px;
}
.info-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 30px;
  transition: transform var(--transition);
}
.info-item:hover { transform: translateY(-5px); border-color: var(--accent); }
.info-item h3 { margin-bottom: 12px; font-size: 1.2rem; }
.info-item p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; }

/* ── Toast ────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e1c2e;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 24px;
  font-size: 0.88rem;
  color: var(--text);
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  max-width: 420px;
  text-align: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.error { border-color: rgba(231,76,60,0.5); color: #f1a39a; }

/* ── Canvas (hidden) ──────────────────────────────────── */
canvas.hidden { display: none !important; }

/* ── Utility ──────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Recording state body class ───────────────────────── */
body.is-recording .controls-card {
  border-color: rgba(231,76,60,0.3);
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 600px) {
  .header { padding: 40px 16px 20px; }
  .timer { font-size: 3rem; }
  .features-grid { grid-template-columns: repeat(2, 1fr); }
  .btn-row { flex-direction: column; align-items: stretch; }
  .btn { justify-content: center; }
  .toggles { flex-direction: column; }
  .toggle-item { min-width: unset; }
  .webcam-pip { width: 140px; }
  .card { padding: 24px 18px; }
}

/* ── Countdown overlay ────────────────────────────────── */
.countdown-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: grid;
  place-items: center;
  background: rgba(13, 13, 20, 0.85);
  backdrop-filter: blur(12px);
}
.countdown-number {
  font-size: 14rem;
  font-weight: 700;
  letter-spacing: -8px;
  background: linear-gradient(135deg, #fff 20%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: countdown-pop 1s cubic-bezier(0.36, 0.07, 0.19, 0.97) forwards;
  user-select: none;
}
@keyframes countdown-pop {
  0%   { transform: scale(1.4); opacity: 0; }
  20%  { transform: scale(1);   opacity: 1; }
  80%  { transform: scale(1);   opacity: 1; }
  100% { transform: scale(0.6); opacity: 0; }
}

/* ── Mic controls (volume + VU-meter) ─────────────────── */
.mic-controls {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--transition);
}
.mic-controls:not(.hidden) { display: flex; }
.mic-vol-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
}

/* Volume slider */
.vol-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: rgba(255,255,255,0.12);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
  cursor: pointer;
  transition: transform var(--transition);
}
.vol-slider::-webkit-slider-thumb:hover { transform: scale(1.3); }
.vol-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 38px;
  text-align: right;
}

/* VU-meter bar */
.vu-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.vu-meter {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
  overflow: hidden;
}
.vu-bar {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, #2ecc71 0%, #f39c12 65%, #e74c3c 90%);
  transition: width 0.05s linear;
}
.vu-label {
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* mic settings */
.mic-settings-row {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-muted);
  transition: color var(--transition);
}
.checkbox-item:hover { color: var(--text); }
.checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

@keyframes ripple-out {
  0%   { transform: scale(0.3); opacity: 1; }
  100% { transform: scale(2);   opacity: 0; }
}

/* ── Footer ───────────────────────────────────────────── */
.footer {
  margin-top: auto;
  padding: 40px 24px;
  border-top: 1px solid var(--border);
  background: rgba(13, 13, 20, 0.4);
}
.footer-content {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}
.branding {
  font-size: 0.88rem;
  color: var(--text-muted);
}
.branding a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition);
}
.branding a:hover { color: #fff; text-decoration: underline; }

/* ── Extra Settings (Resolution, Mirror) ──────────────── */
.extra-settings {
  display: flex;
  gap: 20px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px;
  background: rgba(255,255,255,0.02);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.setting-item {
  display: flex;
  align-items: center;
  gap: 10px;
}
.setting-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}
.select-input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}
.select-input:hover { border-color: var(--accent); }

@media (max-width: 600px) {
  .footer-content { flex-direction: column; text-align: center; }
  .extra-settings { flex-direction: column; gap: 12px; }
}

/* ── Sharing Tip (WhatsApp) ─────────────────────────── */
.sharing-tip {
  margin-top: 24px;
  padding: 20px;
  background: rgba(155, 89, 182, 0.05);
  border: 1px dashed rgba(155, 89, 182, 0.3);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sharing-tip-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sharing-tip p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.sharing-tip strong {
  color: var(--text);
  background: rgba(255,255,255,0.05);
  padding: 2px 4px;
  border-radius: 4px;
}
