* {
  box-sizing: border-box;
  font-family: 'Segoe UI', sans-serif;
}

body {
  margin: 0;
  background: #f4f4f4;
  color: #333;
}

header {
  background: linear-gradient(90deg, #673ab7, #3f51b5);
  color: #fff;
  padding: 1rem 2rem;
  font-size: 1.5rem;
  font-weight: bold;
}

main {
  display: flex;
  flex-wrap: wrap;
  padding: 20px;
  gap: 20px;
}

.left-panel {
  flex: 2;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.toolbar {
  background: #e3f2fd;
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* 🎨 Top Color Section */
.color-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  background: #ffffff;
  padding: 14px 20px;
  border-radius: 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.color-row label {
  font-weight: 600;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.color-row input[type="color"] {
  width: 50px;
  height: 40px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  padding: 0;
}

.color-row input#artName {
  flex: 1;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid #ccc;
  font-size: 15px;
}

.color-row .btn.publish {
  background: linear-gradient(to right, #673ab7, #3f51b5);
  color: white;
  font-weight: bold;
  border-radius: 12px;
  padding: 10px 20px;
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
  border: none;
  transition: background 0.3s, transform 0.1s ease;
}

.color-row .btn.publish:hover {
  background: linear-gradient(to right, #5e35b1, #3949ab);
}

.color-row .btn.publish:active {
  transform: scale(0.96);
}

/* 🎨 Tool Groups */
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.group {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  padding: 12px 16px;
  border-radius: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  font-weight: 600;
}

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

.group span {
  font-weight: 600;
  font-size: 16px;
}

.group button {
  background: #f4f4f4;
  border: none;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.group button:hover {
  background: #dbeafe;
}

.group button:active {
  transform: scale(0.95);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* ✅ Universal active state (for eraser/brush/smooth/pixel) */
.group button.active-tool {
  background: #3b82f6 !important;
  color: #fff !important;
  border: 2px solid #1e40af;
  font-weight: bold;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
  transform: scale(0.98);
}

/* 🧭 Brush Modes Defaults */
.group button#smoothBtn,
.group button#pixelBtn {
  background: #111;
  color: white;
  font-weight: 500;
  border: 2px solid #111;
}

.group button#smoothBtn.active-tool,
.group button#pixelBtn.active-tool {
  background: #3b82f6;
  border-color: #1e3a8a;
}

.group button#smoothBtn:hover,
.group button#pixelBtn:hover {
  background: #3b82f6;
  color: white;
}

/* ↩️ ↪️ 🗑 Action Row */
.row.actions button {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 18px;
  cursor: pointer;
  transition: 0.2s;
}

.row.actions button:hover {
  background: #e0f2fe;
}

.row.actions button:active {
  transform: scale(0.95);
}

/* ✅ General Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 10px;
  background: #2196f3;
  color: #fff;
  cursor: pointer;
  font-weight: bold;
  transition: 0.3s ease;
}

.btn:hover {
  background: #1976d2;
}

.btn:active {
  transform: scale(0.95);
}

.btn.download {
  width: 100%;
  background: #03a9f4;
  font-weight: bold;
}

/* 🖌 Canvas */
canvas {
  image-rendering: pixelated;
  width: 100%;
  height: auto;
  border: 3px solid #2196f3;
  border-radius: 8px;
  background: #fff;
  display: block;
}

/* 🖼 Gallery */
.gallery-panel {
  flex: 1;
  min-width: 250px;
}

.gallery-panel h2 {
  margin-top: 0;
}

.gallery {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.art {
  border: 1px solid #ccc;
  padding: 8px;
  background: #fff;
  border-radius: 6px;
  text-align: center;
}

.art img {
  max-width: 100%;
  max-height: 150px;
  object-fit: contain;
}

.art span {
  display: block;
  margin-top: 5px;
}

.art .actions {
  margin-top: 5px;
  display: flex;
  justify-content: center;
  gap: 5px;
}

/* 📱 Responsive */
@media (max-width: 768px) {
  main {
    flex-direction: column;
  }

  .toolbar {
    gap: 0.5rem;
  }

  .color-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .color-row input#artName {
    width: 100%;
  }
}