:root {
  --pink: #ff6b9d;
  --pink-deep: #e84a7f;
  --mint: #7ee8c4;
  --mint-deep: #3ecf9a;
  --lemon: #ffe566;
  --sky: #a8e0ff;
  --lavender: #c9b6ff;
  --cream: #fff8f0;
  --chocolate: #5c3d2e;
  --panel: rgba(255, 248, 240, 0.94);
  --shadow: 0 8px 28px rgba(92, 61, 46, 0.15);
  --radius: 20px;
  --font: "Fredoka", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: linear-gradient(160deg, #ffe0f0 0%, #d4f5ff 45%, #e8ffd4 100%);
  color: var(--chocolate);
}

#app {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100%;
  min-height: 100vh;
}

/* —— Sidebar —— */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.5rem 1.25rem;
  background: var(--panel);
  border-right: 4px solid rgba(255, 107, 157, 0.35);
  box-shadow: var(--shadow);
  z-index: 2;
  overflow-y: auto;
  backdrop-filter: blur(12px);
}

.sidebar-header h1 {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--pink-deep), #9b6bff, var(--mint-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin-top: 0.25rem;
  font-size: 0.95rem;
  color: #8a6a5a;
  font-weight: 500;
}

.palette h2,
.controls h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a07868;
  margin-bottom: 0.65rem;
  font-weight: 600;
}

.palette-grid {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.palette-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.85rem 1rem;
  border: 3px solid transparent;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 3px 0 rgba(92, 61, 46, 0.08);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--chocolate);
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.palette-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 rgba(92, 61, 46, 0.1);
}

.palette-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(92, 61, 46, 0.08);
}

.palette-btn.active {
  border-color: var(--pink);
  background: linear-gradient(135deg, #fff0f6, #fff);
  box-shadow: 0 0 0 3px rgba(255, 107, 157, 0.2), 0 3px 0 rgba(92, 61, 46, 0.06);
}

.palette-btn .emoji {
  font-size: 1.6rem;
  line-height: 1;
  width: 2rem;
  text-align: center;
}

.palette-btn[data-type="candycane"].active {
  border-color: #ff4d6a;
}

.palette-btn[data-type="gumdrop"].active {
  border-color: #7b68ee;
}

.palette-btn[data-type="lollipop"].active {
  border-color: #ff8c42;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.8rem 1rem;
  border: none;
  border-radius: 14px;
  background: linear-gradient(180deg, #fff, #f5ebe3);
  box-shadow: 0 3px 0 #d4c4b5;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--chocolate);
  transition: transform 0.12s ease, filter 0.12s ease, opacity 0.15s ease;
  position: relative;
}

.tool-btn:hover:not(:disabled) {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.tool-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #d4c4b5;
}

.tool-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tool-btn .icon {
  font-size: 1.15rem;
}

.tool-btn.toggle[aria-pressed="true"] {
  background: linear-gradient(180deg, #ffe566, #ffd24a);
  box-shadow: 0 3px 0 #e0b020;
}

.tool-btn.toggle .toggle-dot {
  margin-left: auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ccc;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.tool-btn.toggle[aria-pressed="true"] .toggle-dot {
  background: #3ecf9a;
  box-shadow: 0 0 8px rgba(62, 207, 154, 0.7);
}

.tool-btn.danger {
  background: linear-gradient(180deg, #ffe8e8, #ffd0d0);
  box-shadow: 0 3px 0 #e8a0a0;
  color: #a03040;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 2px dashed rgba(255, 107, 157, 0.3);
  font-size: 0.88rem;
  color: #8a6a5a;
  line-height: 1.45;
}

.sidebar-footer .hint {
  font-size: 0.78rem;
  opacity: 0.85;
  margin-top: 0.2rem;
}

.sidebar-footer .count {
  margin-top: 0.75rem;
  font-weight: 600;
  color: var(--pink-deep);
  font-size: 0.95rem;
}

/* —— Stage —— */
.stage {
  position: relative;
  min-width: 0;
  background: radial-gradient(ellipse at 50% 20%, #b8e8ff 0%, #87ceeb 40%, #6bb8e8 100%);
}

#c {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.toast {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 0.7rem 1.4rem;
  background: rgba(255, 248, 240, 0.95);
  border: 3px solid var(--pink);
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 5;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* —— Responsive —— */
@media (max-width: 720px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 4px solid rgba(255, 107, 157, 0.35);
    padding: 1rem;
    max-height: 42vh;
  }

  .palette-grid {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .palette-btn {
    flex: 1 1 40%;
    flex-direction: column;
    text-align: center;
    gap: 0.3rem;
    padding: 0.65rem 0.5rem;
    font-size: 0.78rem;
  }

  .controls {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .tool-btn {
    flex: 1 1 45%;
    font-size: 0.8rem;
    padding: 0.65rem 0.5rem;
  }

  .sidebar-footer {
    display: none;
  }
}
