@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,400;0,500;0,700;1,400&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bg-primary: #07090e;
  --bg-secondary: #0d1117;
  --bg-tertiary: #161b22;
  --bg-card: rgba(22, 27, 34, 0.75);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(0, 255, 242, 0.35);
  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  --text-muted: #535d6c;
  --accent-cyan: #00fff2;
  --accent-blue: #0077ff;
  --accent-orange: #ff6a00;
  --accent-gold: #ffd000;
  --accent-emerald: #00ff88;
  --accent-purple: #b34eff;
  --accent-red: #ff3366;
  --glow-cyan: 0 0 25px rgba(0, 255, 242, 0.25);
  --glow-orange: 0 0 25px rgba(255, 106, 0, 0.25);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: #21262d;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #30363d;
}

/* Header */
.app-header {
  height: 54px;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 50;
  flex-shrink: 0;
}

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

.brand-logo {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--glow-cyan);
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #ffffff, var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-tag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(0, 255, 242, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 255, 242, 0.25);
}

/* Toolbar Controls */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-btn {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.tool-btn:hover {
  background: #21262d;
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.tool-btn.primary {
  background: linear-gradient(135deg, #00b4d8, #0077ff);
  color: #fff;
  border: none;
  box-shadow: 0 2px 10px rgba(0, 119, 255, 0.35);
}

.tool-btn.primary:hover {
  background: linear-gradient(135deg, #00c6eb, #0088ff);
  box-shadow: 0 4px 15px rgba(0, 119, 255, 0.5);
}

.tool-btn.accent-orange {
  background: linear-gradient(135deg, #ff8c00, #ff4500);
  color: #fff;
  border: none;
  box-shadow: 0 2px 10px rgba(255, 69, 0, 0.35);
}

.tool-btn.accent-purple {
  background: linear-gradient(135deg, #9d4edd, #7b2cbf);
  color: #fff;
  border: none;
}

.tool-select {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

.tool-select:focus {
  border-color: var(--accent-cyan);
}

/* App Main Container */
.app-workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* Left Panel: Code & Revision Hub */
.panel-editor {
  width: 50%;
  min-width: 380px;
  max-width: 65%;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Panel Header Tabs */
.editor-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.tab-group {
  display: flex;
  gap: 4px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  font-family: inherit;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  color: var(--accent-cyan);
  background: rgba(0, 255, 242, 0.1);
  border: 1px solid rgba(0, 255, 242, 0.25);
}

.editor-status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.status-dot.compiling {
  background: var(--accent-gold);
  box-shadow: 0 0 8px var(--accent-gold);
}

.status-dot.error {
  background: var(--accent-red);
  box-shadow: 0 0 8px var(--accent-red);
}

/* Editor Container */
.tab-content {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.tab-content.active {
  display: flex;
}

/* CodeMirror customization */
.CodeMirror {
  flex: 1;
  height: 100% !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 13px !important;
  line-height: 1.55 !important;
  background: #090c10 !important;
}

.CodeMirror-gutters {
  background: #0d1117 !important;
  border-right: 1px solid #21262d !important;
}

.CodeMirror-linenumber {
  color: #484f58 !important;
}

.CodeMirror-cursor {
  border-left: 2px solid var(--accent-cyan) !important;
}

.CodeMirror-selected {
  background: rgba(0, 255, 242, 0.15) !important;
}

/* Revision Panel View */
.revision-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-primary);
}

.revision-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.revision-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.revision-textarea {
  width: 100%;
  min-height: 90px;
  background: #090c10;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  resize: vertical;
  outline: none;
}

.revision-textarea:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 255, 242, 0.15);
}

.quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quick-tag {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.quick-tag:hover {
  background: rgba(0, 255, 242, 0.1);
  color: var(--accent-cyan);
  border-color: rgba(0, 255, 242, 0.3);
}

/* History Snapshots */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.history-item {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.history-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item-title {
  font-weight: 600;
  color: var(--text-primary);
}

.history-item-time {
  font-size: 10px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.history-actions {
  display: flex;
  gap: 6px;
}

.history-btn {
  background: #21262d;
  border: none;
  color: var(--text-secondary);
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
}

.history-btn:hover {
  color: var(--text-primary);
  background: #30363d;
}

/* Right Panel: Preview & Live Canvas */
.panel-preview {
  flex: 1;
  background: #04060a;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Canvas Viewport */
.canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 20px;
  background-image: 
    radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 24px 24px;
}

.canvas-container {
  position: relative;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  transition: width 0.3s ease, height 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

#motionSvg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Canvas Overlay Badges */
.canvas-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 10;
}

.badge-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.badge-val {
  color: var(--accent-cyan);
  font-weight: 700;
}

.scene-indicator {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-gold);
  z-index: 10;
  letter-spacing: 0.04em;
}

/* Runtime Error Banner */
.error-banner {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  background: rgba(255, 51, 102, 0.15);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 51, 102, 0.4);
  border-radius: 8px;
  padding: 12px 16px;
  color: #ff99b3;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  display: none;
  align-items: flex-start;
  gap: 10px;
  z-index: 30;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}

.error-banner.show {
  display: flex;
}

.error-close {
  background: transparent;
  border: none;
  color: #ff99b3;
  cursor: pointer;
  margin-left: auto;
  font-size: 14px;
}

/* Studio Timeline & Player */
.timeline-bar {
  background: rgba(13, 17, 23, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  z-index: 20;
}

.timeline-scrubber-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.time-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 65px;
}

.time-label.current {
  color: var(--accent-cyan);
  font-weight: 700;
}

.scrubber-track-container {
  flex: 1;
  position: relative;
  height: 24px;
  display: flex;
  align-items: center;
}

.scene-markers {
  position: absolute;
  top: 2px;
  left: 0;
  right: 0;
  height: 4px;
  display: flex;
  pointer-events: none;
}

.scene-marker-segment {
  height: 100%;
  position: relative;
}

.scene-marker-segment:not(:last-child)::after {
  content: '';
  position: absolute;
  right: 0;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 1px;
}

.timeline-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: #21262d;
  border-radius: 4px;
  outline: none;
  position: relative;
  z-index: 2;
  cursor: pointer;
}

.timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 12px var(--accent-cyan), 0 0 0 2px #ffffff;
  transition: transform 0.1s ease;
}

.timeline-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

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

.playback-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-cyan);
  border: none;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(0, 255, 242, 0.4);
  transition: all 0.15s ease;
}

.play-btn:hover {
  transform: scale(1.08);
  background: #33fff5;
}

.control-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.control-icon-btn:hover {
  color: var(--text-primary);
  background: #21262d;
}

.control-icon-btn.active {
  color: var(--accent-cyan);
  border-color: rgba(0, 255, 242, 0.4);
  background: rgba(0, 255, 242, 0.1);
}

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

.setting-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-backdrop.show {
  display: flex;
}

.modal-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 800px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 14px 20px;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 65px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 150;
}

.toast {
  background: rgba(13, 17, 23, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--accent-cyan);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  animation: slideIn 0.25s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}
