/* Professional White Theme with Blue Accents */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #ffffff;
  color: #2c3e50;
  min-height: 100vh;
  padding: 20px;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.color-picker-container {
  display: flex;
  flex-direction: row;
  justify-content: space-evenly;
  align-items: center;
  gap: 20px;
  margin-bottom: 10px
}

/* Fullscreen behavior is mobile-only (see media query below) */

/* Header */
#header {
  position: fixed;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1rem;
  font-weight: 700;
  color: #2563eb;
  text-shadow: none;
  z-index: 1000;
  background: transparent;
  padding: 2px 4px;
}

/* Mobile Clear Icon - Blue like eye icon, positioned next to it */
#clearCanvas {
  color: #2563eb;
  font-size: 14px;
  cursor: pointer;
  background: white;
  padding: 4px;
  border-radius: 50%;
  border: 2px solid #e5e7eb;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  transition: all 0.3s ease;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 8px;
  left: calc(320px + 90px);
  z-index: 4001;
}

#clearCanvas:hover {
  border-color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.2);
}

/* Top Navigation Icons */
.top-icons {
  position: fixed;
  top: 8px;
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 40px;
  z-index: 999;
}

.top-icons > div:last-child {
  padding-right: 20px;
}

.right-icons {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 20px;
}

#toggleCanvas {
  color: #2563eb;
  font-size: 14px;
  cursor: pointer;
  background: white;
  padding: 4px;
  border-radius: 50%;
  border: 2px solid #e5e7eb;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  transition: all 0.3s ease;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 8px;
  left: calc(320px + 20px);
  z-index: 4001;
}

/* Hide small-screen helper icons by default on large screens */
.fs-controls { display: none; }

/* Desktop: show only a blue Clear icon next to the eye */
@media (min-width: 769px) {

  .fs-controls-desktop {
    position: fixed;
    top: 8px;
    left: calc(320px + 100px);
    z-index: 4001;
    display: flex;
    gap: 12px;
    align-items: center;
  }
  .fs-controls-desktop i {
    width: 24px;
    height: 24px;
    font-size: 12px;
    background: white;
    border: 2px solid #2563eb;
    color: #2563eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

#toggleCanvas:hover {
  border-color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.2);
}

#add {
  width: 24px;
  height: 24px;
  cursor: pointer;
  background: #2563eb;
  padding: 4px;
  border-radius: 50%;
  border: 2px solid #2563eb;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  transition: all 0.3s ease;
  filter: brightness(1.1);
}

#add:hover {
  border-color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.2);
}

/* Robot Icon */
#robotIcon {
  width: 24px;
  height: 24px;
  cursor: pointer;
  background: #2563eb;
  padding: 4px;
  border-radius: 50%;
  border: 2px solid #2563eb;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  transition: all 0.3s ease;
  filter: brightness(1.1);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  animation: robotBlink 2s infinite;
}

#robotIcon:hover {
  border-color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.2);
}

/* Blinking animation for robot */
@keyframes robotBlink {
  0%, 90% { opacity: 1; }
  95% { opacity: 0.3; }
  100% { opacity: 1; }
}

/* Settings Icon */
#settingsIcon {
  width: 24px;
  height: 24px;
  cursor: pointer;
  background: #6b7280;
  padding: 4px;
  border-radius: 50%;
  border: 2px solid #6b7280;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  transition: all 0.3s ease;
  filter: brightness(1.1);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

#settingsIcon:hover {
  border-color: #374151;
  background: #374151;
  transform: translateY(-2px) rotate(90deg);
  box-shadow: 0 4px 20px rgba(55, 65, 81, 0.2);
}

/* AI Settings Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  z-index: 2000;
}

.modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  z-index: 2001;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #e5e7eb;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: white;
  border-radius: 12px 12px 0 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.modal-header i.fa-times {
  cursor: pointer;
  font-size: 18px;
  padding: 8px;
  border-radius: 50%;
  transition: background 0.3s ease;
}

.modal-header i.fa-times:hover {
  background: rgba(255, 255, 255, 0.2);
}

.modal-body {
  padding: 24px;
}

.setting-group {
  margin-bottom: 20px;
}

.setting-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #374151;
}

.setting-group textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  transition: border-color 0.3s ease;
}

.setting-group textarea:focus,
.setting-group select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.setting-group select {
  width: 100%;
  padding: 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  background: white;
  transition: border-color 0.3s ease;
}

.setting-group input[type="range"] {
  width: 100%;
  margin: 8px 0;
}

.slider-help {
  font-size: 12px;
  color: #6b7280;
  font-style: italic;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
}

.btn-primary,
.btn-secondary {
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 2px solid #e5e7eb;
}

.btn-secondary:hover {
  background: #e5e7eb;
}

/* Processing Overlay */
.processing-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.9), rgba(59, 130, 246, 0.9));
  backdrop-filter: blur(10px);
  z-index: 3000;
  justify-content: center;
  align-items: center;
}

.processing-content {
  text-align: center;
  color: white;
}

.processing-icon {
  font-size: 4rem;
  margin-bottom: 20px;
  animation: processingPulse 1.5s ease-in-out infinite;
}

.processing-text {
  font-size: 2rem;
  margin-bottom: 30px;
  animation: processingGlow 2s ease-in-out infinite alternate;
}

.processing-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.processing-dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: white;
  animation: processingBounce 1.4s ease-in-out infinite both;
}

.processing-dots span:nth-child(1) { animation-delay: -0.32s; }
.processing-dots span:nth-child(2) { animation-delay: -0.16s; }
.processing-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes processingPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes processingGlow {
  0% { text-shadow: 0 0 20px rgba(255, 255, 255, 0.5); }
  100% { text-shadow: 0 0 30px rgba(255, 255, 255, 0.8), 0 0 40px rgba(255, 255, 255, 0.6); }
}

@keyframes processingBounce {
  0%, 80%, 100% { 
    transform: scale(0);
  } 
  40% { 
    transform: scale(1);
  }
}

/* Result Modal */
.result-modal {
  max-width: 700px;
}

.result-image-container {
  text-align: center;
  margin-bottom: 24px;
  max-height: 400px;
  overflow: hidden;
  border-radius: 8px;
  background: #f3f4f6;
}

.result-image-container img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.download-options h4 {
  margin: 0 0 16px 0;
  color: #374151;
  font-weight: 600;
}

.download-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.download-btn {
  padding: 12px 20px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  background: white;
  color: #374151;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.download-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* App Container with Sidebar Layout */
.app-container {
  display: flex;
  height: 100vh;
  margin-top: 10px;
}

.app-container select {
  font-size: 16px;
  text-align: center;
}

/* Left Tools Sidebar */
.tools-sidebar {
  width: 320px;
  background: #f8fafc;
  border-right: 2px solid #e5e7eb;
  overflow-y: auto;
  padding: 20px;
  position: fixed;
  left: 0;
  top: 10px;
  bottom: 0;
  z-index: 10;
  transition: all 0.3s ease;
}

/* Hidden state for tools sidebar */
.tools-sidebar.hidden {
  transform: translateX(-100%);
}

/* Main Canvas Container */
.canvas-container {
  margin-left: 320px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  gap: 10px;
  margin-top: 20px;
  overflow: hidden;
  transition: all 0.3s ease;
}

/* Canvas container when sidebar is hidden */
.canvas-container.fullscreen {
  margin-left: 0;
  left: 0;
  right: 0;
  width: 100vw;
  padding: 10px;
}

/* Eye icon positioning when sidebar is hidden */
.tools-sidebar.hidden ~ * #toggleCanvas {
  left: 20px !important;
}

/* Canvas Styling */
#canvas {
  background: white;
  border: 3px solid #2563eb;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  width: calc(100vw - 360px);
  height: calc(100vh - 100px);
  max-width: calc(100vw - 360px);
  max-height: calc(100vh - 100px);
  touch-action: none;
  transition: all 0.3s ease;
}

/* Canvas fullscreen styling */
@media (max-width: 768px) {
  body.fullscreen-mode {
    padding: 0 !important;
    overflow: hidden !important;
    display: flex !important;
  }
  body.fullscreen-mode .top-icons,
  body.fullscreen-mode footer,
  body.fullscreen-mode #header {
    display: none !important;
  }
  .canvas-container.fullscreen {
    margin: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    padding: 0 !important;
    align-items: center !important;
    justify-content: center !important;
  }
  #canvas.fullscreen {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    z-index: 2500;
  }
}

#canvas:hover {
  border-color: #2563eb;
  box-shadow: 0 8px 30px rgba(37, 99, 235, 0.15);
}

/* Drawing Mode Selector */
#drawingMode {
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 15px;
  font-size: 14px;
  color: #374151;
  width: 100%;
  max-width: 100%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: all 0.3s ease;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  padding-right: 35px;
  text-align: center;
}

#drawingMode:hover {
  border-color: #2563eb;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.1);
}

#drawingMode:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

optgroup {
  font-weight: 600;
  color: #2563eb;
  background: #f8fafc;
}

option {
  padding: 8px;
  color: #374151;
  background: white;
}

/* Tool Buttons Container */
.tool-section.tool-buttons {
  display: flex;
  flex-direction: row;
  justify-content: space-evenly;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: white;
  padding: 12px;
  border-radius: 10px;
  border: 2px solid #e5e7eb;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

/* Action Buttons - ensure they're always in a row */
.tool-buttons {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px;
  flex-wrap: wrap;
}

.tool-icon {
  font-size: 14px;
  cursor: pointer;
  color: #6b7280;
  background: #f9fafb;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.3s ease;
  border: 2px solid transparent;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool-icon:hover {
  background: #2563eb;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

/* Color Picker */
#color {
  height: 36px;
  width: 36px;
  border: 2px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  transition: all 0.3s ease;
}

#color:hover {
  border-color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.2);
}

/* Color Palette */
.colors {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  background: white;
  padding: 12px;
  border-radius: 10px;
  border: 2px solid #e5e7eb;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  max-width: 600px;
}

.strokeColor {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid #e5e7eb;
  transition: all 0.3s ease;
  position: relative;
}

.strokeColor:hover {
  transform: scale(1.1);
  border-color: #2563eb;
  box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

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

/* Stroke Width Controls */
.strokeWidth {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: white;
  padding: 12px;
  border-radius: 10px;
  border: 2px solid #e5e7eb;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  width: 90%;
  margin: 5px auto;
}

.strokeWidth > div {
  width: 34px;
  height: 34px;
  border: 2px solid #e5e7eb;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: white;
  color: #6b7280;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  user-select: none;
}

.strokeWidth > div:hover {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
  transform: scale(1.1);
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

.strokeWidth > div:active {
  transform: scale(0.95);
}

/* Range Slider */
input[type="range"] {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #e5e7eb;
  outline: none;
  margin: 10px 0;
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #2563eb;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: all 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: #1d4ed8;
  transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #2563eb;
  cursor: pointer;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

#strokeWidthValue {
  font-size: 12px;
  font-weight: 600;
  color: #2563eb;
  background: white;
  padding: 4px 8px;
  border-radius: 20px;
  border: 2px solid #e5e7eb;
  min-width: 50px;
  text-align: center;
}

/* Footer */
footer {
  text-align: center;
  margin-top: 60px;
  padding: 30px;
  background: white;
  border-radius: 16px;
  border: 2px solid #e5e7eb;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

footer p {
  font-size: 16px;
  color: #6b7280;
  font-weight: 500;
}

/* Responsive Design */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
    margin-top: 60px;
    overflow-x: hidden;
    height: calc(100vh - 60px);
  }


  .tools-sidebar {
    position: relative;
    min-width: 100%;
    height: 200px !important;
    flex: 0 0 200px;
    top: 0;
    left: 0;
    right: 0;
    overflow-x: auto;
    overflow-y: hidden !important;
    display: flex;
    flex-direction: row;
    gap: 10px;
    border-right: none;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  /* Ensure horizontal layout restoration on toggle */
  .tools-sidebar.mobile-horizontal {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: scroll !important;
    overflow-y: hidden !important;
    white-space: nowrap !important;
  }

  .canvas-container {
    margin-left: 0px;
    width: 100%;
    overflow: hidden;
    text-align: center;
    position: relative;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
  }


  #header {
    font-size: 1.5rem;
    padding: 8px 20px;
  }

  #canvas {
    width: calc(100vw - 40px) !important;
    max-width: calc(100vw - 40px) !important;
    height: 100% !important;
    max-height: 100% !important;
    box-sizing: border-box;
    margin: 0 auto;
    display: block;
  }

  #drawingMode {
    /* Keep same sizing as large screens */
    font-size: 14px;
    padding: 8px 15px;
    min-width: initial;
    text-align: center;
  }

  .tool-buttons {
    display: flex;
    flex-direction: row;
    gap: 6px;
    padding: 8px;
    justify-content: center;
    width: 100%;
    align-items: center;
    flex-wrap: wrap;
  }

  .tool-icon {
    width: 32px;
    height: 32px;
    font-size: 14px;
    color: #374151;
    background: white;
  }

  /* Hide the black eraser in Action Buttons section on mobile - we have blue one now */
  .tool-buttons .fa-eraser {
    display: none !important;
  }

  .colors {
    gap: 4px;
    padding: 8px;
    justify-content: center;
  }

  .strokeColor {
    width: 22px;
    height: 22px;
  }

  .strokeWidth {
    gap: 6px;
    padding: 10px;
    justify-content: center;
    width: 90%;
  }

  .strokeWidth div {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }

  input[type="range"] {
    width: 100%;
  }

  .top-icons {
    padding: 0 15px;
  }

  .top-icons > div:last-child {
    padding-right: 15px;
  }

  .right-icons {
    gap: 8px;
    padding-right: 15px;
  }

  #toggleCanvas {
    position: fixed !important;
    left: 15px !important;
    top: 8px !important;
    width: 24px;
    height: 24px;
  }

  /* Mobile Clear Icon - Blue like eye icon, positioned next to it */
  #clearCanvas {
    position: fixed !important;
    left: 65px !important;
    top: 8px !important;
    width: 24px;
    height: 24px;
    color: #2563eb;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    z-index: 4001;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
  }

  #clearCanvas:hover {
    border-color: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.2);
  }


  #add {
    width: 24px;
    height: 24px;
  }

  #robotIcon {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  #settingsIcon {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .modal {
    width: 95%;
    max-height: 90vh;
  }

  .modal-body {
    padding: 16px;
  }

  .btn-primary,
  .btn-secondary {
    padding: 10px 16px;
    font-size: 13px;
  }

  .processing-text {
    font-size: 1.5rem;
  }

  .processing-icon {
    font-size: 3rem;
  }

  .download-buttons {
    flex-direction: column;
    gap: 8px;
  }

  .download-btn {
    padding: 10px 16px;
    justify-content: center;
  }

  #color {
    height: 30px;
    width: 30px;
  }

  .section-title {
    font-size: 14px;
    margin-bottom: 8px;
  }
}

@media (max-width: 480px) {
  .tools-sidebar {
    overflow-x: scroll;
    overflow-y: hidden;
    padding: 0;
    display: flex;
    gap: 8px;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    margin-left: 0;
    margin-right: 0;
  }


  #header {
    font-size: 1.3rem;
    padding: 6px 15px;
  }

  #drawingMode {
    /* Keep same sizing as large screens */
    font-size: 14px;
    padding: 8px 15px;
    min-width: initial;
    text-align: center;
  }

  .tool-buttons {
    display: flex;
    flex-direction: row;
    gap: 4px;
    padding: 6px;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
    align-items: center;
  }

  .tool-icon {
    width: 30px;
    height: 30px;
    font-size: 16px;
    color: #374151;
    background: white;
  }

  /* Hide the black eraser in Action Buttons section on mobile - we have blue one now */
  .tool-buttons .fa-eraser {
    display: none !important;
  }

  .colors {
    gap: 3px;
    padding: 6px;
  }

  .strokeColor {
    width: 20px;
    height: 20px;
  }

  .strokeWidth {
    gap: 5px;
    padding: 8px;
    width: 90%;
  }

  .strokeWidth div {
    width: 26px;
    height: 26px;
    font-size: 10px;
  }

  input[type="range"] {
    width: 100%;
  }

  #color {
    height: 28px;
    width: 28px;
  }

  .section-title {
    font-size: 13px;
  }

  #toggleCanvas {
    position: fixed !important;
    left: 15px !important;
    top: 8px !important;
    width: 24px;
    height: 24px;
  }

  /* Mobile Clear Icon - Blue like eye icon, positioned next to it */
  #clearCanvas {
    position: fixed !important;
    left: 65px !important;
    top: 8px !important;
    width: 24px;
    height: 24px;
    color: #2563eb;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    z-index: 4001;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
  }

  #clearCanvas:hover {
    border-color: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.2);
  }

  .color-picker-container {
    flex-direction: row !important;
    gap: 10px;
  }

  .slider-container {
    flex-direction: row !important;
    gap: 10px;
  }
}

/* Tool Sections in Sidebar */
.tool-section {
  background: white;
  width: 100%;
  height: auto;
  text-align: center;
  font-size: 16px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 15px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.tool-section:hover {
  border-color: #2563eb;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.12);
  transform: translateY(-2px);
}



.section-title {
  font-size: 16px;
  font-weight: 600;
  color: #2563eb;
  margin: 0 0 15px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid #e5e7eb;
  text-align: center;
}

/* Color Controls */
.color-controls {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.color-picker-container {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}

.color-picker-container label {
  font-size: 14px;
  font-weight: 500;
  color: #374151;
}

/* Brush Controls */
.brush-controls {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 15px;
  justify-content: center;
  flex-direction: row;
}

/* Responsive Grid */
@media (max-width: 1200px) {
  .tools-container {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
  }
}

@media (max-width: 768px) {
  .tools-container {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 15px 10px;
  }

  .tool-section {
    padding: 15px;
    display: flex;
    flex-direction: column;
    min-width: 280px;
    flex-shrink: 0;
    font-size: 16px;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 180px;
  }

  .section-title {
    font-size: 18px;
    margin-bottom: 12px;
  }
}

@media (max-width: 480px) {
  .tools-container {
    gap: 10px;
    padding: 10px 5px;
  }

  #header {
    top: 50px;
  }
  .color-picker-container {
    flex-direction: row !important;
    gap: 10px;
  }

  .slider-container {
    flex-direction: row !important;
    gap: 10px;
  }
}

/* Professional animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.canvas-container > * {
  animation: fadeInUp 0.6s ease-out;
}

/* Focus states for accessibility */
.tool-icon:focus,
.strokeColor:focus,
.strokeWidth div:focus {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Active states */
.tool-icon:active {
  transform: translateY(0) scale(0.95);
}

/* Professional hover effects */
.tool-buttons:hover {
  box-shadow: 0 6px 25px rgba(0,0,0,0.08);
}

.colors:hover,
.strokeWidth:hover {
  box-shadow: 0 6px 25px rgba(0,0,0,0.08);
}