/* --- 1. RESET & BASE STYLES --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: 20px;
  background-color: #f5f5f5;
  font-family: Arial, sans-serif;
  overflow: hidden; /* Prevents viewport scrollbars */
}

/* Base form element controls */
input,
label {
  display: inline-block;
}

input {
  width: 10ch;
  padding: 8px 12px;
  font-size: 14px;
}

/* Common reusable box styling */
.box {
  border: 1px dashed #000;
  background-color: #fff;
  padding: 16px;
}

/* --- 2. LAYOUT CONTAINERS --- */
.app-container {
  display: flex;
  flex: 1;
  gap: 8px;
  min-height: 0; /* Critical: allows flex children to shrink below content size */
}

/* --- 3. LEFT PANEL --- */
.left-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.editor {
  flex: 1;
  min-height: 0;
}

.run-btn {
  align-self: flex-start;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
}

.run-btn:hover {
  background-color: #e0e0e0;
}

/* --- 4. RIGHT PANEL --- */
.right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
}

/* Canvas container using CSS Grid overlay stack */
.canvas,
#canvasContainer {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  position: relative;
  padding: 0;
  overflow: hidden;
  min-height: 0;
}


canvas,
#canvas {
  display: block;
  width: 100%;
  height: 100%;
}


/* --- 6. CONSOLE OUTPUT --- */
.console-output {
  flex: 0 0 auto;
}

#consoleOutput {
  max-height: 200px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}