*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #111827;
  color: #f9fafb;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: row;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at top left, #1f2933, #020617);
}

.toolbar {
  display: flex;
  flex-direction: column;
  padding: 1.2rem 0.9rem;
  gap: 1.2rem;
  background: rgba(15, 23, 42, 0.96);
  border-radius: 0.75rem;
  margin: 0.75rem;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(16px);
}

.toolbar-left {
  width: 220px;
  position: relative;
  overflow: visible;
}

.toolbar-right {
  width: 80px;
  align-items: center;
  justify-content: flex-start;
  gap: 1.5rem;
  padding-top: 1.2rem;
}

.toolbar-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.app-title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.control-label {
  font-size: 0.9rem;
  color: #9ca3af;
}

.control-input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 100%;
  height: 40px;
  border-radius: 0.6rem;
  background: #020617;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.4);
  padding: 4px;
}

.control-input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.control-input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 0.5rem;
}

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

.brush-preview {
  margin-top: 0.4rem;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #000;
  border: 2px solid #e5e7eb;
}

.canvas-wrapper {
  flex: 1;
  margin: 0.75rem 0;
  position: relative;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.5);
  background: #f9fafb;
  touch-action: none; /* allow drawing without scrolling */
}

#drawingCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #f9fafb;
  touch-action: none;
}

.icon-button {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: none;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0ea5e9, #22c55e);
  color: #f9fafb;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.icon-button.danger {
  background: linear-gradient(135deg, #f97316, #ef4444);
}

.icon-button:active {
  transform: scale(0.96);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

.toolbar-toggle {
  position: absolute;
  top: 50%;
  right: -22px;
  transform: translateY(-50%);
  width: 40px;
  height: 80px;
  border-radius: 999px;
  border: none;
  background: #0ea5e9;
  color: #f9fafb;
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease,
    box-shadow 0.15s ease, transform 0.15s ease;
}

.toolbar-toggle:active {
  transform: translateY(-50%) scale(0.96);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
}

.toolbar-left.collapsed {
  width: 40px;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.toolbar-left.collapsed .toolbar-section {
  display: none;
}

#clearBtn {
  margin-top: auto;
  margin-bottom: auto;
}

.toolbar-left.collapsed .toolbar-toggle {
  position: absolute;
  right: -22px;
  background: #0ea5e9;
  color: #f9fafb;
  font-size: 1.8rem;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.7);
}


@media (max-width: 960px) {
  .toolbar-left {
    width: 180px;
  }

  .toolbar-right {
    width: 70px;
  }
}

