body {
  margin: 0;
  padding: 0;
  background-color: #ffffff;
  font-family: system-ui, sans-serif;
}

#app {
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

#pixi-container canvas {
  display: block;
}

/* Top-left hamburger menu button */
.menu-button {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 1100;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid #dbe3ec;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(34, 51, 68, 0.18);
}

.menu-button:hover {
  background: #f3f7fb;
}

/* Settings modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 30, 42, 0.45);
}

/* A class with `display` overrides the default [hidden] rule, so restore it. */
.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(560px, calc(100vw - 40px));
  max-height: calc(100vh - 80px);
  overflow: auto;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(20, 30, 42, 0.35);
}

.modal-form {
  padding: 28px 32px 24px;
}

.modal-title {
  margin: 0 0 6px;
  font-size: 22px;
  color: #1c2733;
}

.modal-intro {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.5;
  color: #5a6b7d;
}

.modal-section {
  margin: 18px 0 12px;
  padding-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7a8aa0;
  border-bottom: 1px solid #e2e9f1;
}

.modal-field {
  display: block;
  margin-bottom: 18px;
}

.modal-field span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #2b3a48;
}

.modal-field input {
  box-sizing: border-box;
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  color: #1c2733;
  border: 1px solid #cdd9e6;
  border-radius: 8px;
  outline: none;
}

.modal-field input:focus {
  border-color: #2f6db0;
  box-shadow: 0 0 0 3px rgba(47, 109, 176, 0.15);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.modal-btn {
  font-size: 14px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
}

.modal-btn-secondary {
  background: #ffffff;
  border-color: #cdd9e6;
  color: #2b3a48;
}

.modal-btn-secondary:hover {
  background: #f3f7fb;
}

.modal-btn-primary {
  background: #2f6db0;
  color: #ffffff;
}

.modal-btn-primary:hover {
  background: #3a7ec6;
}

/* Drawing tool toolbar (fixed, top-center) */
.draw-toolbar {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid #dbe3ec;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(34, 51, 68, 0.18);
  user-select: none;
}

.draw-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Thin divider between groups. */
.draw-group + .draw-group {
  padding-left: 10px;
  border-left: 1px solid #e2e9f1;
}

.draw-tool {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  background: #ffffff;
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  cursor: pointer;
}

.draw-tool:hover {
  background: #f3f7fb;
}

.draw-tool[data-active="true"] {
  background: #e6f0fb;
  border-color: #2f6db0;
}

.draw-swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #cdd9e6;
  cursor: pointer;
}

.draw-swatch[data-active="true"] {
  box-shadow: 0 0 0 2px #2f6db0;
}

.draw-width {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  cursor: pointer;
}

.draw-width:hover {
  background: #f3f7fb;
}

.draw-width[data-active="true"] {
  background: #e6f0fb;
  border-color: #2f6db0;
}

.draw-width-dot {
  display: block;
  border-radius: 50%;
  background: #2b3a48;
}

.draw-action {
  font-size: 13px;
  font-weight: 600;
  color: #2b3a48;
  padding: 7px 12px;
  background: #ffffff;
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  cursor: pointer;
}

.draw-action:hover {
  background: #f3f7fb;
}

/* DOM context menu */
.context-menu {
  position: absolute;
  z-index: 1000;
  min-width: 160px;
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(34, 51, 68, 0.18);
  padding: 4px;
  user-select: none;
}

.context-menu-item {
  padding: 8px 12px;
  font-size: 14px;
  color: #223344;
  border-radius: 5px;
  cursor: pointer;
}

.context-menu-item:hover {
  background: #eef3f9;
}

/* Items that open a flyout get a trailing chevron. */
.context-menu-item.has-submenu {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.context-menu-item.has-submenu::after {
  content: "▸";
  font-size: 12px;
  color: #7a8aa0;
}

/* Nested flyout menus are positioned in viewport coordinates. */
.context-submenu {
  position: fixed;
}

/* DOM overlay hosting the Filerobot image editor (active image bubble) */
.image-editor-overlay {
  position: absolute;
  z-index: 850;
  background: #ffffff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(34, 51, 68, 0.3);
}

.image-editor-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 14px;
  color: #5a6b7d;
}

/* "Generating image…" placeholder overlay (anchored to a world point) */
.image-gen-loading {
  position: absolute;
  z-index: 850;
  transform-origin: top left;
  max-width: 280px;
  padding: 12px 16px;
  font-size: 14px;
  color: #5a6b7d;
  background: #ffffff;
  border: 1px dashed #b8c8da;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(34, 51, 68, 0.18);
  user-select: none;
}

.image-gen-loading.is-error {
  color: #c0392b;
  border-color: #e0a9a2;
  border-style: solid;
}

/* DOM code-cell overlay (Jupyter) */
.code-cell {
  position: absolute;
  z-index: 800;
  width: 380px;
  transform-origin: top left;
}

.code-cell-body {
  background: #ffffff;
  border: 1px solid #cdd9e6;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(34, 51, 68, 0.18);
  overflow: hidden;
}

/* Orange "+" spawner straddling the lower-middle edge */
.code-cell-add {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 50%);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #ff8c00;
  color: #000000;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(34, 51, 68, 0.25);
}

.code-cell-add:hover {
  background: #ff9f1a;
}

.code-cell-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  background: #f3f7fb;
  border-bottom: 1px solid #e2e9f1;
  cursor: grab;
  user-select: none;
}

.code-cell-header:active {
  cursor: grabbing;
}

.code-cell-count {
  font-family: "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 12px;
  color: #7a8aa0;
  white-space: pre;
}

.code-cell-title {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: #5a6b7d;
  letter-spacing: 0.02em;
}

.code-cell-run {
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  background: #2f7d4f;
  border: none;
  border-radius: 5px;
  padding: 3px 10px;
  cursor: pointer;
}

.code-cell-run:disabled {
  opacity: 0.55;
  cursor: default;
}

.code-cell-runall {
  background: #2f6db0;
  letter-spacing: -1px;
}

.code-cell-runall:hover {
  background: #3a7ec6;
}

.code-cell-icon {
  font-size: 15px;
  line-height: 1;
  color: #7a8aa0;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0 4px;
}

.code-cell-icon:hover {
  color: #2f6db0;
}

/* Orange "×" badge straddling the top-right corner (matches chat/image bubbles) */
.code-cell-close {
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(50%, -50%);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #ff8c00;
  color: #000000;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(34, 51, 68, 0.25);
}

.code-cell-close:hover {
  background: #ff9f1a;
}

.code-cell-editor {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 64px;
  margin: 0;
  border: none;
  outline: none;
  resize: none;
  padding: 12px;
  font-family: "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  color: #1c2733;
  background: #ffffff;
  tab-size: 4;
}

.code-cell-output {
  padding: 10px 12px;
  border-top: 1px solid #e2e9f1;
  background: #fafcfe;
  max-height: 320px;
  overflow: auto;
}

.code-cell-text {
  margin: 0;
  font-family: "SF Mono", "Fira Code", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  color: #2b3a48;
  white-space: pre-wrap;
  word-break: break-word;
}

.code-cell-text.is-error {
  color: #c0392b;
}

.code-cell-rich {
  display: block;
  max-width: 100%;
  margin: 6px 0;
}

.code-cell-rich img,
.code-cell-rich table {
  max-width: 100%;
}

/* Kernel status pill (fixed, top-right) */
.kernel-status {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1100;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  background: #7a8aa0;
  box-shadow: 0 2px 8px rgba(34, 51, 68, 0.2);
  user-select: none;
}

.kernel-status[data-status="loading"] {
  background: #d99323;
}

.kernel-status[data-status="ready"] {
  background: #2f7d4f;
}

.kernel-status[data-status="running"] {
  background: #2f6db0;
}

/* DOM textarea overlay used while editing a bubble */
.bubble-editor {
  position: absolute;
  z-index: 900;
  box-sizing: border-box;
  margin: 0;
  border: 1.5px solid #9bb3cc;
  border-radius: 12px;
  background: #ffffff;
  color: #223344;
  line-height: 20px;
  resize: none;
  overflow: hidden;
  outline: none;
  box-shadow: 0 4px 14px rgba(34, 51, 68, 0.15);
}
