:root {
  --bg: #121317;
  --panel: #1b1d23;
  --panel2: #23262e;
  --line: #2f333d;
  --text: #e6e8ee;
  --dim: #9097a6;
  --accent: #ffb020;
  --accent2: #00d1ff;
  --danger: #ff5a6a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: grid; grid-template-rows: auto 1fr auto;
  background: var(--bg); color: var(--text);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  overflow: hidden; user-select: none; -webkit-user-select: none;
}
button, select, input { font: inherit; color: inherit; }
button {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 5px;
  padding: 4px 10px; cursor: pointer; white-space: nowrap;
}
button:hover { border-color: #4a505e; background: #2a2e38; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #1a1200; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.small { padding: 1px 8px; font-size: 12px; float: right; }
button.danger { color: var(--danger); }
button.on { border-color: var(--accent2); color: var(--accent2); }
select, input[type=text], input[type=number] {
  background: #0e0f12; border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; min-width: 0;
}
input[type=text], input[type=number] { user-select: text; -webkit-user-select: text; }
input[type=color] { width: 34px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: none; }
input[type=range] { width: 100%; accent-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent2); outline-offset: 1px; }

#bar {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { letter-spacing: .04em; color: var(--accent); margin-right: 4px; }
.name { width: 150px; }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.grow { flex: 1; }
.chk { display: inline-flex; align-items: center; gap: 4px; color: var(--dim); white-space: nowrap; }
#customSize input { width: 70px; }

#main { display: grid; grid-template-columns: 1fr 290px; min-height: 0; }
#stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background:
  repeating-conic-gradient(#15171c 0% 25%, #121317 0% 50%) 0 0 / 24px 24px; }
#scene { position: absolute; background: #000; box-shadow: 0 0 0 1px #3a3f4b, 0 8px 30px rgba(0, 0, 0, .5); }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#empty {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  color: var(--dim); pointer-events: none; font-size: 14px;
}

#side { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; }
#side section { padding: 10px 12px; border-bottom: 1px solid var(--line); }
#side h2 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }

.layer, .media {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 5px; cursor: pointer;
}
.layer:hover, .media:hover { background: var(--panel2); }
.layer.sel { background: #2c2a1c; box-shadow: inset 2px 0 0 var(--accent); }
.layer .nm, .media .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer button, .media button { padding: 0 6px; font-size: 12px; line-height: 20px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(255, 255, 255, .25); flex: none; }
.media .meta { color: var(--dim); font-size: 11px; white-space: nowrap; }
.media.bad .nm { color: var(--danger); }
.none { color: var(--dim); padding: 4px 0; }

.row { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 8px; margin: 6px 0; }
.row > label { color: var(--dim); }
.row .pair { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.row .pair button { padding: 4px 7px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.actions.end { justify-content: flex-end; }
.note { color: var(--dim); font-size: 12px; margin: 6px 0; }

#status {
  display: flex; gap: 12px; align-items: center; padding: 4px 10px; font-size: 12px; color: var(--dim);
  background: var(--panel); border-top: 1px solid var(--line); white-space: nowrap; overflow: hidden;
}
#hint { overflow: hidden; text-overflow: ellipsis; }
#msg { color: var(--accent); }
#msg.err { color: var(--danger); }

dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 16px 18px; width: 440px; max-width: calc(100vw - 32px);
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin: 0 0 10px; font-size: 15px; }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 12px; padding: 8px 12px 12px; }
legend { color: var(--dim); padding: 0 4px; }
progress { width: 100%; grid-column: 1 / -1; accent-color: var(--accent); }

body.dropping #stage::after {
  content: "Drop video or image files to import"; position: absolute; inset: 12px; display: grid; place-items: center;
  border: 2px dashed var(--accent2); border-radius: 10px; background: rgba(0, 209, 255, .08); color: var(--accent2); font-size: 16px;
}
