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

:root {
  --primary: #007AFF;
  --secondary: #5856D6;
  --success: #34C759;
  --warning: #FF9500;
  --danger: #FF3B30;
  --bg-primary: rgba(0, 0, 0, 0.85);
  --bg-secondary: rgba(255, 255, 255, 0.1);
  --bg-blur: rgba(255, 255, 255, 0.95);
  --text-primary: #FFFFFF;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --border: rgba(255, 255, 255, 0.15);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #000;
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
}

#app {
  position: relative;
  width: 100%;
  height: 100vh;
}

#app.dragging::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 122, 255, 0.1);
  border: 3px dashed var(--primary);
  z-index: 10000;
  pointer-events: none;
}

.video-container {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.video-player {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
}

.video-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  color: var(--text-secondary);
}

.video-placeholder svg {
  opacity: 0.3;
}

.overlay-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}

.overlay-ui > * {
  pointer-events: auto;
}

.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 20px 30px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
  display: flex;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.app-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  font-weight: 600;
}

.top-controls {
  display: flex;
  gap: 12px;
}

.icon-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.02);
}

.icon-button.gpu-active {
  background: var(--primary);
  border-color: var(--primary);
}

.device-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.caption-panel {
  position: absolute;
  right: -400px;
  top: 0;
  bottom: 0;
  width: 400px;
  background: var(--bg-blur);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border-left: 1px solid var(--border);
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  color: #000;
}

.caption-panel.active {
  right: 0;
}

.panel-header {
  padding: 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.close-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: rgba(0, 0, 0, 0.05);
  color: #000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.close-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

.analysis-settings {
  padding: 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.setting-group {
  margin-bottom: 20px;
}

.setting-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: rgba(0, 0, 0, 0.6);
}

.slider {
  width: calc(100% - 40px);
  height: 4px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.1);
  outline: none;
  -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: var(--primary);
  cursor: pointer;
}

.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: var(--primary);
  cursor: pointer;
  border: none;
}

.setting-group span {
  display: inline-block;
  margin-left: 10px;
  font-weight: 600;
  color: var(--primary);
}

.analyze-btn {
  margin: 0 20px;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s;
}

.analyze-btn:hover:not(:disabled) {
  background: #0051D5;
  transform: scale(1.02);
}

.analyze-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.results-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.summary-section {
  margin-bottom: 30px;
  padding: 16px;
  background: rgba(0, 122, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(0, 122, 255, 0.1);
}

.summary-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--primary);
}

.summary-section p {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(0, 0, 0, 0.8);
}

.frames-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: rgba(0, 0, 0, 0.8);
}

.frame-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.frame-item {
  padding: 12px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.frame-time {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
}

.frame-description {
  font-size: 14px;
  line-height: 1.5;
  color: rgba(0, 0, 0, 0.7);
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.loading-content {
  text-align: center;
  max-width: 300px;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#loadingText {
  font-size: 16px;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

.error-message {
  padding: 20px;
  background: rgba(255, 59, 48, 0.1);
  border: 1px solid rgba(255, 59, 48, 0.2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--danger);
}

.error-message svg {
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .caption-panel {
    width: 100%;
    right: -100%;
  }
  
  .top-bar {
    padding: 15px;
  }
  
  .app-title span {
    display: none;
  }
  
  .device-label {
    display: none;
  }
}