:root {
  --bg: #0c0e13;
  --panel: #141720;
  --panel-elev: #1b1f2b;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #edf0f7;
  --muted: #939db4;
  --accent: #4f7cff;
  --accent-hover: #648dff;
  --accent-soft: rgba(79, 124, 255, 0.16);
  --radius: 10px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  width: 100vw;
  height: 100vh;
}

#main-column {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Viewport */
#viewport-container {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #111318;
}

#three-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

/* Top Bar */
.top-bar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(18, 21, 30, 0.78);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  padding: 8px 14px 8px 10px;
  border-radius: 12px;
  pointer-events: auto;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #4f7cff, #8c5eff);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -0.02em;
  color: #fff;
}

.brand h1 {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

.badge {
  display: inline-block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  pointer-events: auto;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(18, 21, 30, 0.78);
  backdrop-filter: blur(12px);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  border-color: var(--border-strong);
  background: rgba(30, 35, 48, 0.9);
}

.chip-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

.chip-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #fff;
}

.dot-bw {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(90deg, #fff 50%, #000 50%);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

/* 16:9 Frame Guide */
.frame-guide {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
  z-index: 5;
}

.frame-guide-box {
  width: min(88%, calc(78% * 16 / 9));
  max-height: 82%;
  aspect-ratio: 16 / 9;
  border: 1.5px dashed rgba(255, 255, 255, 0.45);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
  position: relative;
}

.frame-label {
  position: absolute;
  top: 8px;
  left: 10px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(0, 0, 0, 0.5);
  padding: 3px 8px;
  border-radius: 6px;
}

/* Bottom Playback Bar */
.playback-bar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(18, 21, 30, 0.84);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 14px;
  z-index: 10;
  max-width: calc(100% - 24px);
}

.play-btn {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-elev);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.play-btn:hover {
  background: #252b3b;
  border-color: var(--border-strong);
}

.play-btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.play-btn.primary:hover {
  background: var(--accent-hover);
}

.play-btn.icon-only {
  padding: 7px 10px;
}

.timeline-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 6px;
  border-left: 1px solid var(--border);
}

.timeline-label {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 72px;
}

#timeline-scrubber {
  width: 150px;
}

/* Sidebar */
#sidebar {
  width: 340px;
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 10px 10px 0;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 9px 6px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: #fff;
  border-bottom-color: var(--accent);
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.section-group:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.section-group h2 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.hint {
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

/* Upload Boxes */
.upload-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1.5px dashed var(--border-strong);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: all 0.15s ease;
}

.upload-box:hover, .upload-box.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-icon {
  font-size: 22px;
  line-height: 1;
}

.upload-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.upload-text strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.upload-text span {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Segmented Control */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
  padding: 3px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.seg-btn {
  padding: 8px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.seg-btn.active {
  background: var(--accent);
  color: #fff;
}

/* Info Grid */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.info-item {
  background: var(--panel-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.info-item span {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
}

.info-item strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

/* Controls */
.control-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.control-header label {
  font-size: 12px;
  color: var(--text);
}

.val {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 99px;
  background: #272d3d;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  cursor: pointer;
}

select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--panel-elev);
  color: var(--text);
  font-size: 12px;
  outline: none;
}

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

.color-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

input[type="color"] {
  width: 38px;
  height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  padding: 2px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}

/* Presets */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.preset-btn {
  padding: 8px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-elev);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Buttons */
.btn-primary, .btn-secondary {
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--panel-elev);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover {
  background: #252b3b;
}

.full-width {
  width: 100%;
}

.export-summary {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  border: 1px solid rgba(79, 124, 255, 0.35);
  font-size: 12px;
  font-weight: 500;
  color: #cddbff;
  text-align: center;
}

.export-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Status Overlay */
.status-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 14, 0.78);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  z-index: 50;
}

.status-card {
  width: 360px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.status-card h3 {
  font-size: 15px;
  font-weight: 600;
}

.status-card p {
  font-size: 12px;
  color: var(--muted);
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

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

.progress-track {
  width: 100%;
  height: 7px;
  border-radius: 99px;
  background: #232836;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4f7cff, #8c5eff);
  transition: width 0.1s linear;
}

.hidden {
  display: none !important;
}

/* ---------------- INTERACTIVE TIMELINE DOCK ---------------- */
#timeline-dock {
  height: 214px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  user-select: none;
  z-index: 15;
}

.tl-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.015);
  flex-wrap: wrap;
}

.tl-transport, .tl-presets, .tl-add-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.tl-sep-label {
  font-size: 11px;
  color: var(--muted);
  margin-right: 2px;
}

.tl-mini-btn, .tl-add-btn {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-elev);
  color: var(--text);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s ease;
}

.tl-mini-btn:hover {
  border-color: var(--border-strong);
  background: #252b3b;
}

.tl-add-btn {
  border-left: 3px solid var(--c, var(--accent));
}

.tl-add-btn:hover {
  background: #252b3b;
  border-color: var(--c, var(--accent));
}

.tl-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 12px;
  position: relative;
  overflow: hidden;
}

.tl-ruler {
  height: 22px;
  position: relative;
  border-bottom: 1px solid var(--border);
  cursor: ew-resize;
}

.tl-tick {
  position: absolute;
  top: 4px;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.tl-tick::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 1px;
  height: 5px;
  background: var(--border-strong);
}

.tl-end-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255, 255, 255, 0.25);
  pointer-events: none;
}

.tl-tracks {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  padding: 4px 0;
}

.tl-lane {
  position: relative;
  height: 31px;
  background: rgba(255, 255, 255, 0.025);
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.tl-lane-label {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.22);
  pointer-events: none;
}

.tl-clip {
  position: absolute;
  top: 2px;
  bottom: 2px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--clip-color) 75%, #111);
  border: 1px solid color-mix(in srgb, var(--clip-color) 90%, #fff);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 15px;
  cursor: grab;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.tl-clip:active {
  cursor: grabbing;
}

.tl-clip.selected {
  outline: 2px solid #fff;
  outline-offset: 1px;
  z-index: 3;
}

.tl-clip-title {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.tl-clip-dur {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.82);
  font-variant-numeric: tabular-nums;
  margin-left: 6px;
  pointer-events: none;
}

.tl-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 12px;
  max-width: 24%;
  cursor: ew-resize;
  z-index: 4;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.2);
  transition: background 0.12s ease;
}

.tl-handle span {
  width: 3px;
  height: 12px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.55);
  pointer-events: none;
}

.tl-handle.left {
  left: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.18);
}

.tl-handle.right {
  right: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
}

.tl-handle:hover {
  background: rgba(255, 255, 255, 0.38);
}

.tl-handle:hover span {
  background: #fff;
}

.tl-dir-toggle {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.tl-dir-btn {
  padding: 3px 8px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.tl-dir-btn.active {
  background: var(--accent);
  color: #fff;
}

.tl-playhead {
  position: absolute;
  top: -22px;
  bottom: 0;
  width: 2px;
  background: #ff4d4f;
  pointer-events: none;
  z-index: 10;
}

.tl-playhead::before {
  content: '';
  position: absolute;
  top: 0;
  left: -5px;
  width: 12px;
  height: 10px;
  background: #ff4d4f;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.tl-inspector {
  height: 34px;
  border-top: 1px solid var(--border);
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.22);
  font-size: 11px;
  overflow-x: auto;
}

.tl-insp-hint {
  color: var(--muted);
}

.tl-insp-badge {
  padding: 2px 8px;
  border-radius: 5px;
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
}

.tl-inspector label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  white-space: nowrap;
}

.tl-inspector input[type="number"],
.tl-inspector select {
  width: 64px;
  padding: 3px 6px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  background: var(--panel-elev);
  color: var(--text);
  font-size: 11px;
}

.tl-inspector select {
  width: auto;
}

.tl-del-btn {
  margin-left: auto;
  padding: 4px 9px;
  border-radius: 5px;
  border: 1px solid rgba(255, 77, 79, 0.4);
  background: rgba(255, 77, 79, 0.14);
  color: #ff8a8c;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.tl-del-btn:hover {
  background: rgba(255, 77, 79, 0.28);
  color: #fff;
}

