:root {
  --bg-color: #040507;
  --bg-gradient: radial-gradient(circle at 80% 20%, #110624 0%, #040507 65%, #000000 100%);
  --panel-bg: rgba(255, 255, 255, 0.08);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  --danger-color: #ef4444;
  --danger-hover: #dc2626;
  --success-color: #10b981;
  --border-radius-lg: 24px;
  --border-radius-md: 16px;
  --border-radius-sm: 12px;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.2);
  --shadow-danger: 0 0 20px rgba(239, 68, 68, 0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Glassmorphism Utilities */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.glass-panel-bottom {
  background: rgba(22, 24, 30, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

/* Layout */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
  position: relative;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo svg {
  width: 30px;
  height: 30px;
  color: #fff;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 8px rgba(255, 255, 255, 0.18));
}

.logo h1 {
  font-family: 'Barlow Condensed', -apple-system-condensed, sans-serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1;
}

.icon-btn {
  position: relative;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  color: var(--text-primary);
  background: var(--panel-bg);
}

/* Viewport Section */
.viewport-section {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 24px 24px 24px;
  position: relative;
  min-height: 0;
}

.video-container {
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--border-radius-lg);
  /* overflow: hidden removed — it clips the native video controls' hit-test region in WebKit/Blink,
     making the progress bar and controls bar unclickable. clip-path gives the same visual rounding
     without interfering with shadow-DOM event routing. */
  clip-path: inset(0 round var(--border-radius-lg));
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--bg-color);
  /* Ensure it doesn't shrink below zero */
  min-height: 0;
}

/* Preview off placeholder — camera/mic stopped to save resources */
.preview-off-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: rgba(0, 0, 0, 0.85);
  border-radius: var(--border-radius-lg);
}

.preview-off-message {
  margin: 0;
  font-size: 1rem;
  color: var(--text-secondary);
}

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* Prevent cropping, keep full 16:9 frame */
  border-radius: var(--border-radius-lg);
  /* Apply a slight scale for visual depth */
  transition: filter 0.3s ease;
}

/* No transforms to avoid browser rendering and click/hover offsets on native video controls */

/* Beauty Filter */
.beauty-filter {
  filter: blur(0.25px) brightness(1.05) contrast(0.95) saturate(1.1);
}



.state-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.6);
  padding: 12px 24px;
  border-radius: 30px;
  font-weight: 500;
  letter-spacing: 0.5px;
  backdrop-filter: blur(8px);
  animation: fadeIn 0.3s ease;
  pointer-events: none;
}

/* Turn off camera — same style/location as state overlay, appears on hover */
.preview-off-hover-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.6);
  padding: 12px 24px;
  border-radius: 30px;
  font-weight: 500;
  letter-spacing: 0.5px;
  backdrop-filter: blur(8px);
  color: var(--text-primary);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  visibility: hidden;
}

.video-container.preview-active.ready-dismissed:hover .preview-off-hover-overlay {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.preview-off-hover-overlay:hover {
  background: rgba(0, 0, 0, 0.75);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -40%);
  }

  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

/* Skip Indicators */
.skip-indicator {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 30%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden; /* Prevent overlay from blocking click/hover events on underlying native video controls */
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 5;
}

.skip-left {
  left: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.4) 0%, transparent 100%);
}

.skip-right {
  right: 0;
  background: linear-gradient(-90deg, rgba(0, 0, 0, 0.4) 0%, transparent 100%);
}

.skip-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.25rem;
  font-weight: 600;
  transform: scale(0.8);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.skip-indicator.show {
  opacity: 1;
  visibility: visible;
}

.skip-indicator.show .skip-circle {
  transform: scale(1);
  animation: pulse-skip 0.5s ease forwards;
}

@keyframes pulse-skip {
  0% {
    transform: scale(0.8);
  }

  50% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
  }
}

/* Recording Indicator */
.recording-indicator {
  position: absolute;
  top: 24px;
  left: 24px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  padding: 8px 16px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.red-dot {
  width: 10px;
  height: 10px;
  background-color: var(--danger-color);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--danger-color);
  animation: pulse-dot 1.5s infinite ease-in-out;
}

@keyframes pulse-dot {
  0% {
    transform: scale(0.95);
    opacity: 0.5;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }

  70% {
    transform: scale(1.1);
    opacity: 1;
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }

  100% {
    transform: scale(0.95);
    opacity: 0.5;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* Controls Section */
.controls-section {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
  z-index: 10;
  border-radius: var(--border-radius-lg);
  width: calc(100% - 48px);
  margin: 0 auto 24px auto;
}

/* ── Custom Seek Bar ─────────────────────────────────────── */
.seekbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0 4px;
}

.seek-time {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 36px;
}

#seek-duration {
  text-align: right;
}

.seekbar-track {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  position: relative;
  cursor: pointer;
  /* Increase hit-target without changing visual height */
  padding: 10px 0;
  margin: -10px 0;
}

.seekbar-buffered {
  position: absolute;
  top: 10px; /* offset to match padding */
  left: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 9999px;
  width: 0%;
  pointer-events: none;
}

.seekbar-progress {
  position: absolute;
  top: 10px;
  left: 0;
  height: 4px;
  background: var(--accent-color, #6c63ff);
  border-radius: 9999px;
  width: 0%;
  pointer-events: none;
}

.seekbar-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  transition: transform 0.1s ease;
}

.seekbar-track:hover .seekbar-thumb {
  transform: translate(-50%, -50%) scale(1.3);
}

.seekbar-track.seeking .seekbar-thumb {
  transform: translate(-50%, -50%) scale(1.3);
}


.device-selectors {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 4px 0 8px;
  line-height: 1.35;
}

.setting-group label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  padding-left: 4px;
}

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

.toggle-group label:first-child {
  padding-left: 0;
  margin-bottom: 0;
}

/* Toggle Switch Styles */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
}

input:checked+.slider {
  background-color: var(--accent-color);
}

input:focus+.slider {
  box-shadow: 0 0 1px var(--accent-color);
}

input:checked+.slider:before {
  transform: translateX(20px);
}

/* Rounded sliders */
.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

.select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius-md);
  padding: 0 12px;
  width: 100%;
  transition: var(--transition-fast);
}

.select-wrapper:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.select-wrapper svg {
  color: var(--text-secondary);
}

.select-wrapper .drop-icon {
  font-size: 16px;
  pointer-events: none;
}

select {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 12px 16px 12px 12px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  width: 100%;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

select option {
  background: var(--bg-color);
  color: var(--text-primary);
}

/* Action Buttons */
.primary-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 32px;
  height: 80px;
}

.action-btn {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  transition: var(--transition-normal);
  color: white;
}

.action-btn svg {
  /* Fix vertical alignment */
  display: flex;
}

/* Material Design Tooltips using aria-label */
.action-btn::after,
.icon-btn::after,
.record-btn::after {
  content: attr(aria-label);
  position: absolute;
  bottom: 115%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: rgba(33, 33, 33, 0.95);
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  z-index: 1000;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.action-btn:hover::after,
.icon-btn:hover::after,
.record-btn:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Position tooltips inside the header below the buttons to prevent screen cut-off */
.app-header .icon-btn::after {
  bottom: auto;
  top: 115%;
  transform: translateX(-50%) translateY(-4px);
}
.app-header .icon-btn:hover::after {
  transform: translateX(-50%) translateY(0);
}

.action-btn.secondary {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
}

.action-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.05);
}

/* Edit button — active state when panel is open */
#edit-btn[aria-expanded="true"] {
  background: var(--accent-color);
  box-shadow: var(--shadow-glow);
  color: #fff;
}

.action-btn.primary {
  background: var(--accent-color);
  box-shadow: var(--shadow-glow);
}

.action-btn.primary:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}

/* Record Button */
.record-btn {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: transparent;
  border: 4px solid var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-normal);
  padding: 0;
}

.record-btn-countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.record-btn-countdown.visible {
  opacity: 1;
}

.record-btn-inner {
  width: 54px;
  height: 54px;
  background: var(--danger-color);
  border-radius: 50%;
  transition: var(--transition-normal);
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

.record-btn:hover .record-btn-inner {
  transform: scale(0.9);
}

/* Recording State */
.record-btn.recording {
  border-color: rgba(255, 255, 255, 0.3);
}

.record-btn.recording .record-btn-inner {
  border-radius: 12px;
  transform: scale(0.6);
  box-shadow: var(--shadow-danger);
}

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

@media (max-width: 600px) {
  .app-header {
    padding: 16px;
  }

  .viewport-section {
    padding: 0 16px 16px 16px;
  }

  .controls-section {
    padding: 20px 16px;
  }

  .select-wrapper select {
    width: 130px;
    font-size: 13px;
  }

  .editing-card-body {
    padding: 12px 12px 16px;
  }

  .editing-card-body>.mdc-button {
    width: 100%;
  }
}

/* Settings Modal */
.settings-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 92%;
  max-width: 480px;
  max-height: min(88vh, 760px);
  background: var(--bg-color);
  border-radius: var(--border-radius-lg);
  padding: 20px 22px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
  animation: settings-fade-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  overflow: hidden;
}

@keyframes settings-fade-in {
  from { transform: translate(-50%, -46%) scale(0.95); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 14px;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.settings-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.settings-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

/* Custom sleek scrollbar for settings */
.settings-content::-webkit-scrollbar {
  width: 6px;
}
.settings-content::-webkit-scrollbar-track {
  background: transparent;
}
.settings-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 3px;
}
.settings-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Settings Section Cards */
.settings-card {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 0;
}

.settings-card:focus-within {
  border-color: rgba(191, 90, 242, 0.35);
}

.settings-card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--color-accent, #bf5af2);
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.settings-card-title svg {
  flex-shrink: 0;
  opacity: 0.9;
}

.settings-grid-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 440px) {
  .settings-grid-row {
    grid-template-columns: 1fr;
  }
}

.auth-legal-hint {
  margin-top: 8px;
  font-size: 11px;
  text-align: center;
  color: var(--text-secondary);
  line-height: 1.35;
}

.auth-legal-hint a {
  color: var(--color-accent, #bf5af2);
  text-decoration: underline;
}

.settings-actions {
  display: flex;
  justify-content: center;
  padding-top: 16px;
  border-top: 1px solid var(--panel-border);
}

#download-btn.disabled {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

#download-btn.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Edit panel: only takes space when expanded */
.editing-tools {
  margin-top: 0;
  padding-top: 0;
  border: none;
  min-height: 0;
  overflow: hidden;
  transition: margin-top 0.2s ease;
}

.editing-tools.editing-tools--expanded {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.editing-panel {
  margin-top: 0;
}

.editing-card {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 2px 6px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.editing-card-body {
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.mdc-field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mdc-field-group--row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.mdc-trim-row {
  display: flex;
  align-items: stretch;
  gap: 16px;
  flex-wrap: wrap;
}

.mdc-trim-row .mdc-text-field--outlined {
  display: flex;
  flex-direction: column;
  width: 88px;
  min-width: 88px;
}

.mdc-trim-row .mdc-floating-label {
  flex: 0 0 auto;
  margin-bottom: 6px;
  line-height: 1.2;
}

.mdc-trim-row .mdc-input {
  flex: 0 0 40px;
  width: 100%;
  box-sizing: border-box;
}

.trim-time-display {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  padding: 0 2px;
}

.trim-time-label {
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.trim-time-label span {
  color: var(--text-primary);
  opacity: 0.85;
  font-weight: 500;
}


.mdc-label {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
  opacity: 0.9;
}

.mdc-field-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.mdc-field-sep {
  color: var(--text-secondary);
  opacity: 0.6;
  font-weight: 500;
}

/* Outlined text field */
.mdc-text-field--outlined {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  min-width: 0;
}

.mdc-text-field--outlined .mdc-input {
  width: 80px;
  height: 40px;
  padding: 0 12px;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text-primary);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 4px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.mdc-text-field--outlined .mdc-input:hover {
  border-color: rgba(255, 255, 255, 0.5);
}

.mdc-text-field--outlined .mdc-input:focus {
  border-color: var(--accent-color);
  border-width: 2px;
  padding: 0 11px;
  box-shadow: 0 0 0 1px var(--accent-color);
}

.mdc-text-field--outlined .mdc-floating-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
  pointer-events: none;
}

.mdc-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.mdc-checkbox-wrap {
  position: relative;
  display: inline-flex;
}

.mdc-checkbox {
  position: absolute;
  opacity: 0;
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
}

.mdc-checkbox-box {
  position: relative;
  display: inline-flex;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 2px;
  background: transparent;
  transition: background 0.2s, border-color 0.2s;
}

.mdc-checkbox:checked+.mdc-checkbox-box {
  background: var(--accent-color);
  border-color: var(--accent-color);
}

.mdc-checkbox:focus-visible+.mdc-checkbox-box {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}

.mdc-checkbox-box::after {
  content: '';
  position: absolute;
  display: none;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.mdc-checkbox:checked+.mdc-checkbox-box::after {
  display: block;
}

.mdc-checkbox-text {
  font-size: 0.875rem;
  color: var(--text-primary);
}

/* Filled button (Material primary) */
.mdc-button {
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  transition: box-shadow 0.2s, background 0.2s;
}

.mdc-button--filled {
  height: 40px;
  padding: 0 24px;
  background: var(--accent-color);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.mdc-button--filled:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

.mdc-button--filled:active {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.mdc-button--filled:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  box-shadow: none;
}

.mdc-button--filled.is-processing,
.mdc-button--filled.is-processing:disabled {
  opacity: 1;
  cursor: wait;
  background: linear-gradient(
    90deg,
    var(--accent-hover, #2563eb) 0%,
    var(--accent-hover, #2563eb) var(--progress, 0%),
    rgba(255, 255, 255, 0.15) var(--progress, 0%),
    rgba(255, 255, 255, 0.15) 100%
  );
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
  transition: background 0.1s linear;
}

.editing-card-body>.mdc-button {
  margin-top: 4px;
}

/* YouTube modal */
.youtube-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 400px;
  background: var(--bg-color);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--panel-border);
}

.youtube-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  outline: none;
  box-sizing: border-box;
}

.youtube-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.youtube-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

.youtube-status {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 16px 0;
  min-height: 1.2em;
  transition: color 0.2s;
}

.youtube-status--success {
  display: none;
  /* We use a dedicated success view now */
}

.youtube-status--error {
  color: #ef5350;
  font-weight: 500;
}

.success-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1rem 0;
}

.success-icon-wrapper {
  background: rgba(76, 175, 80, 0.1);
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.success-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  color: var(--text-primary);
}

.success-message {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Modal Overlay logic via JS */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

/* Google Sign-in Styles */
.auth-card {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-title {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 0;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.auth-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.4;
}

.auth-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

#google-login-btn {
  margin-top: 4px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 1rem;
  text-align: left;
}

.user-photo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--accent-color);
}

.user-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.google-signin-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: white;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 24px;
  padding: 10px 24px;
  font-family: 'Google Sans', Roboto, Arial, sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  width: auto;
  min-width: 200px;
  margin: 0 auto;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.google-signin-btn:hover {
  background-color: #f7f8f8;
  border-color: #d2dce0;
  box-shadow: 0 1px 3px 1px rgba(60, 64, 67, 0.15), 0 1px 2px 0 rgba(60, 64, 67, 0.30);
  transform: translateY(-1px);
}

.google-signin-btn:active {
  background-color: #f1f3f4;
  transform: translateY(0);
}

.google-signin-btn svg {
  flex-shrink: 0;
}

.signout-btn {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #ef4444;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.signout-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
}

.progress-container {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  margin: 12px 0 20px;
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--accent-color);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
  transition: width 0.3s ease;
}

/* Trim Timeline Styles */
.trim-timeline-container {
  padding: 12px 10px 24px;
  width: 100%;
  box-sizing: border-box;
}

.trim-timeline {
  position: relative;
  width: 100%;
  height: 48px;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  cursor: pointer;
}

.trim-filmstrip {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: none;
  opacity: 0.6;
}

.trim-filmstrip img {
  height: 100%;
  flex: 1;
  object-fit: cover;
  min-width: 0;
}


.trim-active-range {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(59, 130, 246, 0.3);
  border: 2px solid var(--accent-color);
  border-top: none;
  border-bottom: none;
  box-sizing: border-box;
  pointer-events: none;
  z-index: 3;
}

.trim-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 12px;
  background: var(--accent-color);
  cursor: grab;
  z-index: 100;
  transition: background 0.2s, width 0.2s;
  outline: none;
  transform: translateX(-50%);
  pointer-events: auto;
}

.trim-handle:hover,
.trim-handle:focus {
  background: #fff;
  width: 16px;
}

.trim-handle::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 16px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 1px;
}

.trim-handle:active {
  cursor: grabbing;
  background: #fff;
}

/* Increase hit area significantly */
.trim-handle::after {
  content: '';
  position: absolute;
  top: 0;
  left: -15px;
  right: -15px;
  bottom: 0;
}

.trim-handle--start {
  border-radius: 4px 0 0 4px;
}

.trim-handle--end {
  border-radius: 0 4px 4px 0;
}

/* Snackbar (Toast) System */
.snackbar-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 320px;
  /* MD3 standard */
  align-items: center;
}

.snackbar {
  background: #323232;
  color: rgba(255, 255, 255, 0.9);
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 0.875rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: auto;
  animation: snackbar-in-center 0.3s cubic-bezier(0, 0, 0.2, 1);
  transform-origin: bottom center;
  border-left: 4px solid var(--accent-color);
  min-width: 250px;
}

.snackbar--success {
  border-left-color: #4caf50;
}

.snackbar--error {
  border-left-color: #ef5350;
}

.snackbar.fade-out {
  animation: snackbar-out 0.2s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes snackbar-in-center {
  from {
    transform: translateY(100%) scale(0.9);
    opacity: 0;
  }

  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes snackbar-in-left {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes snackbar-out {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

/* Material Design 3: Desktop is bottom-left */
@media (min-width: 601px) {
  .snackbar-container {
    left: 24px;
    bottom: 24px;
    transform: none;
    align-items: flex-start;
  }

  .snackbar {
    animation-name: snackbar-in-left;
  }
}

@media (max-width: 600px) {
  .snackbar-container {
    bottom: 80px;
    /* Above mobile navigation */
  }
}

/* Device & Audio Status Overlay (Draggable) */
.device-status-overlay {
  position: absolute;
  top: 24px;
  right: 24px;
  background: rgba(10, 10, 12, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--border-radius-md);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 15;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  width: 260px;
  max-width: calc(100% - 24px);
  transition: opacity var(--transition-normal), visibility var(--transition-normal), box-shadow 0.2s ease, border-color 0.2s ease;
  color: var(--text-primary);
  pointer-events: auto; /* Enable dragging & interaction */
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.device-status-overlay:hover {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.5);
}

.device-status-overlay.is-dragging {
  cursor: grabbing;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
  border-color: var(--accent-color);
  opacity: 0.95;
  transition: none !important;
}

.device-status-header {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 6px;
}

.drag-hint {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  opacity: 0.75;
  padding: 3px 5px;
  border-radius: 4px;
  transition: opacity var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}

.device-status-overlay:hover .drag-hint {
  opacity: 1;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.green-pulse {
  background-color: var(--success-color);
  box-shadow: 0 0 8px var(--success-color);
  animation: pulse-green-glow 2s infinite ease-in-out;
}

@keyframes pulse-green-glow {
  0% { transform: scale(0.95); opacity: 0.6; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.05); opacity: 1; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); opacity: 0.6; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.status-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  color: var(--text-secondary);
}

.device-info-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.device-info-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.device-info-icon {
  flex-shrink: 0;
  color: var(--accent-color);
}

.device-info-text {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audio-meter-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
}

.audio-meter-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.audio-meter-level {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background-color: var(--success-color);
  transition: width 0.05s ease, background-color 0.1s ease, box-shadow 0.1s ease;
}

.audio-meter-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.audio-meter-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.audio-clip-indicator {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 1px 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  opacity: 0.4;
  transition: all 0.1s ease;
}

.audio-clip-indicator.is-clipping {
  background: var(--danger-color, #ef4444);
  color: #ffffff;
  opacity: 1;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
  animation: pulse-clip 0.3s ease-in-out infinite alternate;
}

@keyframes pulse-clip {
  from { opacity: 0.85; }
  to { opacity: 1; }
}

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

.setting-value-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-accent, #bf5af2);
  background: rgba(191, 90, 242, 0.15);
  padding: 2px 8px;
  border-radius: 10px;
}

.slider-wrapper {
  display: flex;
  align-items: center;
  padding: 4px 0;
}

.slider-wrapper input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
  transition: background 0.2s ease;
}

.slider-wrapper input[type="range"]:hover {
  background: rgba(255, 255, 255, 0.25);
}

.slider-wrapper input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-accent, #bf5af2);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(191, 90, 242, 0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.slider-wrapper input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(191, 90, 242, 0.8);
}

.slider-wrapper input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-accent, #bf5af2);
  cursor: pointer;
  border: none;
  box-shadow: 0 0 8px rgba(191, 90, 242, 0.5);
}

@media (max-width: 600px) {
  .device-status-overlay {
    top: 12px;
    right: 12px;
    padding: 8px 12px;
    width: calc(100% - 24px);
    max-width: 220px;
    gap: 6px;
  }
  .device-status-header {
    padding-bottom: 4px;
    gap: 6px;
  }
  .device-info-row {
    gap: 4px;
  }
  .device-info-text {
    font-size: 10px;
  }
  .audio-meter-label {
    font-size: 8px;
  }
}

/* App Footer (Google Compliance) */
.app-footer {
  text-align: center;
  padding: 8px 0 16px 0;
  display: flex;
  justify-content: center;
  gap: 16px;
  z-index: 10;
}
.app-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 12px 8px; /* Tap target compliance */
  display: inline-block;
  font-size: 12px;
  transition: color var(--transition-fast);
}
.app-footer a:hover {
  color: var(--color-accent, #bf5af2);
  text-decoration: underline;
}

/* Custom focus states for keyboard users (Material 3 standard) */
a:focus-visible, 
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--color-accent, #bf5af2);
  outline-offset: 4px;
  border-radius: 4px;
}