.modal-busy { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; background: rgba(11,16,32,0.6); backdrop-filter: blur(2px); border-radius: 16px; z-index: 10; pointer-events: all; }
.modal-busy[hidden] { display: none !important; }
.spinner { width: 28px; height: 28px; border: 3px solid rgba(255,255,255,0.25); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { width: min(520px, 80%); height: 6px; border-radius: 999px; background: rgba(255,255,255,0.15); overflow: hidden; }
.progress .bar { width: 0%; height: 100%; background: linear-gradient(90deg, #7c5cff, #3abfff); transition: width 120ms linear; }
:root {
  --bg: #0b1020;
  --bg-elev: #121832;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.08);
  --text: #e8ecf1;
  --muted: #a0a8c0;
  --primary: #7c5cff;
  --primary-600: #6a49ff;
  --success: #23d18b;
  --warning: #ffca3a;
  --danger: #ff5d5d;
  --info: #3abfff;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
}

/* Ensure elements with the hidden attribute are not displayed */
[hidden] { display: none !important; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: radial-gradient(1200px 800px at 15% 10%, #1a1f3d 0%, rgba(26,31,61,0) 60%),
              radial-gradient(900px 600px at 85% 20%, #0f2a4b 0%, rgba(15,42,75,0) 60%),
              linear-gradient(160deg, #0b1020 0%, #0b1020 100%);
  background-attachment: fixed;
}

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  backdrop-filter: blur(10px);
  background: linear-gradient(180deg, rgba(5,8,20,0.85) 0%, rgba(5,8,20,0.35) 100%);
  border-bottom: 1px solid var(--card-border);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; }
.brand-name { font-weight: 800; letter-spacing: 0.2px; font-size: 18px; }

.stack {
  width: 100%;
  max-width: 900px;
  margin: 24px auto;
  padding: 0 20px 40px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: floatIn 600ms ease both;
}

.card.audio-settings {
  overflow: visible;
}

@keyframes floatIn {
  from { transform: translateY(8px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.preview-card { padding: 16px; }
.preview-card.centered { text-align: center; }
.video-wrap {
  position: relative;
  aspect-ratio: 16/10;
  border-radius: 12px;
  overflow: hidden;
  background: #0a0f1f;
  border: 1px solid var(--card-border);
}
video#preview { width: 100%; height: 100%; object-fit: contain; background: #000; }
.video-wrap.trimming { display: none; }
.video-wrap.trimming + .trim-inline { margin-top: 0; }

/* removed in favor of on-canvas watermark only */

.video-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px;
  padding-bottom: 48px;
  color: var(--muted);
}
.video-placeholder i { width: 48px; height: 48px; color: var(--muted); opacity: 0.9; }
.video-placeholder p { margin: 0; opacity: 0.95; text-align: center; }
.video-placeholder p.sub { font-size: 12px; opacity: 0.75; }
/* arrow CTA removed, keep text-only */

.rec-indicator {
  position: absolute; top: 12px; left: 12px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 999px;
  background: rgba(255, 0, 0, 0.12);
  color: #ffb3b3;
  border: 1px solid rgba(255, 93, 93, 0.35);
  box-shadow: 0 2px 8px rgba(255, 93, 93, 0.15);
  opacity: 0; transform: translateY(-8px);
  pointer-events: none;
}
.rec-indicator.active { opacity: 1; transform: translateY(0); transition: all 300ms ease; }
.rec-indicator .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 0 rgba(255, 93, 93, 0.6);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 93, 93, 0.6); }
  70% { box-shadow: 0 0 0 12px rgba(255, 93, 93, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 93, 93, 0); }
}

.hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

/* settings panel removed */

.field { display: grid; gap: 6px; margin-bottom: 8px; }
.field label { font-size: 12px; color: var(--muted); }

.select-wrap { display: flex; align-items: center; gap: 8px; }
select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.04); color: var(--text);
  outline: none; box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--card-border); background: rgba(255,255,255,0.04); color: var(--text); display: grid; place-items: center; }
.icon-btn i { width: 18px; height: 18px; color: var(--muted); }

.field.slider { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
input[type="range"] { accent-color: var(--primary); width: 100%; }

.level-row { display: flex; gap: 10px; align-items: center; }
.level-meter {
  flex: 1; height: 12px; border-radius: 999px; background: rgba(255,255,255,0.06); border: 1px solid var(--card-border);
  overflow: hidden; position: relative;
}
.level-fill { position: absolute; inset: 0 100% 0 0; background: linear-gradient(90deg, #1ee9ac, #ffcf4d, #ff6b6b); transition: inset 80ms linear; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.04); color: var(--text); font-weight: 600; letter-spacing: 0.2px; cursor: pointer;
  transform: translateZ(0);
  transition: transform 120ms ease, background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}
.btn i { width: 18px; height: 18px; }
.btn:hover { transform: translateY(-1px); background: rgba(255,255,255,0.06); box-shadow: 0 6px 16px rgba(0,0,0,0.25); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none; }

.btn.primary { border-color: rgba(124,92,255,0.35); background: linear-gradient(180deg, rgba(124,92,255,0.25), rgba(124,92,255,0.12)); }
.btn.success { border-color: rgba(35,209,139,0.35); background: linear-gradient(180deg, rgba(35,209,139,0.22), rgba(35,209,139,0.10)); }
.btn.warning { border-color: rgba(255,202,58,0.35); background: linear-gradient(180deg, rgba(255,202,58,0.22), rgba(255,202,58,0.10)); }
.btn.danger { border-color: rgba(255,93,93,0.35); background: linear-gradient(180deg, rgba(255,93,93,0.22), rgba(255,93,93,0.10)); }
.btn.info { border-color: rgba(58,191,255,0.35); background: linear-gradient(180deg, rgba(58,191,255,0.22), rgba(58,191,255,0.10)); }
.btn.subtle { background: rgba(255,255,255,0.03); }

.record-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.preview-actions { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }
.preview-actions .timer { margin-left: 0; }
.preview-actions #btnSource[hidden] { display: none; }
/* Inline trimming */
.trim-inline { padding: 12px; position: relative; margin-top: 12px; }
.trim-inline.busy { pointer-events: none; }
.preview-actions.busy { pointer-events: none; opacity: 0.7; }
.trim-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
/* unified busy overlay styles above */
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.modal-header h3 { margin: 0; font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.trim-body { display: grid; gap: 12px; }
.trim-body video { width: 100%; border-radius: 10px; background: #000; border: 1px solid var(--card-border); }
.trim-timeline { display: grid; gap: 8px; }
.trim-timeline .canvas-container { position: relative; }
.trim-timeline canvas { width: 100%; height: 84px; border-radius: 8px; background: rgba(255,255,255,0.04); border: 1px solid var(--card-border); display: block; }
.range { position: absolute; top: 1px; left: 1px; right: 1px; bottom: 1px; pointer-events: none; }
.range .selection { position: absolute; top: 0; height: 100%; background: rgba(124,92,255,0.15); border: 1px solid rgba(124,92,255,0.4); border-left: none; border-right: none; z-index: 0; pointer-events: none; }
.range .handle { position: absolute; top: 0; width: 8px; height: 100%; background: linear-gradient(180deg, rgba(124,92,255,0.8), rgba(124,92,255,0.5)); border-radius: 4px; cursor: ew-resize; display: grid; place-items: center; z-index: 1; pointer-events: auto; }
.range .handle .bubble { position: absolute; top: -28px; left: 0; padding: 4px 6px; font-size: 12px; border-radius: 6px; background: rgba(0,0,0,0.6); color: #fff; white-space: nowrap; z-index: 10; }
.range .handle.start { left: 0; }
.range .handle.end { left: auto; }
.range .playhead { position: absolute; top: 0; width: 2px; height: 100%; background: #fff; opacity: 0.8; z-index: 2; pointer-events: none; }
.time-rail { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.timer { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }

.download-link {
  margin-top: 12px; display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none;
  padding: 10px 12px; border-radius: 12px; border: 1px dashed var(--card-border); background: rgba(255,255,255,0.04);
}
.download-link i { width: 18px; height: 18px; color: var(--success); }

/* footer removed */

/* Audio Settings Panel */
.audio-settings {
  padding: 16px;
  animation-delay: 100ms;
  overflow: visible;
}

.audio-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.audio-settings-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.audio-settings-header h3 i {
  width: 16px;
  height: 16px;
  color: var(--info);
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  transition: all 200ms ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background: var(--muted);
  border-radius: 50%;
  transition: all 200ms ease;
}

.toggle-switch input:checked + .toggle-slider {
  background: rgba(35,209,139,0.2);
  border-color: rgba(35,209,139,0.4);
}

.toggle-switch input:checked + .toggle-slider::before {
  left: calc(100% - 19px);
  background: var(--success);
  box-shadow: 0 0 8px rgba(35,209,139,0.5);
}

.audio-settings-body {
  display: grid;
  gap: 14px;
}

.audio-settings-body.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Level meter - OBS style */
.level-section {
  display: grid;
  gap: 6px;
}

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

.level-db {
  font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  font-size: 11px;
  color: var(--text);
  min-width: 60px;
  text-align: right;
}

.level-meter-wrap {
  display: grid;
  gap: 4px;
}

.level-meter {
  position: relative;
  height: 20px;
  border-radius: 4px;
  background: linear-gradient(90deg, 
    rgba(0,0,0,0.4) 0%,
    rgba(0,0,0,0.4) 100%
  );
  border: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
}

.level-fill {
  position: absolute;
  inset: 2px;
  right: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg,
    #1ee9ac 0%,
    #1ee9ac 60%,
    #ffcf4d 75%,
    #ff6b6b 90%,
    #ff3d3d 100%
  );
  transition: right 50ms linear;
}

.level-peak {
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 3px;
  left: 0;
  background: #fff;
  border-radius: 1px;
  opacity: 0.9;
  transition: left 50ms linear, opacity 300ms ease;
  box-shadow: 0 0 6px rgba(255,255,255,0.5);
}

.level-ticks {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: none;
}

.level-ticks span {
  flex: 1;
  border-right: 1px solid rgba(255,255,255,0.1);
}

.level-ticks span:last-child {
  border-right: none;
}

.level-scale {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--muted);
  opacity: 0.7;
  padding: 0 2px;
}

/* Mute button in select row */
#btnMuteMic.muted {
  border-color: rgba(255,93,93,0.4);
  background: rgba(255,93,93,0.15);
}

#btnMuteMic.muted i {
  color: var(--danger);
}

.icon-btn {
  cursor: pointer;
  transition: all 150ms ease;
}

.icon-btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
}

/* Mic activity indicator on select */
.select-wrap {
  position: relative;
  display: flex;
  gap: 8px;
  align-items: center;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Custom select dropdown */
.custom-select {
  position: relative;
  flex: 1;
}

.custom-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: all 150ms ease;
}

.custom-select-trigger:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.15);
}

.custom-select-trigger:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(124,92,255,0.2);
}

.custom-select.open .custom-select-trigger {
  border-color: var(--primary);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.custom-select-value {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-arrow {
  width: 16px;
  height: 16px;
  color: var(--muted);
  transition: transform 200ms ease;
  flex-shrink: 0;
}

.custom-select.open .custom-select-arrow {
  transform: rotate(180deg);
}

.custom-select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(20, 25, 45, 0.98);
  backdrop-filter: blur(8px);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  max-height: 280px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all 150ms ease;
}

.custom-select.open .custom-select-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.custom-select.open .custom-select-trigger {
  border-color: var(--card-border);
  border-radius: 10px;
}

.custom-select-options {
  padding: 6px;
}

.custom-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  color: var(--text);
  cursor: pointer;
  border-radius: 6px;
  transition: all 100ms ease;
}

.custom-select-option:hover {
  background: rgba(255,255,255,0.06);
}

.custom-select-option.selected {
  background: rgba(35,209,139,0.15);
  color: var(--success);
}

.custom-select-option.selected::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.custom-select-option.selected:hover {
  background: rgba(35,209,139,0.2);
}

/* Scrollbar styling for dropdown */
.custom-select-dropdown::-webkit-scrollbar {
  width: 6px;
}

.custom-select-dropdown::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.05);
  border-radius: 3px;
}

.custom-select-dropdown::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
}

.custom-select-dropdown::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.3);
}

.mic-active-dot {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
  z-index: 2;
}

.mic-active-dot.active {
  opacity: 1;
  animation: pulse-mic 1.5s infinite;
}

/* Adjust trigger padding when dot is active */
.mic-active-dot.active ~ .custom-select-trigger {
  padding-left: 28px;
}

@keyframes pulse-mic {
  0% { box-shadow: 0 0 0 0 rgba(35, 209, 139, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(35, 209, 139, 0); }
  100% { box-shadow: 0 0 0 0 rgba(35, 209, 139, 0); }
}


