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


html {
  color-scheme: dark;
}

body {
  background: #111827;
  color: #e5e7eb;
  font-family: system-ui, sans-serif;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  padding: 0.75rem 1rem;
  background: #020617;
  border-bottom: 1px solid #1f2937;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.theme-picker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.theme-picker select {
  background: #111827;
  border: 1px solid #4b5563;
  color: #e5e7eb;
  padding: 0.25rem 0.6rem;
  border-radius: 0.25rem;
  cursor: pointer;
}

main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.left-pane {
  flex: 1;
  border-right: 1px solid #1f2937;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.editor-wrapper {
  flex: 1;
  min-width: 0;
   min-height: 0;
}

.CodeMirror {
  height: 100%;
  border-radius: 0.5rem;
  border: 1px solid #1f2937;
  background: #020617;
}




.right-pane {
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}


.controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  align-items: center;
}

.controls input {
  width: 70px;
  background: #020617;
  border: 1px solid #374151;
  color: #e5e7eb;
  padding: 0.2rem 0.3rem;
  border-radius: 0.25rem;
}

.controls button {
  background: #111827;
  border: 1px solid #4b5563;
  color: #e5e7eb;
  padding: 0.25rem 0.6rem;
  border-radius: 0.25rem;
  cursor: pointer;
}

.controls button:hover {
  background: #1f2937;
}














.stage {
  width: 640px;
  height: 360px;
  border-radius: 0.5rem;
  border: 1px solid #1f2937;
  background: #ffffff;
  position: relative;
  overflow: hidden;
}



#stage img {
  will-change: opacity;
  backface-visibility: hidden;
}







.console {
  flex: 1;
  border-radius: 0.5rem;
  border: 1px solid #1f2937;
  background: #020617;
  padding: 0.5rem;
  font-family: monospace;
  font-size: 0.8rem;
  overflow-y: auto;
  white-space: pre-wrap;
}

.console-title {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-bottom: 0.25rem;
}






.console {
  position: relative;
}

#scrollToBottom {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: #1f2937;
  border: 1px solid #4b5563;
  color: #e5e7eb;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  display: none;
  z-index: 10;
}

#scrollToBottom:hover {
  background: #374151;
}








/* Force non-overlay scrollbars */
.CodeMirror-scroll {

  scrollbar-gutter: stable;
}








/* === Dark Scrollbars === */

/* Chrome, Edge, Safari */
.CodeMirror-scroll::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.CodeMirror-scroll::-webkit-scrollbar-track {
  background: #0f172a;   /* dark track */
}

.CodeMirror-scroll::-webkit-scrollbar-thumb {
  background: #374151;   /* thumb color */
  border-radius: 6px;
  border: 2px solid #0f172a; /* gives padding look */
}

.CodeMirror-scroll::-webkit-scrollbar-thumb:hover {
  background: #4b5563;
}


/* Firefox */
.CodeMirror-scroll {
  scrollbar-width: thin;
  scrollbar-color: #374151 #0f172a;
}



.title-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.project-title {
  background: #111827;
  border: 1px solid #374151;
  color: #e5e7eb;
  padding: 0.25rem 0.6rem;
  border-radius: 0.25rem;
  font-size: 0.9rem;
  width: 220px;
  height: 100%;
}

.project-title:focus {
  outline: none;
  border-color: #3b82f6;
}


.icon-btn {
  background: #111827;
  border: 1px solid #4b5563;
  border-radius: 0.25rem;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.icon-btn svg {
  display: block;
}

.icon-btn:hover {
  background: #1f2937;
  border-color: #3b82f6;
}

.title-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.project-title {
  background: #111827;
  border: 1px solid #374151;
  color: #e5e7eb;
  padding: 0.25rem 0.6rem;
  border-radius: 0.25rem;
  font-size: 0.9rem;
  width: 220px;
  height: 34px;
}

.project-title:focus {
  outline: none;
  border-color: #3b82f6;
}


/* Plus button uses same style as other icon buttons */
.icon-btn {
  background: #111827;
  border: 1px solid #4b5563;
  border-radius: 0.25rem;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.icon-btn svg {
  display: block;
}

.icon-btn:hover {
  background: #1f2937;
  border-color: #3b82f6;
}












#stage {
  user-select: none;
  -webkit-user-select: none; /* Safari */
  -moz-user-select: none;    /* Firefox */
  -ms-user-select: none;     /* old Edge */
}

#stage img,
#stage div {
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}




.stage-loading {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  font-size: 1.5em;
  font-family: sans-serif;
  z-index: 1000;
  pointer-events: none; /* let mouse events pass through once hidden */
  transition: opacity 0.5s ease;
}






/* Assets + Tabs */


.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.tab-btn {
  background: #111827;
  border: 1px solid #4b5563;
  color: #e5e7eb;
  padding: 0.25rem 0.6rem;
  border-radius: 0.25rem;
  cursor: pointer;
}

.tab-btn.active {
  background: #1f2937;
  border-color: #3b82f6;
}

.tab-content {
  display: none;
  height: 100%;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.assets-panel {
  padding: 0.5rem;
  color: #9ca3af;
}





/* Assets */


.asset-upload-btn {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}








.asset-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #111827;
  border: 1px solid #374151;
  padding: 8px;
  border-radius: 6px;
  margin-bottom: 8px;
  transition: background 0.2s, border-color 0.2s;
}

.asset-item:hover {
  background: #1f2937;
  border-color: #4b5563;
}

/* HANDLE */
.asset-handle {
  cursor: grab;
  user-select: none;
  opacity: 0.5;
  font-size: 14px;
  padding: 4px;
}

/* RIGHT SIDE */
.asset-right {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* NAME */
.asset-name {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: #e5e7eb;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.asset-name:focus {
  outline: none;
  border-color: #3b82f6;
  background: #020617;
}

/* PREVIEW */
.asset-preview {
  display: flex;
  align-items: center;
}

.asset-preview img {
  width: 50px;
  height: 50px;
  object-fit: contain;
  border-radius: 4px;
}

.asset-preview audio {
  width: 100px;
  height: 28px;
}

/* BUTTONS */
.asset-buttons {
  display: flex;
  gap: 6px;
}

.asset-buttons button {
  background: #020617;
  border: 1px solid #374151;
  color: #e5e7eb;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

.asset-buttons button:hover {
  background: #1f2937;
  border-color: #4b5563;
}


.asset-name {
  display: inline-block;

  min-width: 60px;
  max-width: 160px;

  white-space: nowrap;
  overflow-x: auto;

  text-overflow: clip;

  border: none;
  background: transparent;
  outline: none;

  font-size: 14px;
}






/* Dragging */

.asset-item.dragging {
  opacity: 0.4;
}


/* Scrolling */

#assetList {
  overflow-y: auto;
  flex: 1;           /* fills available space inside tab */
  min-height: 0;     /* IMPORTANT for flexbox scrolling */
}
.tab-content.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.assets-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}


#assetList {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}




