html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f6f7f9;
}

#toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 16px;
  background: #1f2937;
  color: white;
}

#logo {
  height: 34px;
  width: auto;
  border-radius: 6px;
}

#title {
  font-weight: 600;
  font-size: 16px;
  flex: 1;
}

#toolbar button {
  background: #3478F6;
  color: white;
  border: 0;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}

#toolbar button:hover {
  filter: brightness(1.1);
}

#toolbar button#clear {
  background: #6b7280;
}

#toolbar button#center,
#toolbar button#file-menu-btn {
  background: #374151;
  font-size: 16px;
  padding: 6px 12px;
}

#file-wrap {
  position: relative;
}

#file-menu {
  position: absolute;
  top: 40px;
  right: 0;
  background: white;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  min-width: 170px;
  overflow: hidden;
  z-index: 50;
}

#file-menu[hidden] {
  display: none;
}

#file-menu button {
  background: none;
  border: 0;
  color: #111827;
  text-align: left;
  padding: 12px 16px;
  font-size: 14px;
  cursor: pointer;
}

#file-menu button:active,
#file-menu button:hover {
  background: #eef2ff;
}

#workspace {
  position: absolute;
  top: 48px;
  left: 0;
  right: 0;
  bottom: 0;
  /* Let Blockly own all touch gestures (pinch/drag); without this the
     browser's own pan/zoom handling fights two-finger input. */
  touch-action: none;
}

#workspace.with-output {
  bottom: 30vh;
}

#output {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 30vh;
  background: #111827;
  color: #d1d5db;
  display: flex;
  flex-direction: column;
  border-top: 2px solid #3478F6;
}

#output[hidden] {
  display: none;
}

#toolbar button#toggle-output {
  background: #374151;
  font-family: monospace;
}

/* In-page dialog (replaces window.prompt/confirm). */
#dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#dialog-overlay[hidden] {
  display: none;
}

#dialog {
  background: white;
  border-radius: 12px;
  padding: 18px 20px;
  min-width: 260px;
  max-width: 85vw;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

#dialog-title {
  font-weight: 600;
  font-size: 16px;
  color: #111827;
  margin-bottom: 6px;
}

#dialog-msg {
  font-size: 14px;
  color: #4b5563;
  margin-bottom: 10px;
}

#dialog-msg:empty {
  display: none;
}

#dialog-choices {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 40vh;
  overflow-y: auto;
  margin-bottom: 10px;
}

#dialog-choices:empty {
  display: none;
}

#dialog-choices button {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}

#dialog-choices button:active {
  background: #dbeafe;
}

#dialog-input[hidden] {
  display: none;
}

#dialog-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 18px;
  padding: 8px 10px;
  border: 2px solid #3478F6;
  border-radius: 8px;
  outline: none;
  margin-bottom: 14px;
}

#dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

#dialog-buttons button {
  border: 0;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 14px;
  cursor: pointer;
}

#dialog-ok {
  background: #3478F6;
  color: white;
}

#dialog-cancel {
  background: #e5e7eb;
  color: #111827;
}

/* Phones: tighter toolbar so the workspace gets the room. */
@media (max-width: 500px) {
  #toolbar {
    height: 40px;
    gap: 8px;
    padding: 0 10px;
  }
  #logo {
    height: 28px;
  }
  #title {
    font-size: 13px;
  }
  #toolbar button {
    padding: 6px 10px;
    font-size: 12px;
  }
  #workspace {
    top: 40px;
  }
}

#output-header {
  padding: 8px 16px;
  background: #0b1220;
  font-size: 13px;
  color: #9ca3af;
  border-bottom: 1px solid #1f2937;
}

#output-pre {
  flex: 1;
  margin: 0;
  padding: 12px 16px;
  overflow: auto;
  font-family: "JetBrains Mono", Menlo, monospace;
  font-size: 13px;
  white-space: pre;
}
