/* Import modern typography from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  /* Design Tokens */
  --bg-deep: #07080d;
  --bg-main: #0c0e17;
  --bg-panel: rgba(20, 24, 40, 0.65);
  --bg-panel-hover: rgba(30, 36, 60, 0.8);
  --bg-card: rgba(14, 17, 29, 0.8);
  --border-color: rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.12);
  
  /* Cyber Accent Palette */
  --purple: #8b5cf6;
  --purple-glow: rgba(139, 92, 246, 0.25);
  --cyan: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.25);
  
  /* Diagnostic Colors */
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.15);
  --duplicate-blue: #3b82f6;
  --duplicate-blue-glow: rgba(59, 130, 246, 0.15);
  
  /* Text colors */
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --text-dim: #4b5563;
  
  /* Layout Constants */
  --sidebar-width: clamp(300px, 28vw, 380px);
  --header-height: 70px;
  --timeline-height: clamp(280px, 36vh, 430px);
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Global */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, .font-heading {
  font-family: 'Outfit', sans-serif;
  letter-spacing: -0.01em;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

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

/* Header Container */
header {
  height: var(--header-height);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: rgba(12, 14, 23, 0.8);
  backdrop-filter: blur(8px);
  z-index: 10;
  flex-shrink: 0;
}

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

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--purple), var(--cyan));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px var(--purple-glow);
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  font-family: 'Outfit', sans-serif;
}

.logo-text h1 {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(to right, #ffffff, #cfd3ec);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text span {
  font-size: 11px;
  color: var(--cyan);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  transition: var(--transition-normal);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  box-shadow: 0 0 8px rgba(107, 114, 128, 0.5);
}

.status-dot.active {
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  animation: pulse-cyan 2s infinite;
}

.status-dot.success {
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
}

.status-dot.processing {
  background: var(--purple);
  box-shadow: 0 0 10px var(--purple);
  animation: pulse-purple 1.5s infinite;
}

/* App Main Container */
.app-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
  height: calc(100vh - var(--header-height));
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  border-right: 1px solid var(--border-color);
  background: rgba(9, 10, 18, 0.85);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  min-height: 0;
  z-index: 5;
}

.sidebar-section {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sidebar > .sidebar-section:nth-of-type(2) {
  background: rgba(9, 10, 18, 0.98);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
  position: sticky;
  top: 0;
  z-index: 7;
}

.sidebar > .sidebar-section:nth-of-type(3) {
  flex: 0 0 auto !important;
  min-height: 0;
  display: flex !important;
  flex-direction: column !important;
  overflow: visible !important;
}

.sidebar > .sidebar-section:nth-of-type(3) h3,
.sidebar > .sidebar-section:nth-of-type(3) .diagnostic-stats {
  flex-shrink: 0;
}

#anomaly-list-container {
  flex: 0 0 auto;
  min-height: 0;
  max-height: 0;
  margin-top: 0;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: max-height var(--transition-normal), opacity var(--transition-fast), margin-top var(--transition-fast);
}

.sidebar.anomaly-list-expanded #anomaly-list-container {
  max-height: min(340px, 34vh);
  margin-top: 10px;
  opacity: 1;
  pointer-events: auto;
}

.sidebar-section h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 16px;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* File Upload Controls */
.upload-zone {
  border: 2px dashed rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.01);
  transition: var(--transition-normal);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.upload-zone:hover {
  border-color: var(--purple);
  background: rgba(139, 92, 246, 0.03);
  box-shadow: inset 0 0 12px rgba(139, 92, 246, 0.05);
}

.upload-zone.dragover {
  border-color: var(--cyan);
  background: rgba(6, 182, 212, 0.05);
  box-shadow: 0 0 20px var(--cyan-glow);
}

.upload-icon {
  font-size: 32px;
  background: linear-gradient(135deg, var(--purple), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.upload-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.upload-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.upload-buttons {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-top: 10px;
}

.btn-file-select {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 11px;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  font-weight: 500;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.btn-file-select:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-light);
}

select.btn-file-select {
  appearance: none;
  display: block;
  background-color: #151722;
  color: var(--text-primary);
  color-scheme: dark;
}

select.btn-file-select option {
  background-color: #151722;
  color: #f8fafc;
}

.playback-fps-select {
  width: 104px;
  max-width: 104px;
  padding: 7px 28px 7px 10px;
}

.source-fps-setting {
  display: grid;
  grid-template-columns: 1fr 82px;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.source-fps-setting label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
}

.source-fps-setting select {
  width: 82px;
  padding: 6px;
}

/* Sliders and parameters */
.parameter-group {
  margin-bottom: 16px;
}

.parameter-group:last-child {
  margin-bottom: 0;
}

.parameter-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
}

.parameter-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.parameter-value {
  color: var(--cyan);
  font-family: monospace;
  font-weight: 600;
}

.parameter-input {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
  transition: var(--transition-fast);
}

.parameter-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--purple);
  box-shadow: 0 0 6px var(--purple);
  cursor: pointer;
  transition: var(--transition-fast);
}

.parameter-input::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: #fff;
}

.parameter-desc {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

/* Diagnostic Reports List */
.diagnostic-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.btn-list-toggle {
  width: 100%;
  min-height: 34px;
  border: 1px solid rgba(139, 92, 246, 0.28);
  background: rgba(139, 92, 246, 0.07);
  color: var(--text-primary);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-list-toggle:hover:not(:disabled) {
  background: rgba(139, 92, 246, 0.14);
  border-color: rgba(139, 92, 246, 0.5);
}

.btn-list-toggle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.stat-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  transition: var(--transition-fast);
}

.stat-card.has-issues.duplicates {
  border-color: rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.02);
}

.stat-card.has-issues.jumps {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.03);
}

.stat-num {
  font-size: 20px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
}

.stat-num.dup-color {
  color: var(--duplicate-blue);
}

.stat-num.jump-color {
  color: var(--warning);
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-top: 2px;
}

.compare-report {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.compare-report.empty {
  color: var(--text-muted);
}

.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.compare-metric {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.16);
}

.compare-metric-value {
  color: var(--cyan);
  font-family: monospace;
  font-size: 15px;
  font-weight: 700;
}

.compare-metric-label {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.compare-summary.good { color: var(--success); }
.compare-summary.warn { color: var(--warning); }
.compare-summary.bad { color: var(--danger); }

.report-list {
  max-height: 250px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-radius: 8px;
}

.report-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 12px;
}

.report-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}

.report-item.active {
  border-color: var(--purple);
  background: rgba(139, 92, 246, 0.05);
}

.report-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.report-dot.duplicate {
  background: var(--duplicate-blue);
  box-shadow: 0 0 6px var(--duplicate-blue);
}

.report-dot.jump {
  background: var(--warning);
  box-shadow: 0 0 6px var(--warning);
}

.report-dot.repaired {
  background: var(--purple);
  box-shadow: 0 0 6px var(--purple);
}

.report-details {
  flex: 1;
}

.report-title {
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
}

.report-frame {
  color: var(--cyan);
  font-family: monospace;
}

.report-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.empty-reports {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.01);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
}

/* Action Buttons */
.action-suite {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-action {
  width: 100%;
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-normal);
  border: none;
}

.btn-action.primary {
  background: linear-gradient(135deg, var(--purple), var(--cyan));
  color: #fff;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.25);
}

.btn-action.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35);
  background: linear-gradient(135deg, #9b72f8, #1bc1df);
}

.btn-action.primary:disabled {
  background: var(--text-dim);
  box-shadow: none;
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-action.secondary {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-action.secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-action.secondary:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-danger-outline {
  border: 1px solid rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.02);
  color: var(--danger);
}

.btn-danger-outline:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.08);
  border-color: var(--danger);
}

.btn-warning-outline {
  border: 1px solid rgba(245, 158, 11, 0.24);
  background: rgba(245, 158, 11, 0.03);
  color: var(--warning);
}

.btn-warning-outline:hover:not(:disabled) {
  background: rgba(245, 158, 11, 0.09);
  border-color: var(--warning);
}

/* Main Area Layout */
.main-stage {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
  position: relative;
  overflow: hidden;
}

/* Visual Stage Panel (Top of Main) */
.visual-stage {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  padding: 18px;
  overflow: hidden;
  gap: 18px;
}

.visual-stage.split-mode {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
}

/* Playback Monitor (Canvas Viewport) */
.monitor-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  overflow: hidden;
}

.viewport-container {
  flex: 1;
  background: #040508;
  border-radius: 12px 12px 0 0;
  border: 1px solid var(--border-color);
  border-bottom: none;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: inset 0 4px 20px rgba(0, 0, 0, 0.6);
}

.viewport-canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  background-size: 20px 20px;
  background-image: 
    linear-gradient(to right, rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.02) 1px, transparent 1px);
}

.viewport-indicator {
  position: absolute;
  top: 16px;
  left: 16px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-family: monospace;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.indicator-bullet {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--purple);
}

.onion-opacity-control {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 250px;
  pointer-events: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  z-index: 4;
}

.onion-opacity-control span {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  white-space: nowrap;
}

/* Playback Control Bar */
.control-bar {
  height: 64px;
  background: rgba(12, 14, 23, 0.95);
  border: 1px solid var(--border-color);
  border-radius: 0 0 12px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  font-size: 14px;
}

.control-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--cyan);
}

.control-btn.active {
  background: var(--purple-glow);
  border-color: var(--purple);
  color: var(--purple);
}

.control-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.control-btn.play-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--cyan));
  color: #fff;
  border: none;
  font-size: 16px;
  box-shadow: 0 0 12px var(--purple-glow);
}

.control-btn.play-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.5);
  color: #fff;
}

.control-time {
  font-family: monospace;
  font-size: 13px;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  display: flex;
  gap: 4px;
}

.control-time-current {
  color: var(--cyan);
  font-weight: 600;
}

.control-time-total {
  color: var(--text-muted);
}

/* Detail Inspection (Right Side Split) */
.inspection-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.inspection-panel h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.inspection-card {
  flex: 1;
  background: rgba(12, 14, 23, 0.5);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.inspector-split {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.inspector-thumb-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inspector-thumb-title {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
  display: flex;
  justify-content: space-between;
}

.inspector-canvas-wrapper {
  aspect-ratio: 1.5;
  background: #000;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inspector-thumb-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.anomalies-fixing-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
}

.anomaly-type-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.anomaly-type-title.duplicate {
  color: var(--duplicate-blue);
}

.anomaly-type-title.jump {
  color: var(--warning);
}

.anomaly-type-title.repaired {
  color: var(--purple);
}

.anomaly-action-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 12px;
}

/* Bottom Timeline */
.timeline-panel {
  height: var(--timeline-height);
  border-top: 1px solid var(--border-color);
  background: rgba(10, 11, 20, 0.95);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  user-select: none;
}

.timeline-header {
  min-height: 38px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(0, 0, 0, 0.15);
}

.timeline-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.timeline-view-toggle {
  flex-shrink: 0;
  margin-left: auto;
  margin-right: 18px;
}

.timeline-max-btn {
  flex-shrink: 0;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-fast);
}

.timeline-max-btn:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: rgba(34, 211, 238, 0.45);
  background: rgba(34, 211, 238, 0.08);
}

.timeline-max-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.stack-scale-control {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
}

.stack-scale-control.hidden {
  display: none;
}

.stack-control-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.stack-control-row label {
  min-width: 44px;
}

.stack-scale-control input {
  width: 108px;
  accent-color: var(--purple);
}

.stack-scale-control span {
  min-width: 40px;
  color: var(--cyan);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 10px;
  text-align: right;
}

.timeline-legend {
  display: flex;
  gap: 16px;
  font-size: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.legend-dot.normal { background: var(--success); }
.legend-dot.low { background: var(--warning); }
.legend-dot.duplicate { background: var(--duplicate-blue); }
.legend-dot.jump { background: var(--warning); }
.legend-dot.repaired { background: var(--purple); }
.legend-dot.compare {
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.65);
}

.timeline-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  padding: 10px 20px 14px;
  display: flex;
  flex-direction: column;
}

.timeline-canvas-container {
  flex: 1;
  position: relative;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.timeline-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: ew-resize;
}

.timeline-legend.hidden,
.timeline-canvas-container.hidden,
.frame-grid-container.hidden,
.temporal-stack-container.hidden {
  display: none;
}

.frame-grid-container {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  padding: 12px;
}

.frame-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 7px;
}

.frame-tile {
  position: relative;
  min-width: 0;
  aspect-ratio: 1 / 1;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: rgba(8, 9, 16, 0.88);
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.frame-tile:hover {
  border-color: rgba(34, 211, 238, 0.55);
  transform: translateY(-1px);
}

.frame-tile.duplicate {
  border-color: var(--purple);
  box-shadow: 0 0 0 1px var(--purple), 0 0 14px rgba(139, 92, 246, 0.35);
}

.frame-tile.jump {
  border-color: rgba(245, 158, 11, 0.95);
}

.frame-tile.active {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px var(--cyan), 0 0 18px rgba(34, 211, 238, 0.45);
}

.frame-tile.duplicate.active {
  border-color: var(--purple);
  box-shadow: 0 0 0 1px var(--cyan), 0 0 0 3px rgba(139, 92, 246, 0.55), 0 0 18px rgba(34, 211, 238, 0.4);
}

.frame-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}

.frame-tile-index,
.frame-tile-badge {
  position: absolute;
  left: 4px;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 8px;
  line-height: 1;
  color: #eef2ff;
  background: rgba(0, 0, 0, 0.72);
}

.frame-tile-index {
  bottom: 4px;
}

.frame-tile-badge {
  top: 4px;
  color: #f3e8ff;
  background: rgba(88, 28, 135, 0.9);
}

.temporal-stack-container {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: #000;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.temporal-stack-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.main-stage.timeline-maximized .viewport-container,
.main-stage.timeline-maximized .inspection-panel {
  display: none;
}

.main-stage.timeline-maximized .monitor-panel {
  display: block;
  height: auto;
  overflow: visible;
}

.main-stage.timeline-maximized .visual-stage {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 30;
  width: min(760px, calc(100% - 56px));
  height: auto;
  flex: none;
  display: block;
  padding: 0;
  overflow: visible;
  pointer-events: none;
}

.main-stage.timeline-maximized .viewer-panel {
  height: auto;
  overflow: visible;
}

.main-stage.timeline-maximized .control-bar {
  min-height: 54px;
  height: auto;
  border-radius: 12px;
  padding: 8px 12px;
  background: rgba(8, 10, 18, 0.88);
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.42);
  pointer-events: auto;
}

.main-stage.timeline-maximized .timeline-panel {
  flex: 1;
  height: auto;
  min-height: 0;
}

.main-stage.timeline-maximized .timeline-body {
  padding-bottom: 16px;
}

/* Playback Overlay Screen & Drop Area */
.full-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(7, 8, 13, 0.95);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: var(--transition-slow);
}

.full-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-content {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
}

.overlay-hero {
  text-align: center;
}

.overlay-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--purple), var(--cyan));
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 32px var(--purple-glow);
  font-weight: 800;
  font-size: 32px;
  color: #fff;
  font-family: 'Outfit', sans-serif;
  margin-bottom: 20px;
}

.overlay-title {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(to right, #ffffff, #9ca3af);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.overlay-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Loader Screen Overlay */
.loader-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(7, 8, 13, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-normal);
}

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

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border-color);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
  box-shadow: 0 0 16px var(--purple-glow);
}

.loader-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.loader-subtext {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-family: monospace;
}

.progress-container {
  width: 280px;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, var(--purple), var(--cyan));
  box-shadow: 0 0 10px var(--cyan);
  transition: width 0.1s ease;
}

/* Custom UI Layout Utilities */
.view-mode-selector {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.view-mode-btn {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition-fast);
}

.view-mode-btn:hover {
  color: var(--text-primary);
}

.view-mode-btn.active {
  background: var(--purple);
  color: #fff;
  box-shadow: 0 2px 8px var(--purple-glow);
}

@media (max-width: 1100px) {
  .timeline-header {
    min-height: 64px;
    flex-wrap: wrap;
    align-content: center;
    gap: 8px 12px;
    padding: 8px 14px;
  }

  .timeline-view-toggle {
    margin-left: 0;
    margin-right: 0;
  }

  .timeline-legend {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .frame-grid {
    grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  }
}

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

@keyframes pulse-cyan {
  0% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(6, 182, 212, 0); }
  100% { box-shadow: 0 0 0 0 rgba(6, 182, 212, 0); }
}

@keyframes pulse-purple {
  0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(139, 92, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

/* Custom Checkbox styles for interactive elements */
.custom-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

.custom-checkbox input {
  display: none;
}

.checkbox-box {
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.custom-checkbox:hover .checkbox-box {
  border-color: var(--purple);
}

.custom-checkbox input:checked + .checkbox-box {
  background: var(--purple);
  border-color: var(--purple);
}

.custom-checkbox input:checked + .checkbox-box::after {
  content: "✓";
  color: #fff;
  font-size: 10px;
  font-weight: bold;
}

/* Mock Generator Panel in sidebar */
.mock-generator-panel {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.05), rgba(6, 182, 212, 0.05));
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: 8px;
  padding: 14px;
}

.mock-generator-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 12px;
}

/* Patient loading warning notice */
.loader-warning {
  margin-top: 24px;
  font-size: 12px;
  color: #f59e0b; /* Amber warning color */
  text-align: center;
  max-width: 320px;
  line-height: 1.5;
  background: rgba(245, 158, 11, 0.05);
  border: 1px solid rgba(245, 158, 11, 0.2);
  padding: 8px 16px;
  border-radius: 8px;
  animation: pulse-opacity-warning 2.5s infinite ease-in-out;
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-height: 820px) {
  :root {
    --header-height: 58px;
    --timeline-height: clamp(220px, 34vh, 320px);
  }

  header {
    padding: 0 16px;
  }

  .logo-icon {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }

  .logo-text h1 {
    font-size: 17px;
  }

  .logo-text span {
    display: none;
  }

  .sidebar-section {
    padding: 12px 16px;
  }

  .sidebar-section h3 {
    margin-bottom: 9px;
    font-size: 11px;
  }

  .parameter-group {
    margin-bottom: 10px;
  }

  .parameter-desc {
    display: none;
  }

  .diagnostic-stats {
    margin-bottom: 8px;
  }

  .stat-card {
    padding: 7px 8px;
  }

  .stat-num {
    font-size: 17px;
    line-height: 1;
  }

  .stat-label {
    font-size: 9px;
  }

  .btn-action {
    min-height: 34px;
    padding: 8px 12px;
    font-size: 12px;
  }

  .action-suite {
    gap: 7px;
  }

  .visual-stage {
    padding: 14px;
    gap: 14px;
  }

  .control-bar {
    height: 54px;
    padding: 0 12px;
  }

  .inspection-card {
    padding: 12px;
    gap: 12px;
  }
}

@media (max-height: 680px) {
  :root {
    --timeline-height: 210px;
  }

  .sidebar > .sidebar-section:nth-of-type(1) {
    display: none;
  }

  .sidebar > .sidebar-section:nth-of-type(3) {
    min-height: 0;
  }

  .report-desc,
  .empty-reports {
    display: none;
  }
}

@keyframes pulse-opacity-warning {
  0%, 100% { opacity: 0.65; transform: scale(0.99); }
  50% { opacity: 1.0; transform: scale(1.01); }
}
