body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: #0f0f0f;
  color: #fff;
}

/* layout */

.layout {
  display: flex;
}

.container {
  max-width: 800px;
  margin: auto;
  padding: 2rem;
}

h1 {
  font-weight: 400;
}

.section {
  margin-bottom: 1.5rem;
}

.divider {
  border: none;
  border-top: 1px solid #333;
  margin: 2.5rem 0;
}

/* inputs */

textarea {
  width: 100%;
  min-height: 120px;
  padding: 1rem;
  margin-bottom: 2rem;
  background: #1a1a1a;
  color: #fff;
  border: 1px solid #333;
  border-radius: 6px;
}

/* ================= */
/* GLOBAL BUTTONS */
/* ================= */

button {
  background: #1f1f1f;
  border: 1px solid #3a3a3a;
  color: #e5e5e5;
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: all .15s ease;
}

button:hover {
  background: #2a2a2a;
  border-color: #555;
  color: #fff;
}

button:active {
  transform: scale(.96);
}

button:disabled {
  opacity: .5;
  cursor: default;
}

/* option buttons */

.options button {
  margin: .3rem;
  padding: .6rem 1rem;
}

.options button.active {
  background: #fff;
  color: #000;
}

/* ================= */
/* SIDEBAR */
/* ================= */

.sidebar {
  width: 220px;
  background: #111;
  padding: 1rem;
  border-right: 1px solid #222;
  min-height: 100vh;
}

.sidebar h2 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

#project-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.project-item {
  padding: .5rem;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  cursor: pointer;
}

.project-item:hover {
  background: #222;
}

.project-item.active {
  background: #fff;
  color: #000;
}

#new-project {
  margin-top: 1rem;
  width: 100%;
}

/* ================= */
/* SYSTEM CHECK */
/* ================= */

.system-check {
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

#backend-status {
  font-size: .9rem;
  opacity: .8;
}

/* ================= */
/* TIMELINE */
/* ================= */

.project-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.audio-toggle {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .9rem;
}

#scene-strip {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding: 1rem 0;
}

.scene-thumb {
  min-width: 180px;
  cursor: pointer;
  position: relative;
}

.scene-thumb video {
  width: 100%;
  border-radius: 6px;
  border: 2px solid #333;
}

.scene-thumb.active video {
  border-color: #fff;
}

.scene-thumb.dragging {
  opacity: .4;
  transform: scale(.98);
}

.scene-select {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 10;
}

.scene-badge {
  position: absolute;
  top: 6px;
  left: 36px;
  background: rgba(0,0,0,.7);
  padding: 2px 6px;
  font-size: .7rem;
  border-radius: 4px;
}

.thumb-controls {
  position: absolute;
  bottom: 6px;
  left: 6px;
  display: flex;
  gap: 4px;
}

.thumb-controls button {
  background: rgba(0,0,0,.7);
  border: none;
  font-size: .7rem;
  padding: 2px 5px;
  border-radius: 3px;
}

/* ================= */
/* TIMELINE TRACK */
/* ================= */

.timeline-container {
  margin-top: 20px;
  border-top: 1px solid #333;
  padding-top: 15px;
}

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

.timeline {
  background: #111;
  border: 1px solid #222;
  border-radius: 6px;
  padding: 10px;
}

.track {
  display: flex;
  align-items: center;
  height: 50px;
  background: #1b1b1b;
  border-radius: 4px;
  margin-bottom: 8px;
  overflow: hidden;
}

.track-label {
  width: 80px;
  font-size: 13px;
  color: #888;
  padding-left: 10px;
}

.track-content {
  flex: 1;
  position: relative;
  height: 100%;
}

.audio-bar {
  position: absolute;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg,#4CAF50,#2e7d32);
  border-radius: 3px;
  opacity: .9;
}

/* ================= */
/* ASSETS */
/* ================= */

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

.asset-grid {
  margin-top: 15px;
  display: grid;
  grid-template-columns: repeat(auto-fill,minmax(180px,1fr));
  gap: 15px;
}

.asset-card {
  background: #111;
  border: 1px solid #222;
  border-radius: 8px;
  overflow: hidden;
  transition: .2s ease;
}

.asset-card:hover {
  transform: translateY(-4px);
  border-color: #444;
}

.asset-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.asset-footer {
  padding: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .85rem;
  opacity: .8;
  flex-wrap: wrap;
  gap: 4px;
}

.asset-footer button {
  padding: 4px 6px;
  font-size: 12px;
}

.asset-type-badge {
  flex-basis: 100%;
}

#open-asset-modal { border-color:#3a7cff; }
#upload-asset-btn { border-color:#9c5cff; }

/* ================= */
/* ASSET PREVIEW */
/* ================= */

.scene-asset-preview {
  display:flex;
  gap:10px;
  margin-top:10px;
}

.scene-asset-thumb {
  position:relative;
}

.scene-asset-thumb img {
  width:80px;
  height:80px;
  object-fit:cover;
  border-radius:6px;
}

.scene-asset-thumb button {
  position:absolute;
  top:-5px;
  right:-5px;
}


.scene-assets-panel {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #222;
}

.scene-assets-panel h3 {
  margin: 0 0 12px 0;
  font-size: 1rem;
}

.scene-asset-slots {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
}

.scene-asset-slot {
  min-height: 110px;
  background: #111;
  border: 1px dashed #333;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px;
}

.scene-asset-slot-label {
  font-size: 0.85rem;
  color: #888;
}
/* ================= */
/* MODAL */
/* ================= */

.asset-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.asset-modal.hidden {
  display: none;
}

.asset-modal-content {
  background: #111;
  padding: 20px;
  width: 500px;
  border-radius: 10px;
  border: 1px solid #333;
}

.asset-type-select {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.asset-type-select button.active {
  background: #444;
}

.asset-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ================= */
/* IMAGE PREVIEW */
/* ================= */

#image-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.image-preview-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.85);
}

.image-preview-content {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#image-preview-img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  border-radius: 8px;
}

#close-image-preview {
  position: absolute;
  top: 20px;
  right: 30px;
  background: none;
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
}

.hidden {
  display: none;
}

.container video {
  max-width: 420px;
  width: 100%;
  height: auto;
}


/* ================= */
/* FRAME MODAL */
/* ================= */

.modal-frame {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.modal-frame.hidden {
  display: none;
}

.modal-frame-content {
  background: #111;
  padding: 24px;
  width: 360px;
  border-radius: 10px;
  border: 1px solid #333;
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
  text-align: center;
}

.modal-frame-actions {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  gap: 10px;
}

.modal-frame-content label {
  display: block;
  margin: 10px 0;
  font-size: 14px;
}

.export-asset {
  opacity: 0.7;
}
.export-asset:hover {
  opacity: 1;
}


/* ================= */
/* COMPOSE MODAL */
/* ================= */

.compose-preview{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:15px;
  margin-bottom:15px;
}

.compose-preview img{
  width:80px;
  height:80px;
  object-fit:cover;
  border-radius:6px;
}

.compose-plus{
  font-size:24px;
  color:#aaa;
}


/* status globale */
.global-status {
  margin: 10px 0;
  padding: 10px;
  font-size: 13px;
  color: #ccc;
  background: rgba(0,0,0,0.4);
  border-radius: 6px;
  max-height: 120px;
  overflow-y: auto;
  font-family: monospace;
}

/* sezione asset scrollabile */
.asset-grid-wrapper {
  max-height: 400px;
  overflow-y: auto;
}