html,
body {
  margin: 0;
  min-height: 100%;
  background: #07070d;
  color: #f6f7fb;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  overflow: hidden;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, calc(100vh * 9 / 16)) minmax(360px, 440px);
  gap: 18px;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
  box-sizing: border-box;
  padding: 18px;
}

.preview-pane {
  width: min(calc(100vw - 500px), calc(100vh * 9 / 16));
  max-width: calc(100vh * 9 / 16);
  height: min(calc(100vh - 36px), calc((100vw - 500px) * 16 / 9));
  max-height: calc(100vh - 36px);
  margin: auto;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 18px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.editor {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: calc(100vh - 36px);
  box-sizing: border-box;
  padding: 16px;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(25, 28, 43, 0.96), rgba(13, 16, 27, 0.98));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 22px 70px rgba(0, 0, 0, 0.34);
}

.editor[hidden],
.render-mode .editor {
  display: none;
}

.render-mode .workspace {
  display: grid;
  place-items: center;
  padding: 0;
}

.render-mode .preview-pane {
  width: min(100vw, calc(100vh * 9 / 16));
  height: min(100vh, calc(100vw * 16 / 9));
}

.render-mode canvas {
  border-radius: 0;
  box-shadow: none;
}

.editor h1,
.editor h2 {
  margin: 0;
  line-height: 1.08;
}

.editor h1 {
  font-size: 22px;
}

.editor h2 {
  font-size: 14px;
  color: #cfd6ec;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.editor p {
  margin: 0;
  color: #aeb7d1;
  font-size: 13px;
  line-height: 1.48;
}

.editor-card {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.055);
}

.playback-card {
  border-color: rgba(255, 223, 101, 0.26);
  background: linear-gradient(180deg, rgba(255, 223, 101, 0.11), rgba(255, 255, 255, 0.055));
}

.timeline-control {
  display: grid;
  gap: 7px;
  color: #cfd6ec;
  font-size: 12px;
}

input[type="range"] {
  accent-color: #ffdf65;
  padding-inline: 0;
}

.playback-readout {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  width: fit-content;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  color: #ffdf65;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.sticky-tools {
  position: sticky;
  top: -16px;
  z-index: 2;
  border-color: rgba(255, 223, 101, 0.28);
  background: rgba(30, 35, 55, 0.98);
}

.row,
.button-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.row label {
  display: grid;
  gap: 5px;
  flex: 1 1 120px;
  color: #cfd6ec;
  font-size: 12px;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  box-sizing: border-box;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  color: #f6f7fb;
  padding: 8px 10px;
}

input[type="color"] {
  min-height: 37px;
  padding: 3px;
}

textarea {
  min-height: 190px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

button {
  border: 0;
  border-radius: 999px;
  background: #3949ab;
  color: #ffffff;
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
}

button.secondary {
  background: rgba(255, 255, 255, 0.12);
}

button.danger {
  background: #e53935;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 5px;
}

.swatch {
  height: 24px;
  border: 2px solid rgba(255, 255, 255, 0.24);
  border-radius: 7px;
}

.point-list,
.entity-list,
.object-editor {
  display: grid;
  gap: 7px;
  max-height: 210px;
  overflow: auto;
}

.object-editor {
  max-height: 360px;
}

.point-row,
.entity-row {
  display: grid;
  grid-template-columns: 34px 1fr 1fr 42px;
  gap: 6px;
  align-items: center;
}

.entity-row {
  grid-template-columns: 34px 52px 1fr 1fr;
}

.point-row button {
  min-width: 0;
  padding-inline: 0;
}

.selected-point {
  outline: 2px solid #ffdf65;
  outline-offset: 2px;
}

.selected-editor {
  border-color: rgba(255, 223, 101, 0.34);
  background: rgba(255, 223, 101, 0.075);
}

.selected-label {
  width: fit-content;
  border-radius: 999px;
  background: rgba(255, 223, 101, 0.14);
  color: #ffdf65;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
}

.object-row {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
}

.object-row.selected-object {
  border-color: rgba(255, 223, 101, 0.62);
  box-shadow: 0 0 0 2px rgba(255, 223, 101, 0.12);
}

.object-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #f6f7fb;
  font-size: 12px;
}

.object-title button {
  padding: 5px 8px;
  font-size: 11px;
}

.mini-actions {
  gap: 5px;
  justify-content: flex-end;
}

.object-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.object-grid label {
  display: grid;
  gap: 4px;
  color: #cfd6ec;
  font-size: 11px;
}

.status {
  min-height: 18px;
  color: #ffdf65;
  font-size: 12px;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .preview-pane {
    width: min(100%, calc(88vh * 9 / 16));
    height: auto;
    aspect-ratio: 9 / 16;
  }

  .editor {
    height: auto;
    max-height: none;
  }
}
