:root {
  color-scheme: light;
  --ink: #1f2b26;
  --muted: #667269;
  --panel: #fffaf0;
  --line: #d7dfd2;
  --stage: #dff5ff;
  --green: #4f8f46;
  --green-dark: #2d6b36;
  --blue: #3182ce;
  --orange: #f59e0b;
  --pink: #db2777;
  --purple: #7c3aed;
  --red: #dc2626;
  --shadow: 0 18px 45px rgba(31, 43, 38, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Arial, "Helvetica Neue", sans-serif;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 221, 87, 0.32), transparent 28rem),
    linear-gradient(135deg, #d6f4ff 0%, #f5f1df 50%, #e0f4d8 100%);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(420px, 1.15fr) minmax(360px, 0.85fr);
  gap: 16px;
}

.stage-panel,
.blocks-panel {
  min-width: 0;
  border: 1px solid rgba(80, 105, 85, 0.2);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.94);
  box-shadow: var(--shadow);
}

.stage-panel {
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr) auto;
  overflow: hidden;
}

.topbar,
.statusbar,
.workspace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1;
}

h2 {
  font-size: 20px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  color: #1f2b26;
  background: #edf2e8;
  box-shadow: inset 0 -2px 0 rgba(31, 43, 38, 0.16);
  cursor: pointer;
}

.button:active {
  transform: translateY(1px);
  box-shadow: inset 0 -1px 0 rgba(31, 43, 38, 0.16);
}

.button--run {
  color: white;
  background: var(--green);
}

.button--small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 14px;
}

.stage-wrap {
  position: relative;
  min-height: 0;
  padding: 16px;
  display: grid;
  place-items: center;
}

canvas {
  width: 100%;
  max-width: 860px;
  aspect-ratio: 12 / 7;
  border: 3px solid #2f5840;
  border-radius: 8px;
  background: var(--stage);
}

.speech {
  position: absolute;
  left: 11%;
  top: 12%;
  max-width: min(320px, 70%);
  padding: 12px 14px;
  border: 3px solid #2f5840;
  border-radius: 8px;
  background: white;
  font-weight: 700;
  box-shadow: 0 10px 25px rgba(31, 43, 38, 0.16);
}

.speech::after {
  content: "";
  position: absolute;
  left: 34px;
  bottom: -13px;
  width: 20px;
  height: 20px;
  border-right: 3px solid #2f5840;
  border-bottom: 3px solid #2f5840;
  background: white;
  transform: rotate(45deg);
}

.statusbar {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.blocks-panel {
  display: grid;
  grid-template-columns: minmax(170px, 0.7fr) minmax(220px, 1fr);
  min-height: 0;
  overflow: hidden;
}

.palette,
.workspace {
  min-width: 0;
  padding: 16px;
}

.palette {
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.42);
}

.palette-list,
.program-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.program-list {
  min-height: 360px;
  margin: 14px 0 0;
  padding: 12px;
  border: 2px dashed #a5b99d;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
  list-style: none;
}

.block {
  position: relative;
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 9px 12px 9px 18px;
  color: white;
  text-align: left;
  font-weight: 700;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18), 0 5px 12px rgba(31, 43, 38, 0.12);
  cursor: grab;
}

.block::before,
.program-item::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 18px;
  width: 12px;
  height: 12px;
  border-radius: 0 8px 8px 0;
  background: rgba(255, 255, 255, 0.55);
}

.block:active {
  cursor: grabbing;
}

.block--motion {
  background: var(--blue);
}

.block--looks {
  background: var(--purple);
}

.block--control {
  background: var(--orange);
}

.block--sound {
  background: var(--pink);
}

.program-item {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 48px;
  border-radius: 8px;
  padding: 9px 10px 9px 18px;
  color: white;
  font-weight: 700;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}

.program-item.is-running {
  outline: 4px solid rgba(255, 235, 59, 0.88);
}

.program-item button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

.empty-hint {
  margin: 12px 4px 0;
  color: var(--muted);
  font-size: 14px;
}

.program-list.drag-over {
  border-color: var(--green);
  background: rgba(217, 245, 206, 0.74);
}

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

  .blocks-panel {
    grid-template-columns: 1fr;
  }

  .palette {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .palette-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 8px;
    gap: 8px;
  }

  .topbar,
  .statusbar,
  .workspace-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions,
  .button {
    width: 100%;
  }

  .button {
    justify-content: center;
  }

  .palette-list {
    grid-template-columns: 1fr;
  }

  .program-list {
    min-height: 240px;
  }
}
