@font-face {
  font-family: Baufra;
  src: url("fonts/Baufra-Medium.otf") format("opentype");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: Baufra;
  src: url("fonts/Baufra-Bold.otf") format("opentype");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: Dystopian;
  src: url("fonts/Dystopian-Bold.otf") format("opentype");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: Dystopian;
  src: url("fonts/Dystopian-Black.otf") format("opentype");
  font-weight: 900;
  font-display: swap;
}
@font-face {
  font-family: Syne;
  src: url("fonts/Syne-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: Outfit;
  src: url("fonts/Outfit-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: Fraunces;
  src: url("fonts/Fraunces-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: #f3f1ec;
  font-family: Baufra, sans-serif;
  font-size: 15px;
  line-height: 1.35;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid #f3f1ec;
  outline-offset: 2px;
}
#editor[hidden], #library[hidden], #exporting[hidden] { display: none !important; }

#editor {
  height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  grid-template-rows: 60px minmax(0, 1fr) 248px;
  grid-template-areas:
    "top top top"
    "left stage right"
    "bottom bottom bottom";
  background: #0c0c0c;
}

#top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  border-bottom: 1px solid #242424;
  background: #000;
}
.brand {
  font-family: Dystopian, sans-serif;
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.03em;
  line-height: 1;
}
.brand span { color: #f3f1ec; }
#proj-name {
  width: 220px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #333;
  padding: 6px 2px;
  border-radius: 0;
}
#dur-label { color: #c8c2b8; min-width: 72px; }
#dur-label.warn { color: #ffb020; }
#status { color: #8d887f; font-size: 13px; flex: 1; }
.top-actions { display: flex; gap: 8px; }
button {
  background: #161616;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 7px 11px;
}
button:hover { background: #222; }
button.go {
  background: #f3f1ec;
  color: #111;
  border-color: #f3f1ec;
}
button.go:hover { background: #fff; }

#left, #right {
  overflow: auto;
  padding: 16px 14px 24px;
  background: #101010;
  min-height: 0;
}
#left { grid-area: left; border-right: 1px solid #242424; }
#right { grid-area: right; border-left: 1px solid #242424; }
#stage {
  grid-area: stage;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #000;
}
#preview {
  height: 100%;
  width: auto;
  max-width: 100%;
  background: #000;
  touch-action: none;
  cursor: default;
}

h2 {
  margin: 0 0 10px;
  font-family: Dystopian, sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  text-transform: lowercase;
}
h2::after { content: "."; }
h3 {
  margin: 16px 0 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8d887f;
}
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-head h2 { margin: 0; }
section + section { margin-top: 22px; }
.hint { color: #8d887f; font-size: 13px; margin: 8px 0 0; }
.warn-note { color: #ffb020; font-size: 13px; margin: 8px 0 0; }

.drop {
  border: 1px dashed #3a3a3a;
  border-radius: 10px;
  padding: 14px;
  color: #c8c2b8;
  margin-bottom: 8px;
  cursor: pointer;
}
.drop strong { display: block; color: #f3f1ec; font-weight: 500; }
.drop.is-on { border-color: #f3f1ec; }

.item {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px;
  border-radius: 8px;
  margin-top: 6px;
  cursor: pointer;
}
.item:hover { background: #1a1a1a; }
.item.is-on { background: #1c1c1c; box-shadow: inset 0 0 0 1px #f3f1ec; }
.item.is-now { box-shadow: inset 3px 0 0 #f3f1ec; }
.item img, .ph {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  background: #222;
}
.item .meta { min-width: 0; }
.item .meta b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta span { color: #8d887f; font-size: 13px; }
.mini { display: flex; flex-direction: column; gap: 2px; }
.mini button { padding: 2px 6px; border-radius: 4px; }

.field { display: block; margin: 0 0 10px; }
.field > span, .field > output {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.field output { color: #c8c2b8; }
input[type="range"] { width: 100%; accent-color: #f3f1ec; }
input[type="number"], input[type="text"], select, textarea {
  width: 100%;
  background: #0c0c0c;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 7px 8px;
}
textarea { min-height: 72px; resize: vertical; }
.colors { display: flex; gap: 8px; align-items: center; }
input[type="color"] {
  width: 42px;
  height: 32px;
  padding: 0;
  border: 1px solid #333;
  background: transparent;
  border-radius: 6px;
}
.checks { display: flex; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 10px; }
.checks label, .check { display: flex; align-items: center; gap: 6px; color: #c8c2b8; }
.swatch {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 7px;
  border: 2px solid transparent;
}
.swatch.is-on { border-color: #f3f1ec; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

#bottom {
  grid-area: bottom;
  border-top: 1px solid #242424;
  background: #000;
  padding: 8px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
#transport { display: flex; align-items: center; gap: 12px; }
#time-label { min-width: 130px; color: #c8c2b8; font-variant-numeric: tabular-nums; }
#scrub { flex: 1; }
.keys { color: #6f6a63; font-size: 12px; white-space: nowrap; }
#timeline { display: grid; grid-template-columns: 64px 1fr; gap: 8px; align-items: center; min-height: 150px; }
.tl-labels { display: grid; grid-template-rows: 72px 26px 26px; gap: 6px; color: #8d887f; font-size: 12px; }
.tl-labels span { display: flex; align-items: center; }
#tl-wrap { position: relative; display: grid; grid-template-rows: 72px 26px 26px; gap: 6px; }
.tl-track {
  position: relative;
  background: #161616;
  border-radius: 6px;
  overflow: hidden;
}
.tl-block {
  position: absolute;
  top: 3px;
  bottom: 3px;
  border-radius: 4px;
  background: #3a342c center / cover no-repeat;
  color: #f3f1ec;
  font-size: 12px;
  overflow: hidden;
  cursor: grab;
  min-width: 10px;
  user-select: none;
}
.tl-block.pic.is-drag, .tl-block.tx.is-drag { outline: 2px solid #f3f1ec; outline-offset: -2px; cursor: grabbing; }
.tl-block span {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.62);
  line-height: 1.3;
  pointer-events: none;
}
.tl-block.tx { background: #243042; cursor: grab; }
.tl-block.tx span { position: static; background: none; padding: 0 8px; display: flex; align-items: center; height: 100%; }
.tl-block.is-on { box-shadow: inset 0 0 0 2px #f3f1ec; }
.tl-block i {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 14px;
  cursor: ew-resize;
  z-index: 1;
}
.tl-block i::after {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  right: 5px;
  width: 2px;
  border-radius: 2px;
  background: rgba(243, 241, 236, 0.9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.tl-block i.left { left: 0; right: auto; }
.tl-block i.left::after { left: 5px; right: auto; }
#playhead {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: #f3f1ec;
  pointer-events: none;
  z-index: 2;
}

#library {
  min-height: 100vh;
  padding: 48px 56px 80px;
  background: #000;
}
#library .brand { font-size: 64px; }
.sub { color: #8d887f; max-width: 520px; margin: 8px 0 28px; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px;
}
.card {
  background: #101010;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #242424;
}
.card img, .card .empty-thumb {
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  display: block;
  background: #181818;
}
.card .pad { padding: 10px 12px 12px; }
.card b { display: block; font-weight: 500; }
.card span { color: #8d887f; font-size: 13px; }
.card .actions { margin-top: 8px; }
.card.new {
  border-style: dashed;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  cursor: pointer;
  color: #f3f1ec;
  font-family: Dystopian, sans-serif;
  font-size: 28px;
}
.card.new:hover { background: #141414; }

#exporting {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.export-card {
  width: min(420px, calc(100% - 32px));
  background: #141414;
  border: 1px solid #333;
  border-radius: 14px;
  padding: 22px;
}
.export-card h2 { font-size: 32px; }
.bar { height: 8px; background: #2a2a2a; border-radius: 99px; overflow: hidden; }
.bar div { height: 100%; width: 0; background: #f3f1ec; }
#export-eta { color: #c8c2b8; min-height: 1.2em; }
#toasts {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(460px, calc(100% - 32px));
}
.toast {
  background: #f3f1ec;
  color: #111;
  padding: 12px 14px;
  border-radius: 10px;
}
#src-video {
  position: fixed;
  width: 4px;
  height: 4px;
  left: 0;
  bottom: 0;
  opacity: 0;
  pointer-events: none;
}
@media (max-width: 1100px) {
  .keys { display: none; }
  #editor { grid-template-columns: 240px minmax(0, 1fr) 260px; }
}
