*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #0a0a12;
  color: #e8e8f0;
  font: 13px/1.4 ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
}

#app {
  display: grid;
  grid-template-columns: 1fr 280px;
  min-height: 100%;
  height: 100%;
}

/* —— Main stage column —— */
#main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #050508;
}

#stage-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 16px 16px 8px;
}

#viewport {
  position: relative;
  width: min(100%, calc((100vh - 120px) * 16 / 9));
  max-height: calc(100vh - 120px);
  aspect-ratio: 16 / 9;
  background: #000;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
}

#stage,
#fxCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#fxCanvas {
  pointer-events: none;
  opacity: 0;
}

#viewport.fx-on #fxCanvas {
  opacity: 1;
}

#viewport.fx-on #stage {
  opacity: 0;
}

.glyph {
  stroke: #ffffff;
  fill: none;
  visibility: hidden;
}

/* —— Transport under video —— */
#transport {
  flex-shrink: 0;
  padding: 10px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid #1e1e2a;
  background: #0c0c14;
}

.transport-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scrub-wrap {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 10px;
}

.scrub-wrap input[type="range"] {
  width: 100%;
  accent-color: #6b6bff;
  height: 6px;
}

.time-label {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: #9a9ab0;
  text-align: center;
}

.export-status {
  margin: 0;
  font-size: 12px;
  color: #a0a0ff;
}

/* —— Sidebar —— */
#ui {
  background: #12121a;
  border-left: 1px solid #2a2a3a;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: auto;
  max-height: 100vh;
}

.ui-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ui-block strong {
  font-size: 14px;
  letter-spacing: 0.02em;
}

.label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9a9ab0;
}

.muted {
  color: #7a7a90;
}

[hidden],
.fx-panel[hidden] {
  display: none !important;
}

.small {
  font-size: 11px;
  line-height: 1.45;
  margin: 0;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.row input {
  accent-color: #5b5bff;
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #c8c8d8;
}

.slider-row span {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.slider-row em {
  font-style: normal;
  font-variant-numeric: tabular-nums;
  color: #8a8aff;
  font-size: 11px;
}

.slider-row input[type="range"] {
  width: 100%;
  accent-color: #5b5bff;
  height: 4px;
}

.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: #c8c8d8;
}

.color-row input[type="color"] {
  width: 44px;
  height: 28px;
  border: 1px solid #3a3a50;
  border-radius: 6px;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.btn {
  appearance: none;
  border: 1px solid #3a3a50;
  background: #1c1c28;
  color: #e8e8f0;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
}

.btn:hover:not(:disabled) {
  background: #262638;
  border-color: #5b5bff;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn.primary {
  background: #2a2a6a;
  border-color: #5b5bff;
}

.btn.primary:hover:not(:disabled) {
  background: #35358a;
}

.btn-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-row .btn {
  flex: 1;
  min-width: 0;
  padding: 7px 8px;
  font-size: 12px;
}

.file-input {
  font-size: 11px;
  color: #9a9ab0;
  max-width: 100%;
}

.meter-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meter {
  height: 8px;
  background: #1c1c28;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #2a2a3a;
}

#audioMeter {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3a3aff, #a0a0ff 70%, #ff6b6b);
  transition: width 0.05s linear;
}

/* Fullscreen / cinema: hide chrome, stage only */
body.cinema #ui {
  display: none;
}

body.cinema #app {
  grid-template-columns: 1fr;
}

body.cinema #transport {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  border: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

body.cinema #transport:hover,
body.cinema #transport:focus-within {
  opacity: 1;
  pointer-events: auto;
}

body.cinema #stage-wrap {
  padding: 0;
  max-height: 100vh;
}

body.cinema #viewport {
  width: min(100vw, calc(100vh * 16 / 9));
  max-height: 100vh;
}

@media (max-width: 900px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
  }

  #ui {
    border-left: none;
    border-top: 1px solid #2a2a3a;
    max-height: none;
  }

  #viewport {
    width: 100%;
    max-height: none;
  }
}
