/* Colour & Draw — categories + levels studio */

.cd-body {
  background-color: #fff7e8;
  background-image:
    radial-gradient(circle at 8% 12%, rgba(255, 143, 107, 0.35) 0%, transparent 38%),
    radial-gradient(circle at 92% 8%, rgba(61, 184, 255, 0.28) 0%, transparent 36%),
    radial-gradient(circle at 78% 88%, rgba(30, 200, 176, 0.28) 0%, transparent 42%),
    radial-gradient(circle at 12% 90%, rgba(255, 196, 58, 0.3) 0%, transparent 40%),
    linear-gradient(165deg, #fff7e8 0%, #ffe8c8 28%, #e8f8ff 62%, #e6fff4 100%);
}

.cd-main { padding-bottom: 48px; }

/* —— Hero —— */
.cd-hero {
  position: relative;
  overflow: hidden;
  margin: 18px auto 0;
  width: min(1180px, 94vw);
  border-radius: 28px;
  padding: 36px 28px 40px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.92), rgba(255,248,235,.88)),
    repeating-linear-gradient(-12deg, transparent, transparent 18px, rgba(255,143,107,.06) 18px, rgba(255,143,107,.06) 19px);
  border: 2px solid rgba(26, 43, 74, 0.08);
  box-shadow: 0 18px 40px rgba(26, 43, 74, 0.1);
}

.cd-hero-glow {
  position: absolute;
  inset: -40% auto auto 55%;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,196,58,.45), transparent 70%);
  pointer-events: none;
  animation: cd-float 7s ease-in-out infinite;
}

.cd-hero-inner { position: relative; z-index: 1; max-width: 640px; }

.cd-kicker {
  display: inline-block;
  margin: 0 0 10px;
  font-weight: 800;
  font-size: .85rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #c45a2c;
  background: rgba(255, 196, 58, .35);
  padding: 6px 12px;
  border-radius: 999px;
}

.cd-hero h1 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.05;
  color: var(--ink);
}

.cd-lead {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--muted);
  max-width: 36rem;
}

.cd-hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.cd-stat {
  background: #fff;
  border: 1.5px solid rgba(26,43,74,.1);
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 800;
  font-size: .9rem;
  box-shadow: 0 6px 14px rgba(26,43,74,.06);
  animation: cd-pop .55s ease both;
}

.cd-scribble {
  position: absolute;
  right: 4%;
  bottom: 8%;
  width: 180px;
  height: 120px;
  pointer-events: none;
  opacity: .55;
}
.cd-scribble span {
  position: absolute;
  display: block;
  border-radius: 999px;
  height: 10px;
  transform-origin: left center;
}
.cd-scribble span:nth-child(1) {
  width: 110px; background: #ff8f6b; top: 20px; left: 20px;
  transform: rotate(-18deg); animation: cd-wiggle 3.2s ease-in-out infinite;
}
.cd-scribble span:nth-child(2) {
  width: 90px; background: #3db8ff; top: 52px; left: 40px;
  transform: rotate(12deg); animation: cd-wiggle 3.8s ease-in-out infinite .4s;
}
.cd-scribble span:nth-child(3) {
  width: 70px; background: #1ec8b0; top: 78px; left: 28px;
  transform: rotate(-8deg); animation: cd-wiggle 3.5s ease-in-out infinite .8s;
}

@keyframes cd-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(18px); }
}
@keyframes cd-wiggle {
  0%, 100% { transform: rotate(var(--r, -12deg)) scaleX(1); }
  50% { transform: rotate(calc(var(--r, -12deg) + 6deg)) scaleX(1.05); }
}
@keyframes cd-pop {
  from { opacity: 0; transform: translateY(8px) scale(.96); }
  to { opacity: 1; transform: none; }
}

.cd-section { margin-top: 28px; }
.cd-section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: end;
  gap: 8px;
  margin-bottom: 16px;
}
.cd-section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.65rem;
}
.cd-section-head p {
  margin: 0;
  font-weight: 700;
  color: var(--muted);
}

/* —— Category tiles —— */
.cd-cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.cd-cat-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  padding: 18px 16px 16px;
  border-radius: 22px;
  border: 2px solid rgba(26,43,74,.08);
  background: var(--cd-bg, #fff);
  box-shadow: 0 10px 24px rgba(26,43,74,.08);
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
  animation: cd-pop .5s ease both;
}
.cd-cat-tile:nth-child(1) { animation-delay: .02s; }
.cd-cat-tile:nth-child(2) { animation-delay: .06s; }
.cd-cat-tile:nth-child(3) { animation-delay: .1s; }
.cd-cat-tile:nth-child(4) { animation-delay: .14s; }
.cd-cat-tile:nth-child(5) { animation-delay: .18s; }
.cd-cat-tile:nth-child(6) { animation-delay: .22s; }
.cd-cat-tile:nth-child(7) { animation-delay: .26s; }
.cd-cat-tile:nth-child(8) { animation-delay: .3s; }

.cd-cat-tile:hover {
  transform: translateY(-4px) rotate(-.4deg);
  box-shadow: 0 16px 32px rgba(26,43,74,.14);
}

.cd-cat-tile .cd-cat-ico {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 2rem;
  background: #fff;
  border: 2px solid rgba(26,43,74,.08);
  box-shadow: 0 6px 0 var(--cd-accent, #ffc43a);
}

.cd-cat-tile h3 {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
}
.cd-cat-tile p {
  margin: 0;
  font-size: .88rem;
  font-weight: 600;
  color: var(--muted);
}
.cd-cat-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 8px;
}
.cd-chip {
  font-size: .72rem;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,.85);
  border: 1px solid rgba(26,43,74,.1);
}
.cd-chip.done {
  background: #e8fff4;
  color: #0f7a52;
  border-color: #9de0c0;
}

/* —— Category banner —— */
.cd-cat-banner {
  width: min(1180px, 94vw);
  margin: 18px auto 0;
  border-radius: 24px;
  padding: 22px 24px 26px;
  background: var(--cd-bg, #fff8ef);
  border: 2px solid rgba(26,43,74,.08);
  box-shadow: 0 14px 30px rgba(26,43,74,.08);
}
.cd-back {
  display: inline-block;
  font-weight: 800;
  text-decoration: none;
  color: var(--muted);
  margin-bottom: 12px;
}
.cd-cat-banner-inner {
  display: flex;
  gap: 16px;
  align-items: center;
}
.cd-cat-emoji {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 2.4rem;
  background: #fff;
  box-shadow: 0 8px 0 var(--cd-accent, #ffc43a);
}
.cd-cat-banner h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
}

/* —— Levels —— */
.cd-level-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.cd-level-tab {
  appearance: none;
  border: 2px solid rgba(26,43,74,.12);
  background: #fff;
  border-radius: 16px;
  padding: 12px 16px;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: transform .12s ease, background .12s ease;
}
.cd-level-tab:hover { transform: translateY(-2px); }
.cd-level-tab.active {
  background: var(--cd-accent, #ffc43a);
  border-color: transparent;
  color: #1a2b4a;
  box-shadow: 0 8px 0 rgba(26,43,74,.12);
}
.cd-stars { letter-spacing: 1px; color: #c45a2c; }

.cd-level-panel h3 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.35rem;
}
.cd-level-hint {
  margin: 0 0 16px;
  font-weight: 700;
  color: var(--muted);
}

.cd-page-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.cd-page-card {
  text-decoration: none;
  color: inherit;
  background: #fff;
  border-radius: 20px;
  border: 2px solid rgba(26,43,74,.08);
  padding: 14px;
  box-shadow: 0 10px 22px rgba(26,43,74,.07);
  transition: transform .15s ease;
  position: relative;
}
.cd-page-card:hover { transform: translateY(-3px) scale(1.01); }
.cd-page-card .cd-thumb {
  aspect-ratio: 1;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 3.2rem;
  background: linear-gradient(160deg, #fffdf8, #fff0dc);
  border: 1.5px dashed rgba(26,43,74,.18);
  margin-bottom: 10px;
}
.cd-page-card h4 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 1.1rem;
}
.cd-page-card p {
  margin: 0;
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
}
.cd-done-badge {
  position: absolute;
  top: 20px;
  right: 20px;
  background: #2fbf71;
  color: #fff;
  font-weight: 800;
  font-size: .72rem;
  padding: 4px 8px;
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(47,191,113,.35);
}

/* —— Studio page —— */
.coloring-shell { padding: 28px 0 60px; }

.coloring-card,
.cd-studio {
  background: rgba(255, 255, 255, 0.96);
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow);
  padding: 22px;
}

.coloring-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-start;
  margin-bottom: 16px;
}

.cd-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.cd-badge {
  font-size: .72rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff3d6;
  color: #8a4b12;
  border: 1px solid #f0d59a;
}
.cd-badge.level { background: #e8f7ff; color: #0d5f8a; border-color: #a8d8f0; }

.cd-nav-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.coloring-tools { margin-bottom: 16px; }

.mode-row,
.palette-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.mode-row { margin-bottom: 12px; }

.mode-row .btn.active {
  background: linear-gradient(135deg, var(--mint), var(--sky));
  color: #fff;
  border-color: transparent;
}

.cd-brush-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-weight: 800;
  color: var(--muted);
}
.cd-brush-row input { width: min(220px, 50vw); }

.swatch-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 3px solid #fff;
  box-shadow: 0 4px 10px rgba(26, 43, 74, 0.12);
  cursor: pointer;
  transition: transform .12s ease;
}

.swatch-btn:hover,
.swatch-btn.active {
  transform: scale(1.08);
  outline: 3px solid var(--ink);
}

.coloring-board {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  background: #ffffff;
  border: 3px dashed rgba(61, 184, 255, 0.35);
  min-height: min(72vw, 420px);
  max-width: 520px;
  margin: 0 auto;
  box-shadow: inset 0 0 0 1px rgba(26,43,74,.04);
}

#coloring-svg-wrap,
.coloring-svg {
  width: 100%;
  height: auto;
  display: block;
}

#draw-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  touch-action: none;
}

.coloring-tip {
  text-align: center;
  color: var(--muted);
  font-weight: 700;
  margin: 14px 0 0;
}

@media (max-width: 980px) {
  .cd-cat-grid { grid-template-columns: repeat(2, 1fr); }
  .cd-page-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .coloring-board { min-height: 68vw; }
  .swatch-btn { width: 38px; height: 38px; }
  .cd-scribble { display: none; }
  .cd-cat-banner-inner { align-items: flex-start; }
}
@media (max-width: 520px) {
  .cd-cat-grid,
  .cd-page-grid { grid-template-columns: 1fr; }
  .cd-hero { padding: 26px 18px 30px; }
}
