:root {
  --bg: #020617;
  --bg-elevated: #020617;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.22);
  --border-subtle: rgba(148, 163, 184, 0.35);
  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --radius-lg: 16px;
  --shadow-soft: 0 22px 45px rgba(15, 23, 42, 0.85);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    sans-serif;
  background: radial-gradient(circle at top, #111827 0, #020617 50%);
  color: var(--text-main);
  min-height: 100vh;
}

#app {
  max-width: 1280px;
  margin: 24px auto 32px;
  padding: 0 16px;
}

/* Header */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: radial-gradient(circle at top, #3b82f6, #1d4ed8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.6);
}

.app-title {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.04em;
}

.app-subtitle {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
}

.app-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.file-input {
  display: none;
}

.divide {
  width: 1px;
  height: 20px;
  background: rgba(148, 163, 184, 0.4);
}

/* Buttons */

.primary-btn,
.ghost-btn,
.icon-btn,
.chip-btn {
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  padding: 6px 11px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  background: transparent;
  color: var(--text-main);
  transition: background 0.18s ease, border-color 0.18s ease,
    box-shadow 0.18s ease, transform 0.08s ease;
}

.primary-btn {
  background: radial-gradient(circle at top, rgba(59, 130, 246, 0.25), #1d4ed8);
  border-color: rgba(59, 130, 246, 0.96);
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.6);
  font-weight: 500;
}

.primary-btn:hover {
  transform: translateY(-0.5px);
  box-shadow: 0 16px 40px rgba(37, 99, 235, 0.75);
}

.ghost-btn {
  border-color: rgba(148, 163, 184, 0.7);
  background: radial-gradient(
    circle at top,
    rgba(148, 163, 184, 0.16),
    rgba(15, 23, 42, 0.98)
  );
  color: var(--text-muted);
}

.ghost-btn:hover {
  border-color: rgba(226, 232, 240, 0.8);
  color: var(--text-main);
}

.icon-btn {
  padding: 4px 8px;
  border-color: rgba(148, 163, 184, 0.6);
  background: radial-gradient(
    circle at top,
    rgba(148, 163, 184, 0.14),
    rgba(15, 23, 42, 0.98)
  );
}

.icon-btn:hover {
  border-color: rgba(226, 232, 240, 0.95);
}

.icon-btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.5);
}

.chip-btn {
  padding: 4px 9px;
  font-size: 11px;
  border-color: rgba(148, 163, 184, 0.6);
  color: var(--text-muted);
  background: radial-gradient(
    circle at top,
    rgba(15, 23, 42, 0.96),
    rgba(15, 23, 42, 0.99)
  );
}

.chip-btn:hover {
  border-color: rgba(226, 232, 240, 0.85);
}

.chip-btn.active {
  border-color: var(--accent);
  background: radial-gradient(circle at top, var(--accent-soft), #020617);
  color: var(--text-main);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.6);
}

/* Layout */

.studio {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.1fr);
  gap: 16px;
}

.left-column,
.right-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (max-width: 980px) {
  .studio {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Panels */

.panel {
  background: radial-gradient(
    circle at top left,
    rgba(30, 64, 175, 0.25),
    #020617 55%
  );
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  padding: 12px 14px;
  position: relative;
}

.panel::before {
  content: "";
  position: absolute;
  inset: -30% 20% auto;
  background: radial-gradient(circle at top, rgba(56, 189, 248, 0.2), transparent);
  opacity: 0.25;
  pointer-events: none;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-header h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.panel-header-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Timeline */

.timeline-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.timeline-controls label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.timeline-ruler {
  margin-bottom: 6px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  font-size: 9px;
  color: var(--text-muted);
  height: 16px;
}

.timeline-ruler-tick {
  position: relative;
  flex: 1;
  border-left: 1px solid rgba(148, 163, 184, 0.35);
}

.timeline-ruler-tick span {
  position: absolute;
  top: -2px;
  transform: translateX(-50%);
}

.timeline-track {
  position: relative;
  width: 100%;
  min-height: 88px;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  background: radial-gradient(circle at top, #111827, #020617 70%);
  overflow: hidden;
  cursor: pointer;
}

.timeline-track-grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(
      to right,
      rgba(55, 65, 81, 0.6) 1px,
      transparent 1px
    ),
    linear-gradient(to bottom, rgba(30, 64, 175, 0.4) 1px, transparent 1px);
  background-size: 40px 100%, 100% 16px;
  opacity: 0.35;
  pointer-events: none;
}

.timeline-playhead {
  position: absolute;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.9);
}

.timeline-playhead::before {
  content: "";
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.4);
}

.timeline-layer-bar {
  position: absolute;
  height: 16px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.8);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.9);
  display: flex;
  align-items: center;
  padding: 0 18px;
  font-size: 10px;
  color: var(--text-main);
}

.timeline-layer-bar.locked {
  border-style: dashed;
  opacity: 0.9;
}

.timeline-layer-bar::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  background: radial-gradient(
    circle at top,
    rgba(191, 219, 254, 0.95),
    rgba(37, 99, 235, 0.2)
  );
  opacity: 0.35;
  pointer-events: none;
}

.timeline-layer-bar-label {
  position: relative;
  z-index: 1;
}

.timeline-layer-bar-handle {
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(191, 219, 254, 0.8);
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.9);
  cursor: col-resize;
}

.timeline-layer-bar-handle--start {
  left: 2px;
}

.timeline-layer-bar-handle--end {
  right: 2px;
}

.timeline-layer-bar.dragging {
  opacity: 0.9;
  box-shadow: 0 0 0 1px rgba(248, 250, 252, 0.9),
    0 18px 35px rgba(15, 23, 42, 0.95);
}

/* Layers panel */

.layers-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 340px;
  overflow: auto;
  padding-right: 2px;
}

.layer-card {
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  background: radial-gradient(circle at top left, #020617, #020617 70%);
  padding: 8px 9px 7px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease,
    transform 0.08s ease, background 0.18s ease, opacity 0.16s ease;
  cursor: pointer;
}

.layer-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.6);
  transform: translateY(-1px);
}

.layer-card.layer-card--hidden {
  opacity: 0.55;
}

.layer-card.layer-card--locked {
  border-style: dashed;
}

.layer-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.layer-type-badge {
  font-size: 10px;
  padding: 3px 6px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  color: var(--text-muted);
}

.layer-header-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.layer-header-actions .icon-btn {
  padding: 3px 6px;
  font-size: 10px;
}

.layer-row {
  display: flex;
  gap: 8px;
  margin-top: 5px;
}

.layer-row label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: var(--text-muted);
}

.layer-row small {
  font-size: 10px;
  color: var(--text-muted);
}

/* Inputs */

input[type="text"],
input[type="number"],
select,
textarea {
  background: rgba(15, 23, 42, 0.96);
  border-radius: 999px;
  border: 1px solid rgba(51, 65, 85, 0.9);
  color: var(--text-main);
  font-size: 11px;
  padding: 5px 8px;
  outline: none;
  width: 100%;
}

textarea {
  border-radius: 14px;
  min-height: 120px;
  resize: vertical;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.6);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100px;
  height: 4px;
  border-radius: 999px;
  background: rgba(31, 41, 55, 0.9);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--accent);
  border: 1px solid rgba(15, 23, 42, 0.9);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.5);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--accent);
  border: 1px solid rgba(15, 23, 42, 0.9);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.5);
  cursor: pointer;
}

/* Preview */

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  align-items: center;
}

.preset-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 11px;
}

.toolbar-label {
  color: var(--text-muted);
  margin-right: 4px;
}

.scene-settings {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.scene-settings label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.preview-window {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: radial-gradient(circle at top left, rgba(37, 99, 235, 0.3), #020617);
  padding: 14px;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-scene {
  position: relative;
  width: 100%;
  max-width: 420px;
  min-height: 190px;
  border-radius: 22px;
  background: radial-gradient(circle at top, rgba(96, 165, 250, 0.2), #020617);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
}

.preview-scene::before {
  content: "";
  position: absolute;
  inset: auto -40% -40%;
  background: radial-gradient(circle at bottom, rgba(15, 23, 42, 0.9), transparent);
  pointer-events: none;
}

.preview-scene.device-tablet {
  max-width: 360px;
  border-radius: 28px;
}

.preview-scene.device-mobile {
  max-width: 260px;
  border-radius: 34px;
}

.preview-item {
  position: relative;
  min-width: 80px;
  padding: 8px 11px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.9);
  background: radial-gradient(circle at top, rgba(15, 23, 42, 0.98), #020617);
  font-size: 11px;
  text-align: center;
  box-shadow: 0 14px 25px rgba(15, 23, 42, 0.98);
  z-index: 1;
}

.preview-item span {
  position: relative;
  z-index: 1;
}

.preview-item::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  background: radial-gradient(
    circle at top,
    rgba(248, 250, 252, 0.08),
    transparent 60%
  );
  opacity: 0.9;
}

/* Export */

.export-tabs {
  display: inline-flex;
  gap: 6px;
  margin-bottom: 8px;
}

.export-textarea {
  width: 100%;
  background: rgba(15, 23, 42, 0.98);
  border-radius: 14px;
  border: 1px solid rgba(51, 65, 85, 0.96);
  color: var(--text-main);
  padding: 9px 10px 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  resize: vertical;
  min-height: 180px;
}

.export-textarea::placeholder {
  color: rgba(148, 163, 184, 0.65);
}

.export-options {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Misc */

.loop-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.loop-toggle input {
  margin: 0;
}

.time-indicator {
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: radial-gradient(
    circle at top,
    rgba(148, 163, 184, 0.2),
    rgba(15, 23, 42, 0.96)
  );
}

.hidden {
  display: none;
}

/* -------------------------------------------------------------------------- */
/* Live keyframes used by the Preview (same as export)                        */
/* -------------------------------------------------------------------------- */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInUp {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(-40px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes rotateIn {
  from {
    transform: rotate(-20deg);
    opacity: 0;
  }
  to {
    transform: rotate(0deg);
    opacity: 1;
  }
}

@keyframes zoomIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes bounceIn {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
    opacity: 1;
  }
  70% {
    transform: scale(0.97);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes flipInX {
  0% {
    transform: perspective(400px) rotateX(90deg);
    opacity: 0;
  }
  40% {
    transform: perspective(400px) rotateX(-10deg);
  }
  70% {
    transform: perspective(400px) rotateX(10deg);
    opacity: 1;
  }
  100% {
    transform: perspective(400px) rotateX(0);
    opacity: 1;
  }
}
