:root {
  --bg: #050505;
  --panel: #080808;
  --panel-border: #242424;
  --panel-border-soft: #171717;
  --text: #f5f5f1;
  --muted: #959595;
  --muted-strong: #c9c9c2;
  --accent: #3fd2fb;
  --accent-2: #68ff21;
  --accent-3: #ffb801;
  --stage-border: #2d2d2d;
  --surface: #101010;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(63, 210, 251, 0.08), transparent 24rem),
    linear-gradient(180deg, #070707 0%, #000000 100%);
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
}

body {
  min-height: 100vh;
}

.shell {
  display: grid;
  grid-template-columns: minmax(360px, 460px) minmax(0, 1fr);
  min-height: 100vh;
}

.panel {
  min-height: 100vh;
  border-right: 1px solid var(--panel-border);
  background:
    linear-gradient(180deg, rgba(10, 10, 10, 0.94) 0%, rgba(4, 4, 4, 0.98) 100%);
}

.panel__inner {
  display: grid;
  gap: 22px;
  padding: 24px 22px 32px;
}

.panel__header {
  gap: 10px;
}

.brand {
  display: block;
}

.brand__logo {
  width: 132px;
  max-width: 100%;
  height: auto;
  display: block;
}

.brand__caption {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.section-kicker,
output,
.actions button,
.stage-frame__header,
.stage-drop-hint {
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: -0.12em;
  text-transform: uppercase;
}

.section-kicker,
output {
  color: var(--muted);
}

.section-kicker {
  margin: 0;
  font-size: 0.8rem;
}

.terminal-card {
  display: grid;
  gap: 14px;
  padding: 18px 16px;
  border: 1px solid var(--panel-border);
  background:
    linear-gradient(180deg, rgba(17, 17, 17, 0.95) 0%, rgba(7, 7, 7, 0.98) 100%);
  box-shadow: var(--shadow);
}

.control span,
.toggle span,
.stage-frame__header {
  font-size: 0.94rem;
}

.controls {
  display: grid;
  gap: 14px;
}

.controls--tight {
  gap: 12px;
}

.control {
  display: grid;
  gap: 7px;
}

.control select,
.control input[type="color"],
.control input[type="text"] {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--panel-border);
  border-radius: 0;
  background: #050505;
  color: var(--text);
  box-shadow: none;
  outline: none;
}

.control input[type="text"]::placeholder {
  color: #666;
}

.control select:focus,
.control input[type="color"]:focus,
.control input[type="text"]:focus {
  border-color: var(--accent);
}

.control input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

output {
  font-size: 0.76rem;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}

.toggle input {
  inline-size: 16px;
  block-size: 16px;
  accent-color: var(--accent-2);
}

.actions {
  display: grid;
  gap: 10px;
}

.actions button {
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--panel-border);
  border-radius: 0;
  background: #050505;
  color: var(--text);
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, background-color 140ms ease, transform 140ms ease;
}

.actions button:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(63, 210, 251, 0.08);
  color: var(--accent);
  transform: translateY(-1px);
}

.actions button:disabled,
.control input:disabled,
.control select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#exportVideoButton {
  color: var(--accent-2);
}

#exportTxtButton {
  color: var(--accent);
}

#exportSvgButton {
  color: var(--accent-3);
}

.stage-shell {
  min-height: 100vh;
  padding: 20px;
  background:
    radial-gradient(circle at top, rgba(104, 255, 33, 0.06), transparent 20rem),
    #000;
}

.stage-sticky {
  position: sticky;
  top: 20px;
  height: calc(100vh - 40px);
  display: grid;
  place-items: center;
}

.stage-frame {
  width: min(100%, calc((100vh - 92px) * 16 / 9));
  max-width: 100%;
  display: grid;
  gap: 0;
  cursor: pointer;
}

.stage-frame__header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--stage-border);
  background: rgba(8, 8, 8, 0.96);
  color: var(--muted-strong);
  font-size: 0.76rem;
}

.stage-frame__header.is-hidden {
  display: none;
}

.stage-frame__header.is-hidden + .stage {
  border-top: 1px solid var(--stage-border);
}

.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  border-left: 1px solid var(--stage-border);
  border-right: 1px solid var(--stage-border);
  border-bottom: 1px solid var(--stage-border);
  background:
    radial-gradient(circle at top, rgba(63, 210, 251, 0.08), transparent 18rem),
    #000;
  overflow: hidden;
}

.stage-drop-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 14px;
  border: 1px solid var(--stage-border);
  background: rgba(0, 0, 0, 0.75);
  color: var(--muted-strong);
  pointer-events: none;
  white-space: nowrap;
  font-size: 0.76rem;
}

.stage-drop-hint.is-hidden {
  display: none;
}

.status-toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 40;
  min-width: min(560px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  padding: 14px 16px;
  border: 1px solid var(--panel-border);
  background: rgba(10, 10, 10, 0.96);
  color: var(--muted-strong);
  font-size: 0.94rem;
  line-height: 1.45;
  transform: translateX(-50%) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.status-toast.is-active {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.stage-frame.is-dragging,
.stage-frame:hover {
  border-color: transparent;
}

.stage-frame.is-dragging .stage-frame__header,
.stage-frame.is-dragging .stage,
.stage-frame:hover .stage-frame__header,
.stage-frame:hover .stage {
  border-color: var(--accent);
}

#displayCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 400px minmax(0, 1fr);
  }
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--panel-border);
  }

  .stage-shell {
    padding: 16px;
  }

  .stage-sticky {
    top: 16px;
    height: auto;
  }

  .stage-frame {
    width: 100%;
  }
}
