[hidden] { display: none !important; }
@font-face { font-family: "Mortend"; src: url("fonts/Mortend-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Mortend"; src: url("fonts/Mortend-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Be Vietnam Pro"; src: url("fonts/BeVietnamPro-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Be Vietnam Pro"; src: url("fonts/BeVietnamPro-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Be Vietnam Pro"; src: url("fonts/BeVietnamPro-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --lime: #83EC4C; --black: #000; --white: #fff; --grey: #8A8A8A; --panel: #1A1A1A; --line: #2a2a2a;
  --head: "Mortend", "Arial Black", sans-serif;
  --body: "Be Vietnam Pro", "Helvetica Neue", Arial, sans-serif;
  --r: 4px;
  color-scheme: dark;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: inherit; }
html, body { height: 100%; margin: 0; }
body { background: var(--black); color: var(--white); font: 400 14px/1.5 var(--body); -webkit-font-smoothing: antialiased; }

.app { display: grid; grid-template-columns: minmax(0, 1fr) 360px; height: 100%; }

/* Stage */
.stage { position: relative; min-height: 0; overflow: hidden; background: #000; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.view-label, .quad-labels span {
  position: absolute; font: 500 12px/1 var(--body); color: var(--grey); padding: 6px 8px;
  background: rgba(0,0,0,.55); border-radius: var(--r); pointer-events: none;
}
.view-label { top: 16px; left: 16px; }
.quad-labels { position: absolute; inset: 0; pointer-events: none; }
.quad-labels span:nth-child(1) { top: 12px; left: 12px; }
.quad-labels span:nth-child(2) { top: 12px; left: calc(50% + 12px); }
.quad-labels span:nth-child(3) { top: calc(50% + 12px); left: 12px; }
.quad-labels span:nth-child(4) { top: calc(50% + 12px); left: calc(50% + 12px); }

.transport {
  position: absolute; left: 16px; right: 16px; bottom: 16px; display: flex; align-items: center; gap: 12px;
  background: rgba(10,10,10,.82); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  padding: 8px 12px; border-radius: var(--r);
}
.icon-btn { width: 40px; height: 40px; border: 0; border-radius: var(--r); background: var(--white); color: #000; display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }
.time { font: 500 13px/1 var(--body); font-variant-numeric: tabular-nums; color: var(--grey); min-width: 52px; }
#scrub { flex: 1; min-width: 60px; }
.chip { border: 1px solid var(--line); background: transparent; color: var(--grey); font: 500 12px var(--body); padding: 6px 10px; border-radius: var(--r); cursor: pointer; flex: none; }
.chip[aria-pressed="true"] { color: var(--white); border-color: var(--grey); }

.drop-hint { position: absolute; inset: 12px; border: 2px dashed var(--lime); border-radius: var(--r); display: grid; place-items: center; background: rgba(0,0,0,.7); z-index: 5; }
.drop-hint div { max-width: 32ch; text-align: center; color: var(--white); font-size: 16px; }

.render-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.78); display: grid; place-items: center; z-index: 6; }
.render-box { width: min(380px, 86%); background: var(--panel); padding: 24px; border-radius: var(--r); }
.render-box p { color: var(--grey); margin: 8px 0 16px; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: #000; border-radius: 3px; overflow: hidden; }
.bar div { height: 100%; width: 0; background: var(--lime); transition: width .15s ease-out; }

/* Panel */
.panel { overflow-y: auto; border-left: 1px solid var(--line); background: #000; }
.panel section, .brand { padding: 20px 24px; border-top: 1px solid var(--line); }
.brand { border-top: 0; padding-top: 24px; }
.logo { width: 160px; height: auto; display: block; margin-bottom: 20px; }
h1, h2, h3 { font-family: var(--head); font-weight: 700; text-transform: uppercase; letter-spacing: .02em; line-height: 1; margin: 0; }
h1 { font-size: 22px; margin-bottom: 10px; }
h2 { font-size: 12px; margin-bottom: 14px; }
h3 { font-size: 14px; margin-bottom: 14px; }
.brand p { margin: 0; color: var(--grey); max-width: 36ch; }

.slots { display: grid; gap: 10px; }
.slot { display: grid; grid-template-columns: 96px 1fr; grid-template-rows: auto auto; gap: 6px 12px; background: var(--panel); padding: 10px; border-radius: var(--r); border: 1px solid transparent; transition: border-color .15s ease-out; }
.slot.drag { border-color: var(--lime); }
.slot-preview { grid-row: span 2; width: 96px; aspect-ratio: 4 / 3; background: #000; border-radius: 2px; overflow: hidden; }
.slot-preview > * { width: 100%; height: 100%; object-fit: contain; display: block; }
.slot-meta strong { display: block; font-weight: 600; }
.slot-name { display: block; color: var(--grey); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 190px; }
.slot-actions { display: flex; gap: 10px; align-items: center; }

.note { color: var(--grey); font-size: 12px; margin: 12px 0 0; max-width: 40ch; }
.note.warn { color: var(--white); }
.status { font-size: 12px; margin: 12px 0 0; color: var(--grey); }
.status.warn { color: var(--white); }
.status.warn::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #ffb03b; margin-right: 8px; vertical-align: 1px; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.seg button { height: 40px; border: 1px solid var(--line); background: var(--panel); color: var(--white); font: 500 13px var(--body); border-radius: var(--r); cursor: pointer; }
.seg button.on { background: var(--white); color: #000; border-color: var(--white); }
.seg.disabled button { opacity: .4; pointer-events: none; }

.toggles { display: grid; gap: 8px; margin-top: 14px; }
.tog { display: flex; align-items: center; gap: 10px; cursor: pointer; min-height: 28px; }
.tog input { appearance: none; -webkit-appearance: none; width: 34px; height: 20px; border-radius: 10px; background: #333; position: relative; flex: none; margin: 0; cursor: pointer; transition: background .15s ease-out; }
.tog input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--white); transition: transform .15s ease-out; }
.tog input:checked { background: var(--white); }
.tog input:checked::after { transform: translateX(14px); background: #000; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 500; font-size: 13px; display: flex; justify-content: space-between; }
.field output { color: var(--grey); font-variant-numeric: tabular-nums; font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid2 .field label { font-size: 12px; }
input[type="number"], select {
  height: 40px; width: 100%; background: var(--panel); color: var(--white); border: 1px solid #333; border-radius: var(--r);
  padding: 0 10px; font: 400 14px var(--body);
}
input[type="number"]:focus, select:focus { outline: none; border-color: var(--lime); }
input[type="range"] { -webkit-appearance: none; appearance: none; height: 24px; background: transparent; width: 100%; margin: 0; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: #333; border-radius: 2px; }
input[type="range"]::-moz-range-track { height: 4px; background: #333; border-radius: 2px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--white); margin-top: -6px; border: 0; }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--white); border: 0; }

.btn, .btn-ghost { white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; height: 44px; padding: 0 16px; border-radius: var(--r); cursor: pointer; font: 700 12px var(--head); text-transform: uppercase; letter-spacing: .02em; }
.btn { width: 100%; margin-top: 16px; background: var(--lime); color: #000; border: 0; }
.btn:disabled { opacity: .5; cursor: progress; }
.btn-ghost { background: transparent; color: var(--white); border: 1px solid #444; }
.btn-ghost.small { height: 32px; padding: 0 10px; font-size: 10px; }
.link { background: none; border: 0; color: var(--grey); text-decoration: underline; cursor: pointer; font: 400 12px var(--body); padding: 0; }

button:focus-visible, input:focus-visible, select:focus-visible, label.btn-ghost:focus-within { outline: 2px solid var(--lime); outline-offset: 2px; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 58vh auto; height: auto; }
  html, body { height: auto; }
  .stage { height: 58vh; }
  .panel { border-left: 0; overflow: visible; }
  .transport { left: 8px; right: 8px; bottom: 8px; gap: 8px; }
  .time { min-width: 0; font-size: 12px; }
  #tDur { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
