.coloring-page {
  --coloring-purple: #7160be;
  --coloring-pink: #f45f94;
  --coloring-ink: #504878;
  background:
    radial-gradient(circle at 11% 18%, rgba(255,255,255,.8) 0 4px, transparent 5px),
    radial-gradient(circle at 88% 32%, rgba(255,255,255,.62) 0 6px, transparent 7px),
    linear-gradient(145deg, #fff1f7, #eee9ff 50%, #dff8ef);
  background-size: 52px 52px, 76px 76px, auto;
}

.coloring-header {
  width: calc(100% - 28px);
  max-width: 1220px;
}

.local-chip {
  justify-self: end;
  padding: 9px 12px;
  border: 1px solid rgba(106,86,181,.14);
  border-radius: 999px;
  color: #645a93;
  background: rgba(255,255,255,.84);
  box-shadow: 0 5px 12px rgba(76,56,140,.09);
  font-size: 11px;
  font-weight: 900;
}

.coloring-shell {
  width: calc(100% - 28px);
  max-width: 1220px;
  margin: 23px auto 32px;
}

.coloring-intro h1 {
  background: linear-gradient(130deg, #554999, #ef5c92 68%, #e5ae32);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

.coloring-intro > p:last-child {
  max-width: 720px;
}

.coloring-layout {
  display: grid;
  grid-template-columns: minmax(520px, 1.35fr) minmax(360px, .82fr);
  gap: 22px;
  align-items: start;
}

.coloring-studio-card,
.coloring-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(101, 79, 173, .16);
  border-radius: 29px;
  background: rgba(255,255,255,.86);
  box-shadow: inset 0 1px #fff, 0 24px 52px rgba(69,52,127,.14);
  backdrop-filter: blur(12px);
}

.coloring-studio-card {
  padding: 17px;
}

.coloring-status-bar {
  min-height: 64px;
  padding: 9px 12px 13px;
  display: grid;
  grid-template-columns: minmax(90px, auto) 1fr minmax(90px, auto);
  gap: 10px;
  align-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, #fbf7ff, #fff2f7);
  box-shadow: inset 0 1px #fff, 0 8px 18px rgba(77, 57, 137, .08);
}

.coloring-status-bar > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
}

.coloring-status-bar span {
  color: #9b91b0;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 1px;
}

.coloring-status-bar strong {
  color: #6557a3;
  font-size: 15px;
}

.coloring-status-bar p {
  margin: 0;
  color: #746b8c;
  text-align: center;
  font: 12px/1.35 Arial, sans-serif;
}

.canvas-frame {
  position: relative;
  width: 100%;
  margin-top: 13px;
  overflow: hidden;
  border: 5px solid #fff;
  border-radius: 24px;
  aspect-ratio: var(--canvas-ratio, 1 / 1);
  background: #fff;
  box-shadow: 0 0 0 1px rgba(96,75,163,.14), 0 17px 32px rgba(66,49,123,.13);
  isolation: isolate;
}

@supports not (aspect-ratio: 1 / 1) {
  .canvas-frame::before {
    content: "";
    display: block;
    padding-top: 100%;
  }
}

#coloring-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #fff;
  cursor: crosshair;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#coloring-canvas.tool-brush { cursor: crosshair; }
#coloring-canvas.tool-fill { cursor: cell; }
#coloring-canvas.tool-eraser { cursor: not-allowed; }

#coloring-canvas:focus-visible {
  outline: 4px solid #51478d;
  outline-offset: -7px;
}

.canvas-loading {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  color: #67599e;
  background: rgba(255,255,255,.92);
  text-align: center;
  pointer-events: none;
}

.canvas-loading.is-hidden {
  display: none;
}

.canvas-loading span {
  width: 44px;
  height: 44px;
  margin: auto;
  border: 5px solid #f3d5e2;
  border-top-color: #ed6394;
  border-radius: 50%;
  animation: colorSpinner .8s linear infinite;
}

@keyframes colorSpinner {
  to { transform: rotate(360deg); }
}

.canvas-hint {
  padding: 15px 4px 2px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.canvas-hint span {
  display: flex;
  gap: 7px;
  align-items: center;
  color: #716887;
  font: 11px/1.25 Arial, sans-serif;
}

.canvas-hint b {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, #ff80aa, #da4a7e);
  box-shadow: 0 4px 9px rgba(202,58,111,.2);
  font-size: 11px;
}

.coloring-brand-strip {
  min-height: 112px;
  padding: 15px 20px;
  display: flex;
  gap: 15px;
  align-items: center;
  color: #fff;
  background:
    radial-gradient(circle at 86% 18%, rgba(255,255,255,.3) 0 4px, transparent 5px),
    linear-gradient(135deg, #8172cb, #6555aa 55%, #ec6c9b);
}

.coloring-brand-strip img {
  width: 84px;
  height: 84px;
  object-fit: contain;
  filter: drop-shadow(0 8px 13px rgba(54,36,115,.24));
}

.coloring-brand-strip div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.coloring-brand-strip span {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 1.5px;
  opacity: .8;
}

.coloring-brand-strip strong {
  font-size: 20px;
  line-height: 1.05;
}

.coloring-controls {
  padding: 20px;
}

.coloring-controls > .eyebrow {
  margin-bottom: 5px;
}

.coloring-controls h2 {
  margin: 0 0 13px;
  color: #514780;
  font-size: clamp(22px, 3vw, 29px);
  line-height: 1.05;
}

.coloring-scenes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.scene-choice {
  min-width: 0;
  min-height: 70px;
  padding: 5px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border: 2px solid transparent;
  border-radius: 14px;
  color: #665c84;
  background: #f3eff9;
  box-shadow: inset 0 1px #fff;
  cursor: pointer;
  text-align: left;
  transition: transform .15s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.scene-choice:hover {
  transform: translateY(-2px);
}

.scene-choice img {
  width: 58px;
  height: 58px;
  display: block;
  object-fit: cover;
  border: 2px solid #fff;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 4px 10px rgba(58,43,115,.12);
}

.scene-choice span {
  overflow-wrap: anywhere;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.15;
}

.scene-choice.is-selected {
  border-color: #e96899;
  color: #fff;
  background: linear-gradient(145deg, #ff82ad, #d94b80);
  box-shadow: 0 8px 17px rgba(207,63,117,.22), inset 0 1px rgba(255,255,255,.42);
}

.coloring-divider {
  height: 1px;
  margin: 17px 0 14px;
  background: linear-gradient(90deg, transparent, rgba(104,82,174,.22), transparent);
}

.color-palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.color-swatch {
  position: relative;
  width: 100%;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 50%;
  aspect-ratio: 1;
  background: var(--swatch);
  box-shadow: 0 0 0 1px rgba(61,47,108,.13), 0 5px 10px rgba(58,43,115,.13);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}

.color-swatch:hover {
  transform: scale(1.08);
}

.color-swatch.is-selected {
  transform: scale(.88);
  box-shadow: 0 0 0 4px #5d4e99, 0 7px 14px rgba(58,43,115,.18);
}

.color-swatch.is-selected::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.55);
  font-size: 13px;
  font-weight: 900;
}

.custom-color {
  margin-top: 10px;
  padding: 8px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 12px;
  color: #706689;
  background: #f6f3fa;
  font-size: 11px;
  font-weight: 900;
}

.custom-color input {
  width: 46px;
  height: 30px;
  padding: 1px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.tool-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.tool-options button {
  min-width: 0;
  min-height: 61px;
  padding: 7px 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
  border-radius: 13px;
  color: #706589;
  background: #f3eff9;
  box-shadow: inset 0 1px #fff;
  cursor: pointer;
}

.tool-options button b {
  font-size: 19px;
}

.tool-options button span {
  font-size: 10px;
  font-weight: 900;
}

.tool-options button.is-selected {
  border-color: #7260b8;
  color: #fff;
  background: linear-gradient(145deg, #8675d2, #6555ac);
  box-shadow: 0 8px 17px rgba(81,63,157,.2), inset 0 1px rgba(255,255,255,.38);
}

.tool-options button:disabled {
  opacity: .44;
  cursor: not-allowed;
  filter: grayscale(.35);
}

.brush-size {
  margin-top: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #706689;
  font-size: 11px;
  font-weight: 900;
}

.brush-size output {
  min-width: 32px;
  padding: 4px 7px;
  border-radius: 999px;
  color: #fff;
  background: #e65b8d;
  text-align: center;
}

.brush-range {
  width: 100%;
  margin: 8px 0 0;
  accent-color: #e65b8d;
  cursor: pointer;
}

.coloring-actions {
  margin-top: 15px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.coloring-actions button {
  min-width: 0;
  min-height: 43px;
  padding: 9px 7px;
  border: 0;
  border-radius: 13px;
  color: #665a8e;
  background: #ece7f7;
  box-shadow: inset 0 1px #fff, 0 6px 13px rgba(78,58,135,.09);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  transition: transform .15s ease, box-shadow .15s ease;
}

.coloring-actions button:hover:not(:disabled) {
  transform: translateY(-2px);
}

.coloring-actions button:disabled {
  opacity: .43;
  cursor: not-allowed;
}

.coloring-actions .save-coloring {
  color: #fff;
  background: linear-gradient(145deg, #ff78a5, #d8457a);
  box-shadow: 0 8px 17px rgba(207,63,117,.22), inset 0 1px rgba(255,255,255,.4);
}

.scene-choice:focus-visible,
.color-swatch:focus-visible,
.custom-color input:focus-visible,
.tool-options button:focus-visible,
.brush-range:focus-visible,
.coloring-actions button:focus-visible {
  outline: 3px solid #40356f;
  outline-offset: 3px;
}

.coloring-page > footer {
  padding: 8px 18px 25px;
  color: #807791;
  text-align: center;
  font: 12px/1.4 Arial, sans-serif;
}

@media (max-width: 980px) {
  .coloring-layout {
    grid-template-columns: 1fr;
  }

  .coloring-studio-card,
  .coloring-panel {
    width: 100%;
    max-width: 720px;
    margin-inline: auto;
  }

  .coloring-brand-strip {
    min-height: 100px;
  }
}

@media (max-width: 620px) {
  .coloring-header > img {
    width: 82px;
    height: 48px;
  }

  .local-chip {
    padding: 8px 9px;
    font-size: 10px;
  }

  .coloring-shell {
    width: calc(100% - 18px);
    max-width: 1220px;
    margin-top: 14px;
  }

  .coloring-intro h1 {
    letter-spacing: -1.7px;
  }

  .coloring-intro > p:last-child {
    font-size: 15px;
  }

  .coloring-studio-card {
    padding: 10px;
    border-radius: 22px;
  }

  .coloring-status-bar {
    grid-template-columns: 72px 1fr 72px;
    gap: 5px;
    padding-inline: 7px;
  }

  .coloring-status-bar strong {
    font-size: 12px;
  }

  .coloring-status-bar p {
    font-size: 10px;
  }

  .canvas-frame {
    border-width: 3px;
    border-radius: 17px;
  }

  .canvas-hint {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 12px 5px 2px;
  }

  .coloring-brand-strip {
    min-height: 88px;
    padding: 11px 16px;
  }

  .coloring-brand-strip img {
    width: 68px;
    height: 68px;
  }

  .coloring-controls {
    padding: 17px;
  }

  .scene-choice {
    grid-template-columns: 51px minmax(0, 1fr);
    gap: 6px;
    min-height: 62px;
  }

  .scene-choice img {
    width: 51px;
    height: 51px;
  }

  .color-palette {
    gap: 7px;
  }
}

@media (pointer: coarse) {
  .coloring-actions button,
  .tool-options button {
    min-height: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
