* { box-sizing: border-box; }
body, .toolbar, .main, .right-panel, .canvas-wrap { user-select: none; }
.stdout { user-select: text; }

/* Cursor blinking animation */
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}
html, body, #app { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: #0f172a;
  background: #f8fafc;
  overflow: hidden;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  background: #111827;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.toolbar .group { display: flex; align-items: center; gap: 8px; }
.toolbar button, .toolbar select {
  background: #1f2937;
  color: #e5e7eb;
  border: 1px solid #374151;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.toolbar button:hover { background: #374151; }
.toolbar .group-title { opacity: 0.8; margin-right: 6px; }

/* Colored shape buttons */
.shape-btn { padding: 4px; display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 40px; background: #1f2937; border: 1px solid #374151; border-radius: 8px; }
.shape-btn svg { width: 90%; height: 90%; }
.shape-btn.oval ellipse { fill: #fde68a; stroke: #b45309; }
.shape-btn.rect rect { fill: #bfdbfe; stroke: #1d4ed8; }
.shape-btn.para polygon { fill: #bbf7d0; stroke: #15803d; }
.shape-btn.diamond polygon { fill: #fecaca; stroke: #b91c1c; }

.main { display: grid; grid-template-columns: 260px 1fr; gap: 12px; padding: 12px; height: calc(100% - 64px); }
.canvas-wrap {
  position: relative;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
}
.canvas { width: 100%; height: calc(100vh - 180px); display: block; outline: none; }
.errors { position: absolute; left: 8px; top: 8px; color: #ef4444; white-space: pre-line; font-size: 12px; }
.right-panel.compact { width: 100%; max-width: min(22vw, 280px); }
.rp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hint { position: absolute; right: 8px; bottom: 8px; font-size: 12px; color: #334155; background: #f1f5f9; padding: 6px 8px; border-radius: 6px; border: 1px solid #e2e8f0; }

.right-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.right-panel h3 { margin: 0; }
.snap-controls {
  padding: 8px;
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 8px;
}
.snap-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}
.snap-checkbox input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}
.backpack {
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 8px;
  padding: 8px;
  display: grid;
  gap: 4px;
  max-height: 420px;
  overflow: auto;
}
.backpack.grid { grid-template-columns: repeat(4, 1fr); }
.backpack.grid .slot { min-height: 40px; align-items: center; justify-content: center; text-align: center; border: 1px dashed #e5e7eb; }
.slot { display: flex; justify-content: space-between; gap: 8px; padding: 4px 6px; border-radius: 6px; }
.slot.highlight { outline: 2px solid #22c55e; background: #ecfdf5; }
.storage { display: flex; gap: 6px; flex-wrap: wrap; }
.storage button { padding: 6px 10px; }

.output { border-top: 1px solid #e5e7eb; background: #fff; padding: 10px 12px; position: sticky; bottom: 0; z-index: 5; }
.output h3 { margin: 0 0 6px 0; }
.stdout { margin: 0; width: 100%; max-height: 20vh; overflow: auto; background: #0b1021; color: #e5e7eb; border-radius: 8px; padding: 10px; }

/* SVG styles */
.node { stroke: #1f2937; fill: #ffffff; cursor: move; }
.node > text { pointer-events: none; }
.node.selected > :is(rect,ellipse,polygon) { stroke: #2563eb; stroke-width: 2; }
.node-label { font-size: 12px; fill: #111827; pointer-events: none; user-select: none; }
.edge { stroke: #111827; stroke-width: 1.5; fill: none; marker-end: url(#arrow); cursor: pointer; }
.edge.selected { stroke: #2563eb; stroke-width: 2; }
.edge.reverse-edge { stroke: #dc2626; stroke-dasharray: 5,5; }
.edge-label { font-size: 11px; fill: #111827; user-select: none; }
.token { fill: #ef4444; }

/* Floating prompt */
.modal {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,0.4);
}
.modal.open { display: flex; }
.modal .panel {
  background: #fff; padding: 16px; border-radius: 10px; width: min(360px, 92vw); display: grid; gap: 10px; border: 1px solid #e5e7eb;
}
.modal .panel input { padding: 8px; border: 1px solid #cbd5e1; border-radius: 6px; }
.modal .panel .actions { display: flex; gap: 8px; justify-content: flex-end; }


