* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
  font-family: sans-serif; 
  background: #e8e8e8; 
  margin: 50px;
}

#app { max-width: 980px; margin: 0 auto; padding: 10px; }

#canvas-wrap {
  width: 100%;
  background: white;
  border: 1px solid #bbb;
  overflow: hidden;
  line-height: 0;
}

#p5-canvas-container svg,
#p5-canvas-container canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
  touch-action: none;
}

#toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  padding: 10px 12px;
  background: white;
  border: 1px solid #ccc;
  border-radius: 6px;
}

#palette {
  display: flex;
  gap: 8px;
}

.color-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  outline: none;
  transition: transform 0.1s;
}

.color-btn.active {
  border-color: #222;
  transform: scale(1.25);
}

#stroke-sizes {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 8px;
  border-left: 1px solid #ddd;
}

.size-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: #eee;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
}

.size-btn span {
  display: block;
  border-radius: 50%;
  background: #555;
}

.size-btn.active {
  border-color: #222;
  transform: scale(1.2);
}

#edit-btns {
  display: flex;
  gap: 6px;
  margin-left: 8px;
  padding-left: 10px;
  border-left: 1px solid #ddd;
}

#undo-btn,
#clear-btn {
  padding: 7px 14px;
  background: #ccc;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

#undo-btn:hover,
#clear-btn:hover { background: #bbb; }

#submit-btn {
  margin-left: auto;
  padding: 7px 20px;
  background: #3a9e5f;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
}

#submit-btn:hover { background: #2d7d4b; }
#submit-btn:disabled { background: #999; cursor: not-allowed; }

#gallery { margin-top: 24px; }
#gallery h2 { font-size: 16px; margin-bottom: 10px; color: #444; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.gallery-item {
  background: transparent;
  
  border-radius: 4px;
  overflow: hidden;
}

.gallery-item img {
  width: 100%;
  display: block;
}

.gallery-item .meta {
  font-size: 11px;
  color: #888;
  padding: 4px 6px;
}

#pagination {
  display: flex;
  gap: 6px;
  margin-top: 14px;
  justify-content: center;
}

#pagination button {
  padding: 5px 12px;
  border: 1px solid #bbb;
  background: white;
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
}

#pagination button.active {
  background: #3a9e5f;
  color: white;
  border-color: #3a9e5f;
}

#status {
  font-size: 13px;
  color: #666;
  margin-left: 8px;
}



#editor-toggle-btn {
  padding: 7px 14px;
  background: #444;
  color: #eee;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}
#editor-toggle-btn:hover { background: #333; }
#editor-toggle-btn.active { background: #3a9e5f; color: white; }

#code-editor-section {
  margin: 8px 0;
  background: #282a36;
  border-radius: 6px;
  overflow: hidden;
}

#code-editor-tabs {
  display: flex;
  align-items: center;
  background: #1e1f29;
  gap: 0;
}

.tab-btn {
  padding: 8px 18px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #888;
  cursor: pointer;
  font-size: 13px;
  font-family: monospace;
  white-space: nowrap;
}

.tab-btn:hover { color: #ccc; }

.tab-btn.active {
  color: #fff;
  border-bottom-color: #3a9e5f;
}

#code-editor-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px;
  margin-left: auto;
}

#code-editor-status {
  font-size: 12px;
  font-family: monospace;
  color: #f48771;
}

#code-run-btn, #code-reset-btn {
  padding: 4px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
#code-run-btn { background: #3a9e5f; color: white; }
#code-run-btn:hover { background: #2d7d4b; }
#code-reset-btn { background: #555; color: #ccc; }
#code-reset-btn:hover { background: #444; }

#code-editor-wrap .CodeMirror {
  height: 720px;
  font-size: 13px;
  line-height: 1.6;
  font-family: 'Fira Code', 'Courier New', monospace;
}

#overlay-section { margin-top: 32px; }

#overlay-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

#overlay-header h2 { font-size: 16px; color: #444; }

#shuffle-btn,
#copy-btn {
  padding: 5px 14px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

#shuffle-btn { background: #ccc; }
#shuffle-btn:hover { background: #bbb; }

#copy-btn { background: #3a9e5f; color: white; }
#copy-btn:hover { background: #2d7d4b; }
#copy-btn:disabled { background: #999; cursor: not-allowed; }

#overlay-wrap {
  width: 100%;
  background: white;
  border: 1px solid #bbb;
  overflow: hidden;
  line-height: 0;
}

#overlay-canvas {
  display: block;
  width: 100%;
  height: auto;
}
