/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Fredoka', 'Comic Sans MS', cursive, sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
  background: #87CEEB;
}

/* ===== Animated Scene Background ===== */
.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #4FC3F7 0%, #81D4FA 40%, #B3E5FC 70%, #E1F5FE 100%);
  animation: skyShift 20s ease-in-out infinite alternate;
}

@keyframes skyShift {
  0%   { filter: hue-rotate(0deg) brightness(1); }
  100% { filter: hue-rotate(15deg) brightness(1.05); }
}

/* Clouds */
.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 50px;
  filter: blur(1px);
}

.cloud::before, .cloud::after {
  content: '';
  position: absolute;
  background: inherit;
  border-radius: 50%;
}

.cloud-1 {
  width: 120px; height: 40px;
  top: 12%; left: -130px;
  animation: driftCloud 35s linear infinite;
}
.cloud-1::before { width: 50px; height: 50px; top: -25px; left: 15px; }
.cloud-1::after  { width: 65px; height: 55px; top: -30px; left: 45px; }

.cloud-2 {
  width: 90px; height: 30px;
  top: 22%; left: -100px;
  animation: driftCloud 28s linear infinite 8s;
  opacity: 0.7;
}
.cloud-2::before { width: 40px; height: 40px; top: -20px; left: 10px; }
.cloud-2::after  { width: 50px; height: 45px; top: -22px; left: 35px; }

.cloud-3 {
  width: 150px; height: 45px;
  top: 8%; left: -160px;
  animation: driftCloud 42s linear infinite 18s;
  opacity: 0.6;
}
.cloud-3::before { width: 60px; height: 55px; top: -28px; left: 20px; }
.cloud-3::after  { width: 75px; height: 60px; top: -32px; left: 55px; }

@keyframes driftCloud {
  from { transform: translateX(0); }
  to   { transform: translateX(calc(100vw + 200px)); }
}

/* Sun */
.sun {
  position: absolute;
  top: 6%;
  right: 8%;
  width: 90px;
  height: 90px;
}

.sun-face {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, #FFEB3B 30%, #FFC107 70%, #FF9800 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  z-index: 2;
  box-shadow: 0 0 40px rgba(255, 193, 7, 0.6), 0 0 80px rgba(255, 152, 0, 0.3);
  animation: sunPulse 3s ease-in-out infinite;
}

@keyframes sunPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 40px rgba(255,193,7,0.6), 0 0 80px rgba(255,152,0,0.3); }
  50%       { transform: scale(1.08); box-shadow: 0 0 60px rgba(255,193,7,0.8), 0 0 100px rgba(255,152,0,0.5); }
}

.sun-rays {
  position: absolute;
  inset: -20px;
  background: repeating-conic-gradient(
    from 0deg,
    rgba(255, 235, 59, 0.5) 0deg 10deg,
    transparent 10deg 20deg
  );
  border-radius: 50%;
  animation: spinRays 12s linear infinite;
}

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

/* Hills */
.hills {
  position: absolute;
  bottom: 60px;
  left: 0; right: 0;
  height: 180px;
}

.hill {
  position: absolute;
  bottom: 0;
  border-radius: 50% 50% 0 0;
}

.hill-back {
  width: 120%;
  left: -10%;
  height: 140px;
  background: #66BB6A;
  opacity: 0.7;
}

.hill-front {
  width: 110%;
  left: -5%;
  height: 100px;
  background: #43A047;
}

/* Grass */
.grass-layer {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  height: 70px;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  background: linear-gradient(180deg, transparent, #2E7D32 30%, #1B5E20 100%);
  overflow: hidden;
}

.grass-blade {
  width: 8px;
  height: calc(30px + var(--i) * 2px);
  background: linear-gradient(180deg, #81C784, #2E7D32);
  border-radius: 50% 50% 0 0;
  transform-origin: bottom center;
  animation: swayGrass calc(1.5s + var(--i) * 0.15s) ease-in-out infinite alternate;
  animation-delay: calc(var(--i) * -0.2s);
  opacity: 0.85;
}

@keyframes swayGrass {
  0%   { transform: rotate(calc(-8deg - var(--i) * 1deg)); }
  100% { transform: rotate(calc(8deg + var(--i) * 1deg)); }
}

/* ===== App Layout ===== */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 16px 24px;
}

.app-header h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  color: #fff;
  text-shadow: 2px 2px 0 #1565C0, 3px 3px 6px rgba(0,0,0,0.2);
  margin: 0;
}

.header-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 20px;
  margin-bottom: 4px;
}

.lang-select-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  background: rgba(255, 255, 255, 0.92);
  padding: 8px 12px;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  min-width: 160px;
}

.lang-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #1565C0;
  margin: 0;
}

.lang-select {
  width: 100%;
  min-width: 140px;
  max-width: 220px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 10px;
  border: 2px solid #90CAF9;
  border-radius: 12px;
  background: #fff;
  color: #333;
  cursor: pointer;
}

.lang-select:focus {
  outline: none;
  border-color: #1565C0;
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.25);
}

[dir="rtl"] .lang-select-wrap {
  align-items: flex-end;
}

.subtitle {
  color: #E3F2FD;
  font-size: clamp(0.95rem, 2.5vw, 1.15rem);
  margin: 0 0 12px;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.2);
}

/* App Tabs */
.app-tabs {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.app-tab {
  font-family: inherit;
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  font-weight: 700;
  padding: 12px 24px;
  border: 3px solid rgba(255,255,255,0.8);
  border-radius: 18px;
  background: rgba(255,255,255,0.85);
  color: #1565C0;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s, box-shadow 0.12s;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}

.app-tab:hover { transform: scale(1.04); }
.app-tab.active {
  background: #FFD600;
  border-color: #fff;
  color: #333;
  transform: scale(1.06);
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.main-layout {
  display: grid;
  grid-template-columns: 180px 1fr 200px;
  gap: 14px;
  align-items: start;
}

/* Panels */
.tools-panel, .colours-panel {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 20px;
  padding: 14px 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.15);
  backdrop-filter: blur(6px);
}

.panel-title {
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  margin: 0 0 12px;
  color: #1565C0;
}

.tool-group {
  margin-bottom: 14px;
}

.tool-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
  margin: 0 0 6px;
  text-align: center;
}

/* Brush sizes */
.brush-sizes {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.brush-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #ddd;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, border-color 0.15s;
  color: #333;
  line-height: 1;
  padding: 0;
}

.brush-btn[data-size="4"]  { font-size: 0.35rem; }
.brush-btn[data-size="10"] { font-size: 0.55rem; }
.brush-btn[data-size="20"] { font-size: 0.85rem; }
.brush-btn[data-size="35"] { font-size: 1.2rem; }
.brush-btn[data-size="55"] { font-size: 1.6rem; }

.brush-btn:hover  { transform: scale(1.12); border-color: #42A5F5; }
.brush-btn.active { border-color: #1565C0; background: #E3F2FD; transform: scale(1.1); }

/* Eraser sizes — big & easy for kids */
.eraser-sizes-group {
  background: #FFF3E0;
  border-radius: 14px;
  padding: 8px 6px 10px;
  border: 2px dashed #FFB74D;
}

.eraser-sizes {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.eraser-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid #FFCC80;
  background: #fff;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  padding: 0;
  line-height: 1;
}

.eraser-btn[data-size="45"]  { font-size: 1rem; }
.eraser-btn[data-size="75"]  { font-size: 1.45rem; }
.eraser-btn[data-size="110"] { font-size: 1.9rem; }

.eraser-btn:hover  { transform: scale(1.12); border-color: #FF9800; }
.eraser-btn.active { border-color: #E65100; background: #FFE0B2; transform: scale(1.1); }

.eraser-main-btn.active {
  background: #FF9800;
  border-color: #E65100;
  color: #fff;
}

#draw-canvas.eraser-mode {
  cursor: cell;
}

#draw-canvas.text-mode {
  cursor: text;
}

/* Text tool */
.text-sizes-group {
  background: #E8F5E9;
  border-radius: 14px;
  padding: 8px 6px 10px;
  border: 2px dashed #81C784;
  display: none;
}

.text-sizes-group.visible {
  display: block;
}

.text-sizes {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.text-size-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 3px solid #A5D6A7;
  background: #fff;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  color: #2E7D32;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.text-size-btn[data-size="20"] { font-size: 0.75rem; }
.text-size-btn[data-size="32"] { font-size: 1rem; }
.text-size-btn[data-size="48"] { font-size: 1.35rem; }
.text-size-btn[data-size="64"] { font-size: 1.65rem; }

.text-size-btn:hover { transform: scale(1.08); border-color: #43A047; }
.text-size-btn.active { border-color: #1B5E20; background: #C8E6C9; }

.canvas-text-input {
  position: absolute;
  z-index: 10;
  min-width: 120px;
  max-width: calc(100% - 24px);
  min-height: 2.5em;
  padding: 6px 10px;
  margin: 0;
  border: 3px dashed #1565C0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  resize: both;
  overflow: auto;
  outline: none;
  line-height: 1.25;
  font-weight: 700;
}

.canvas-text-input:focus {
  border-color: #FFD600;
  box-shadow: 0 0 0 3px rgba(255, 214, 0, 0.4);
}

/* Action buttons */
.magic-tools, .action-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.action-btn {
  width: 100%;
  padding: 10px 8px;
  border: 2px solid #BBDEFB;
  border-radius: 14px;
  background: #fff;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s;
  color: #333;
}

.action-btn:hover  { transform: scale(1.04); background: #E3F2FD; }
.action-btn.active { background: #1565C0; color: #fff; border-color: #1565C0; }

.current-colour-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
}

.current-colour-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  background: #000;
  transition: background 0.2s;
}

/* Canvas */
.canvas-area {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.canvas-frame {
  background: #fff;
  border-radius: 20px;
  padding: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  border: 4px solid #fff;
  width: 100%;
  position: relative;
}

#draw-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  cursor: crosshair;
  touch-action: none;
  background: #fff;
}

.canvas-hint {
  margin: 10px 0 0;
  font-size: 0.9rem;
  color: #fff;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
  font-weight: 600;
}

/* Pages bar */
.pages-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  width: 100%;
}

.page-nav-btn, .page-add-btn, .page-delete-btn {
  font-family: inherit;
  font-weight: 700;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.12s;
}

.page-nav-btn {
  width: 48px;
  height: 48px;
  font-size: 1.2rem;
  background: rgba(255, 255, 255, 0.95);
  color: #1565C0;
  box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}

.page-nav-btn:hover:not(:disabled) { transform: scale(1.08); }
.page-nav-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.page-indicator {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
  min-width: 110px;
  text-align: center;
}

.page-add-btn {
  padding: 10px 18px;
  font-size: 0.95rem;
  background: #66BB6A;
  color: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.page-add-btn:hover { transform: scale(1.05); background: #43A047; }

.page-delete-btn {
  width: 48px;
  height: 48px;
  font-size: 1.1rem;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}

.page-delete-btn:hover:not(:disabled) { transform: scale(1.08); }
.page-delete-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.page-thumbnails-wrap {
  width: 100%;
  margin-top: 10px;
}

.page-thumbnails-label {
  margin: 0 0 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
  text-align: center;
}

.page-thumbnails {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 4px 10px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.page-thumbnails::-webkit-scrollbar { height: 6px; }
.page-thumbnails::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.5); border-radius: 3px; }

.page-thumb {
  flex: 0 0 auto;
  width: 72px;
  border: 3px solid rgba(255, 255, 255, 0.7);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: #fff;
  scroll-snap-align: start;
  transition: transform 0.12s, border-color 0.12s;
  box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}

.page-thumb img {
  display: block;
  width: 100%;
  height: 54px;
  object-fit: cover;
  background: #fff;
}

.page-thumb-label {
  display: block;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #1565C0;
  padding: 3px 0;
  background: #E3F2FD;
}

.page-thumb:hover { transform: scale(1.06); }
.page-thumb.active {
  border-color: #FFD600;
  transform: scale(1.08);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #FFD600;
}

/* Colour Palette */
.colour-palette {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 2px;
}

.colour-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.colour-swatch:hover  { transform: scale(1.15); z-index: 1; }
.colour-swatch.active { border-color: #1565C0; transform: scale(1.2); box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1565C0; }

.colour-palette::-webkit-scrollbar { width: 6px; }
.colour-palette::-webkit-scrollbar-thumb { background: #90CAF9; border-radius: 3px; }

/* Modal */
.kid-modal {
  border-radius: 24px;
  border: none;
  overflow: hidden;
}

.kid-modal .modal-body {
  padding: 28px 24px;
}

.modal-emoji { font-size: 3rem; margin-bottom: 8px; }

.kid-modal h3 {
  font-weight: 700;
  color: #1565C0;
  margin-bottom: 6px;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 18px;
}

.btn-kid-cancel, .btn-kid-confirm {
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  padding: 10px 22px;
  border-radius: 16px;
  border: none;
}

.btn-kid-cancel  { background: #E3F2FD; color: #1565C0; }
.btn-kid-confirm { background: #EF5350; color: #fff; }

/* ===== COLORING TAB ===== */
.coloring-layout {
  display: grid;
  grid-template-columns: 160px 1fr 190px;
  gap: 14px;
  align-items: start;
}

.color-categories-panel,
.color-tools-panel {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 20px;
  padding: 14px 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.15);
  backdrop-filter: blur(6px);
}

.color-categories {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.color-category-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 8px;
  border: 2px solid #BBDEFB;
  border-radius: 14px;
  background: #fff;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s;
  color: #333;
  text-align: left;
}

.color-category-btn:hover { transform: scale(1.03); background: #E3F2FD; }
.color-category-btn.active {
  background: #1565C0;
  color: #fff;
  border-color: #1565C0;
}

.cat-icon { font-size: 1.2rem; flex-shrink: 0; }
.cat-label { flex: 1; }
.cat-count {
  font-size: 0.65rem;
  background: rgba(0,0,0,0.1);
  padding: 2px 6px;
  border-radius: 8px;
}
.color-category-btn.active .cat-count { background: rgba(255,255,255,0.25); }

.coloring-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.color-image-picker-wrap {
  background: rgba(255,255,255,0.92);
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.color-picker-label {
  margin: 0 0 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #1565C0;
  text-align: center;
}

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

.color-pick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  border: 2px solid #E0E0E0;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
  font-family: inherit;
}

.color-pick-btn:hover { transform: scale(1.05); border-color: #90CAF9; }
.color-pick-btn.active {
  border-color: #FFD600;
  background: #FFFDE7;
  transform: scale(1.06);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #FFD600;
}

.color-pick-thumb {
  width: 100%;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.color-pick-thumb svg {
  width: 100%;
  height: 100%;
  max-height: 52px;
}

.color-pick-name {
  font-size: 0.65rem;
  font-weight: 700;
  color: #555;
  line-height: 1.1;
}

.coloring-workspace {
  background: rgba(255,255,255,0.95);
  border-radius: 20px;
  padding: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.coloring-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.coloring-title-bar h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: #1565C0;
}

.coloring-hint-badge {
  font-size: 0.78rem;
  font-weight: 600;
  background: #E8F5E9;
  color: #2E7D32;
  padding: 5px 10px;
  border-radius: 12px;
}

.coloring-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #fff;
  border-radius: 14px;
  border: 3px solid #E3F2FD;
  overflow: hidden;
}

.coloring-svg-host {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.coloring-svg-host svg {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
}

.coloring-svg-host .color-region {
  transition: fill 0.15s ease;
}

.coloring-svg-host .color-region:hover {
  filter: brightness(0.97);
}

#coloring-brush-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.color-mode-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.color-brush-sizes .color-brush-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #ddd;
  background: #fff;
  cursor: pointer;
  padding: 0;
  color: #333;
}

.color-brush-btn[data-size="6"]  { font-size: 0.4rem; }
.color-brush-btn[data-size="14"] { font-size: 0.75rem; }
.color-brush-btn[data-size="24"] { font-size: 1.1rem; }

.color-brush-btn.active { border-color: #1565C0; background: #E3F2FD; }

.color-palette-title { margin-top: 12px; }

.color-tab-palette {
  grid-template-columns: repeat(4, 1fr);
  max-height: 45vh;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .main-layout,
  .coloring-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .tools-panel { order: 2; }
  .canvas-area  { order: 1; }
  .colours-panel { order: 3; }

  .color-categories-panel { order: 2; }
  .coloring-main { order: 1; }
  .color-tools-panel { order: 3; }

  .color-categories {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .color-category-btn {
    flex: 1 1 calc(33% - 8px);
    min-width: 100px;
    flex-direction: column;
    text-align: center;
    padding: 8px 6px;
  }

  .cat-count { display: none; }

  .color-image-picker {
    grid-template-columns: repeat(5, 1fr);
  }

  .brush-sizes {
    flex-direction: row;
  }

  .magic-tools, .action-buttons {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .action-btn {
    flex: 1 1 calc(50% - 6px);
    min-width: 120px;
  }

  .colour-palette {
    grid-template-columns: repeat(8, 1fr);
    max-height: none;
  }

  .sun { width: 60px; height: 60px; }
  .sun-face { font-size: 1.5rem; }
}

@media (max-width: 480px) {
  .header-top {
    flex-direction: column;
  }

  .lang-select-wrap {
    width: 100%;
    max-width: 280px;
  }

  .lang-select {
    max-width: none;
  }

  .colour-palette,
  .color-tab-palette {
    grid-template-columns: repeat(6, 1fr);
  }

  .color-image-picker {
    grid-template-columns: repeat(3, 1fr);
  }

  .app-tab {
    padding: 10px 16px;
    font-size: 0.9rem;
  }
}
