/* ── Colouring Crafts Tool — colouringcrafts.com ── */
.cc-wrap {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  box-sizing: border-box;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.07);
}
.cc-wrap *, .cc-wrap *::before, .cc-wrap *::after { box-sizing: border-box; }

/* ── Toolbars ─────────────────────────────────────────── */
.cc-toolbar {
  background: #ffffff;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1.5px solid #f0f0f0;
}
.cc-toolbar:last-of-type { border-bottom: none; }

/* ── Sections ─────────────────────────────────────────── */
.cc-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cc-section-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #aaa;
  line-height: 1;
  padding-left: 2px;
  display: block;
}

/* ── Pill tool selector ───────────────────────────────── */
.cc-pill-group {
  display: flex;
  align-items: center;
  background: #f4f4f4;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  flex-wrap: wrap;
}
.cc-pill {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 500;
  color: #555;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  line-height: 1;
}
.cc-pill:hover { background: #ebebeb; color: #222; }
.cc-pill.active {
  background: #ffffff;
  color: #2563eb;
  box-shadow: 0 1px 4px rgba(0,0,0,0.13), 0 0 0 1px rgba(0,0,0,0.06);
}
.cc-pill svg { flex-shrink: 0; }

/* ── Mobile colour picker (inside tools row, hidden on desktop/tablet) ── */
.cc-mobile-colour {
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 4px 6px;
  gap: 3px;
}
.cc-mobile-picker {
  position: relative;
  width: 36px;
  height: 36px;
  cursor: pointer;
  flex-shrink: 0;
}
.cc-mobile-picker input[type=color] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
}
.cc-mobile-picker-preview {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px #ccc, 0 2px 6px rgba(0,0,0,0.15);
  background: #e74c3c;
  pointer-events: none;
  transition: background 0.1s;
}

/* ── Brush size ───────────────────────────────────────── */
.cc-size-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f4f4f4;
  border-radius: 10px;
  padding: 6px 10px;
  height: 36px;
}
.cc-size-preview-dot {
  border-radius: 50%;
  background: #333;
  flex-shrink: 0;
  transition: width 0.1s, height 0.1s, background 0.1s;
  min-width: 4px;
  min-height: 4px;
}
.cc-size-slider {
  width: 90px;
  accent-color: #2563eb;
  cursor: pointer;
}

/* ── Colour row (desktop + tablet, hidden on mobile) ───── */
.cc-toolbar-colours { display: flex; justify-content: center; }
.cc-section-colour { flex: 0 0 auto; }
.cc-palette-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f4f4f4;
  border-radius: 10px;
  padding: 6px 12px;
  flex-wrap: nowrap;
}

/* On desktop, brush size moves to colour row - match heights */
.cc-toolbar-colours .cc-section-size { flex: 0 0 auto; }
.cc-toolbar-colours .cc-size-row {
  height: 100%;
  min-height: 40px;
}

/* Hide brush size from top row on desktop, show in colour row */
.cc-toolbar-top .cc-section-size    { display: none; }
.cc-toolbar-colours .cc-section-size { display: flex; }
.cc-palette {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
}
.cc-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
  flex-shrink: 0;
}
.cc-swatch:hover { transform: scale(1.18); box-shadow: 0 1px 4px rgba(0,0,0,0.18); }
.cc-swatch.selected {
  border-color: #2563eb;
  transform: scale(1.22);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.25);
}
.cc-swatch[data-color="#ffffff"] { border-color: #ccc; }

.cc-custom-wrap {
  position: relative;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  cursor: pointer;
}
.cc-custom-wrap input[type=color] {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #ccc;
  cursor: pointer;
  padding: 0;
  background: none;
}
.cc-custom-wrap svg {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: #fff;
  border-radius: 50%;
  padding: 1px;
  color: #555;
  pointer-events: none;
}

/* ── Action buttons ───────────────────────────────────── */
.cc-action-group {
  display: flex;
  align-items: center;
  gap: 3px;
  background: #f4f4f4;
  border-radius: 10px;
  padding: 3px;
}
.cc-action-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  color: #555;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.13s, color 0.13s;
  white-space: nowrap;
  line-height: 1;
}
.cc-action-btn:hover     { background: #e8e8e8; color: #222; }
.cc-action-btn svg       { flex-shrink: 0; }
.cc-action-danger:hover  { background: #ffe4e4; color: #c0392b; }
.cc-action-save          { color: #166534; }
.cc-action-save:hover    { background: #dcfce7; color: #14532d; }

.cc-zoom-label {
  font-size: 11px;
  font-weight: 600;
  color: #888;
  min-width: 38px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  padding: 0 2px;
}

/* ── Canvas ───────────────────────────────────────────── */
.cc-canvas-wrap {
  position: relative;
  background: #d0d0d0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#cc-canvas {
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* ── Tooltip ──────────────────────────────────────────── */
.cc-tooltip {
  position: fixed;
  background: rgba(30,30,30,0.92);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 9px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 9999;
  white-space: nowrap;
}
.cc-tooltip.visible { opacity: 1; }

/* ── Loading ──────────────────────────────────────────── */
.cc-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #f9f9f9;
  font-size: 14px;
  color: #888;
}
.cc-loading.hidden { display: none; }
.cc-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e0e0e0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: cc-spin 0.7s linear infinite;
}
@keyframes cc-spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════
   TABLET  (560px – 1024px)
   - Colour row stays but swatches are bigger + horizontal
   - Brush size moves back to top row
   ══════════════════════════════════════════════════════ */
@media (min-width: 561px) and (max-width: 1024px) {
  .cc-toolbar-top .cc-section-size    { display: flex; }
  .cc-toolbar-colours .cc-section-size { display: none; }
  .cc-swatch { width: 32px; height: 32px; }
  .cc-palette { gap: 7px; }
  .cc-palette-row { padding: 8px 12px; gap: 8px; }
  .cc-custom-wrap,
  .cc-custom-wrap input[type=color] { width: 36px; height: 36px; }
  .cc-pill       { padding: 7px 10px; font-size: 12px; }
  .cc-size-slider       { width: 80px; }
  .cc-action-btn { padding: 7px 10px; }
  .cc-toolbar    { gap: 10px; padding: 10px 12px; }
}

/* ══════════════════════════════════════════════════════
   MOBILE  (≤ 560px)
   - Colour row hidden, mobile picker shown in tools row
   - Brush size moves back to top row
   - Toolbar moves to bottom
   ══════════════════════════════════════════════════════ */
@media (max-width: 560px) {
  .cc-toolbar-top .cc-section-size     { display: flex; }
  .cc-toolbar-colours .cc-section-size { display: none; }

  /* Stack order: canvas top, toolbars bottom */
  .cc-wrap            { display: flex; flex-direction: column; }
  .cc-toolbar-top     { order: 2; border-top: 1.5px solid #f0f0f0; border-bottom: 1.5px solid #f0f0f0; }
  .cc-toolbar-colours { display: none; }
  .cc-toolbar-bottom  { order: 3; border-bottom: none; }
  .cc-canvas-wrap     { order: 1; }

  /* Show mobile colour picker inside tools row */
  .cc-mobile-colour { display: flex; }

  .cc-toolbar       { gap: 6px; padding: 8px 10px; justify-content: center; }
  .cc-pill-group    { flex-wrap: wrap; justify-content: center; }
  .cc-pill          { padding: 7px 9px; font-size: 11px; gap: 4px; }
  .cc-size-slider          { width: 70px; }
  .cc-action-btn    { padding: 6px 8px; font-size: 11px; }
  .cc-section-size  { width: 100%; }
  .cc-size-row      { width: 100%; }
  .cc-size-slider          { flex: 1; }
}

/* ── Print ────────────────────────────────────────────── */
@media print {
  .cc-toolbar-top, .cc-toolbar-colours, .cc-toolbar-bottom { display: none !important; }
  .cc-canvas-wrap { border-radius: 0 !important; }
  .cc-wrap        { box-shadow: none !important; }
}
