/* =======================================================================
   WP COLORING — FULL UI STYLESHEET (v1.8 - Sửa lỗi xung đột Theme Flatsome)
   ======================================================================= */

/* ========================== 0) CSS RESET (nhẹ) ========================== */
button {
  margin-bottom: 0px !important;
}

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

html {
  line-height: 1.5;
  /* -webkit-text-size-adjust: 100%; */
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Inter,
    "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
  color: #1e293b;
  background: #f7f9fc;
}

img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.45);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

/* ====================== 1) BASE VARIABLES & THEME ====================== */
:root {
  /* Surfaces */
  --bg: #f0f4f8;
  --panel: #ffffff;
  --panel-2: #fbfdff;
  --panel-muted: #f7f9fc;

  /* Lines & shadows */
  --stroke: #e0e7ff;
  --stroke-2: #e6ebf2;
  --ring: rgba(79, 70, 229, 0.18);
  --ring-strong: #4f46e5;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.08);

  /* Texts */
  --text: #1e293b;
  --muted: #64748b;

  /* Accent */
  --accent: #3b82f6;

  /* Palette sizes (PC defaults) */
  --swatch-size: 15px;
  --swatch-inner: 15px;

  /* Action sizes (PC defaults) */
  --action-size: 60px;
  --action-radius: 14px;
  --action-font: 30px;

  /* Canvas */
  --canvas-radius: 12px;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --panel: #0b1220;
    --panel-2: #0d1526;
    --panel-muted: #0e182b;
    --stroke: #23314e;
    --stroke-2: #1e2b45;
    --ring: rgba(99, 102, 241, 0.35);
    --ring-strong: #818cf8;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

/* ========================= 2) SHELL & GRID ========================= */
.wp-coloring-shell {
  width: 100%;
  max-width: 790px;
  margin-inline: auto;
  padding: 16px;
  box-sizing: border-box;
  background: transparent;
  position: relative;
  /* For loading overlay */
}

/* LOADING STATE */
.wp-coloring-shell.loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  z-index: 50;
  backdrop-filter: blur(2px);
}

.wp-coloring-shell.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 4px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: wp-coloring-spin 1s linear infinite;
  z-index: 51;
}

@keyframes wp-coloring-spin {
  to {
    transform: rotate(360deg);
  }
}

.wp-coloring-grid {
  flex-grow: 1;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 120px;
  gap: 0;
  height: 100%;
}

@media (max-width: 900px) {
  .wp-coloring-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  .wp-coloring-sidebar.right,
  .wp-coloring-sidebar.left {
    display: none !important;
  }
}

/* ====================== 3) SIDEBARS (PC) ====================== */
.wp-coloring-sidebar {
  background-color: var(--bg-panel);
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  align-items: center;

  /* --- SỬA LỖI --- */
  /* Gắn sidebar vào màn hình */
  position: -webkit-sticky;
  position: sticky;
  top: 90px;
  /* Khoảng cách từ đỉnh, chừa chỗ cho thanh admin WP */
  align-self: start;

  /* Giới hạn chiều cao và cho phép cuộn bên trong nếu cần */
  max-height: calc(100vh - 70px);
  overflow-y: auto;
}

.wp-coloring-sidebar.left {
  width: 210px !important;
}

.wp-coloring-sidebar.right {
  width: 120px;
}

/* ====================== 4) PALETTE (PC + MOBILE) ====================== */
.palette-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(44px, 1fr));
  gap: 4px;
  margin: 0;
  /* padding: 2px; */
  list-style: none;
}

.palette-btn {
  width: 35px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  /* << SỬA: Viền mặc định mỏng hơn */
  padding: 3px;
  background-clip: content-box;
  background-color: var(--clr, #ccc);
  transition: all 0.2s ease;
  flex-shrink: 0;
  /* Thêm để chống theme làm biến dạng nút */
  line-height: 1;
  display: inline-block;
  vertical-align: middle;
}

.palette-btn::before {
  content: "";
  inline-size: var(--swatch-inner);
  block-size: var(--swatch-inner);
  border-radius: 50%;
  background: var(--clr);
}

.palette-btn:hover {
  border-color: var(--ring-strong);
  box-shadow: 0 0 0 3px var(--ring);
}

.palette-btn:focus-visible {
  outline: none;
  border-color: var(--ring-strong);
  box-shadow: 0 0 0 4px var(--ring);
}

.palette-btn.active {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-ring);
  transform: scale(1.1);
}

/* === SỬA LỖI XUNG ĐỘT FLATSOME: MOBILE PALETTE === */
.mobile-palette {
  display: flex;
  gap: 5px;
  /* << TĂNG: Khoảng cách giữa các nút màu */
  overflow-x: auto;
  /* THÊM: Padding để thanh màu không bị sát lề */
  padding: 8px 12px;
  scrollbar-width: none;
  /* Firefox */

  /* THÊM: Hiệu ứng mờ dần ở 2 cạnh để người dùng biết có thể cuộn */
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 15px, black calc(100% - 15px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0%, black 15px, black calc(100% - 15px), transparent 100%);
}

.mobile-palette::-webkit-scrollbar {
  display: none;
}

.wp-coloring-shell .mobile-palette .palette-btn {
  width: 25px;
  /* Đồng bộ kích thước với nút màu */
  height: 25px;
  /* Đồng bộ kích thước với nút màu */
  min-width: 25px;
  padding: 3px;
  border: 2px solid var(--border-color);
  background-clip: content-box;
  /* Dòng này vẫn đúng, chỉ cần selector ưu tiên hơn */
  background-color: var(--clr, #ccc);
}

.wp-coloring-shell .mobile-palette .palette-btn::before {
  width: var(--swatch-inner, 24px) !important;
  height: var(--swatch-inner, 24px) !important;
}

.palette-btn-picker {
  position: relative;
  /* Quan trọng: Để input có thể định vị tuyệt đối bên trong */
  overflow: hidden;
}

.palette-btn-picker::before {
  background: conic-gradient(from 180deg at 50% 50%,
      #ff0000,
      #ff7f00,
      #ffff00,
      #00ff00,
      #0000ff,
      #4b0082,
      #9400d3,
      #ff0000);
  background-color: var(--clr);
  background-image: var(--clr-bg,
      conic-gradient(from 180deg at 50% 50%,
        #ff0000,
        #ff7f00,
        #ffff00,
        #00ff00,
        #0000ff,
        #4b0082,
        #9400d3,
        #ff0000));
}

.palette-btn-picker .cl-input {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;

  /* Làm cho nó trong suốt và có độ ưu tiên nhấp chuột cao */
  opacity: 0 !important;
  cursor: pointer !important;
  z-index: 5 !important;
  /* Cao hơn các thành phần khác trong nút */
}

.palette-btn-picker input[type="color"] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.palette-btn-picker.active::before {
  background-image: none;
  background-color: var(--clr);
}

@keyframes pulse-ring {
  0% {
    box-shadow: inset 0 0 0 1px white,
      0 0 0 0px var(--accent, rgba(59, 130, 246, 0.7));
  }

  100% {
    box-shadow: inset 0 0 0 1px white, 0 0 0 5px rgba(59, 130, 246, 0);
  }
}

.palette-btn-picker.active {
  border: 2px solid var(--accent, #3b82f6);
  box-shadow: inset 0 0 0 1px white;
  animation: pulse-ring 1.5s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
}

.palette-btn-picker.active:hover {
  animation-play-state: paused;
}

/* ====================== 5) MAIN / CANVAS ====================== */
.wp-coloring-main {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 12px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wp-coloring-canvas-outer {
  width: 100%;
  position: relative;
  border: 1px dashed var(--stroke);
  border-radius: var(--canvas-radius);
  background: #fff;
  overflow: hidden;
  touch-action: none;
  aspect-ratio: var(--canvas-aspect-ratio, 3 / 4);
}

.wp-coloring-status {
  text-align: center;
  color: var(--muted);
  font-weight: 500;
  padding: 8px;
  min-height: 20px;
}

.bg-canvas,
.paint-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.paint-canvas {
  mix-blend-mode: multiply;
}

/* ====================== 6) ACTIONS (SIDEBARS & MOBILE) ====================== */
.actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.action-btn {
  min-height: 0px !important;
  inline-size: var(--action-size);
  block-size: var(--action-size);
  border-radius: var(--action-radius);
  border: 1px solid var(--stroke-2);
  background-color: var(--panel, #fff);
  color: var(--text, #1e293b);
  display: grid;
  place-items: center;
  font-size: var(--action-font);
  /* line-height: 1; */
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  background-color: var(--accent);
}

.action-btn:active {
  transform: translateY(0);
}

.action-btn.active {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 3px var(--ring);
}

.action-btn>* {
  background: none !important;
  padding: 0 !important;
  margin: 0 !important;
  display: block !important;
}

.wp-coloring-shell .action-btn svg {
  width: var(--action-font);
  /* Chiều rộng bằng kích thước font */
  height: var(--action-font);
  /* Chiều cao bằng kích thước font */
  /* Đảm bảo màu sắc icon tuân theo màu chữ của nút */
  stroke: currentColor;
}

/* QUAN TRỌNG: Đảm bảo SVG thay đổi màu khi nút được active hoặc hover */
.wp-coloring-shell .action-btn:hover svg {
  stroke: var(--accent);
}

.wp-coloring-shell .action-btn.active svg {
  stroke: #fff;
}

/* ====================== 7) MOBILE COMBINED SIDEBAR ====================== */
.wp-coloring-mobile-sidebar {
  display: none;
}

@media (max-width: 900px) {

  /* 1. KHUNG BAO NGOÀI (SHELL) */
  /* Ép chiều cao cố định theo màn hình thiết bị */
  .wp-coloring-shell {
    height: 85vh !important;
    /* Chiếm 85% chiều cao viewport */
    max-height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    /* Xếp dọc: Ảnh trên, Nút dưới */
    overflow: hidden !important;
    /* Cắt bỏ phần thừa */
    padding: 0 !important;
    margin: 0 auto !important;
  }

  /* 2. GRID LAYOUT (Bây giờ là cột dọc) */
  .wp-coloring-grid {
    display: flex !important;
    flex-direction: column !important;
    flex-grow: 1 !important;
    /* Chiếm hết không gian còn lại */
    height: auto !important;
    overflow: hidden !important;
    /* Quan trọng để ảnh không đẩy nút đi */
    gap: 0 !important;
  }

  /* 3. ẨN SIDEBAR PC (Trái & Phải) */
  .wp-coloring-sidebar.left,
  .wp-coloring-sidebar.right {
    display: none !important;
  }

  /* 4. KHUNG CHỨA ẢNH (MAIN) */
  .wp-coloring-main {
    flex-grow: 1 !important;
    /* Tự động giãn nở */
    flex-shrink: 1 !important;
    /* Cho phép co lại nếu màn hình bé */
    min-height: 0 !important;
    /* Fix lỗi Flexbox trên Firefox/Safari */

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    border: none !important;
    padding: 10px !important;
    background: #f0f4f8 !important;
    /* Màu nền nhẹ cho dễ nhìn */
    overflow: hidden !important;
  }

  /* 5. CANVAS OUTER (BỨC TRANH) */
  /* Logic: Luôn co lại để vừa khít vùng chứa (Fit Screen) */
  .wp-coloring-canvas-outer {
    width: auto !important;
    height: auto !important;

    /* Không bao giờ to hơn khung chứa */
    max-width: 100% !important;
    max-height: 100% !important;

    aspect-ratio: var(--canvas-aspect-ratio, 3/4);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1) !important;
  }

  /* 6. THANH CÔNG CỤ MOBILE (MOBILE SIDEBAR) */
  /* Luôn hiện và gim ở đáy */
  .wp-coloring-mobile-sidebar {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    padding: 10px 15px !important;
    background: #fff !important;
    border-top: 1px solid #e2e8f0 !important;

    flex-shrink: 0 !important;
    /* Cấm bị co lại, luôn hiển thị đủ */
    z-index: 100 !important;

    /* Đảm bảo an toàn cho iPhone đời mới (tai thỏ) */
    padding-bottom: env(safe-area-inset-bottom, 10px) !important;
  }

  /* --- STYLE CHO NÚT TRÊN MOBILE --- */

  /* Hàng bảng màu (Palette) */
  .mobile-palette {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    /* Cho phép vuốt ngang */
    padding: 4px 0;
    scrollbar-width: none;
    /* Ẩn thanh cuộn */
  }

  .mobile-palette::-webkit-scrollbar {
    display: none;
  }

  .mobile-palette .palette-btn {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    border-radius: 50% !important;
    border: 2px solid #fff !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15) !important;
  }

  .mobile-palette .palette-btn.active {
    transform: scale(1.2);
    border-color: #3b82f6 !important;
  }

  /* Hàng công cụ (Actions) */
  .mobile-actions {
    display: flex;
    justify-content: space-between;
    /* Căn đều 2 bên */
    align-items: center;
  }

  .mobile-actions .action-btn {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    font-size: 20px !important;
    border-radius: 8px !important;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
  }

  .mobile-actions .action-btn.active {
    background: #3b82f6 !important;
    color: #fff !important;
    border-color: #3b82f6 !important;
  }

}

.mobile-actions {
  display: flex;
  gap: 8px;
  padding: 4px;
  overflow-x: auto;
}

.wp-coloring-shell .mobile-actions .action-btn {
  padding: 0 !important;
  margin: 0 !important;
  line-height: 1 !important;
  text-transform: none !important;
  flex-shrink: 0;
  inline-size: 50px !important;
  block-size: 50px !important;
  min-width: 50px !important;
  font-size: 24px !important;
  border-radius: 12px !important;
  display: grid !important;
  place-items: center !important;
}

.wp-coloring-shell .mobile-actions .action-btn>* {
  line-height: 1 !important;
  height: auto !important;
  width: auto !important;
}

/* ====================== 8) UTILITIES & STATES ====================== */
.wp-coloring-error {
  color: #dc2626;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* ====================== 9) PRINT STYLES ====================== */
@media print {
  body {
    background: #fff;
  }

  .wp-coloring-shell {
    max-width: 100%;
    padding: 0;
  }

  .wp-coloring-sidebar,
  .wp-coloring-mobile-sidebar,
  .topbar,
  .actions {
    display: none !important;
  }

  .wp-coloring-main {
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .wp-coloring-canvas-outer {
    border: none;
    border-radius: 0;
  }

  .wp-coloring-canvas-outer>canvas {
    width: 100% !important;
    height: auto !important;
  }
}

/* ====================== 10) PICKER SHORTCODE STYLES ====================== */
.wp-coloring-picker {
  margin-bottom: 16px;
  /* Thêm khoảng cách với phần tô màu bên dưới */
}

.wp-coloring-picker .thumb-grid {
  display: flex;
  /* SỬA: Chuyển sang flexbox để cuộn ổn định */
  overflow-x: auto;
  /* Đảm bảo cuộn ngang hoạt động */
  gap: 12px;
  /* Tăng khoảng cách cho thoáng */
  padding-bottom: 12px;
  width: 100%;
  scrollbar-width: thin;
  scrollbar-color: #94a3b8 #e2e8f0;
}

.wp-coloring-picker .thumb-grid::-webkit-scrollbar {
  height: 8px;
  /* Độ dày của thanh cuộn ngang */
  background-color: transparent;
  /* Nền trong suốt */
}

.wp-coloring-picker .thumb {
  width: var(--thumb-size, 40px); /* User requested 40px */
  height: var(--thumb-size, 40px); /* User requested 40px */
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: 2px solid transparent;
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
}

.wp-coloring-picker .thumb:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.wp-coloring-picker .thumb.is-active {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.wp-coloring-picker .thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

button {
  margin-right: 0px !important;
  padding: 0px !important;
}


/* =======================================================================
   HONEYCOMB PALETTE (Final Fix - Khớp khít hoàn hảo)
   ======================================================================= */

/* 1. Container Sidebar */
.wp-coloring-sidebar.left {
  padding: 20px 0 !important;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* --- 2. Ô HIỂN THỊ TO --- */
.hex-display-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 15px;
  z-index: 50;
}

.hex-btn.large {
  width: 54px;
  height: 62px;
  background-color: #ef4444;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.2));
}

.hex-btn.large .cl-input {
  position: absolute;
  inset: -50%;
  width: 200%;
  height: 200%;
  opacity: 0;
  cursor: pointer;
}

/* --- 3. LƯỚI TỔ ONG (4 Ô/HÀNG) --- */
.honeycomb-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  /* Căn trái để tính toán dễ hơn */

  /* TÍNH TOÁN:
       (20px width + 2px margin) * 4 ô = 88px.
       Để dư 1 chút cho an toàn -> 90px.
    */
  width: 180px;
  margin: 0 auto;
  /* padding-bottom: 20px; */
  /* Đẩy nhẹ sang trái 1px để căn giữa thị giác */
  position: relative;
  left: -1px;
}

/* --- 4. Ô MÀU NHỎ (Đã sửa lại tỷ lệ) --- */
.hex-btn.small {
  /* Tỷ lệ vàng của lục giác: Cao = Rộng x 1.15 */
  width: 30px;
  height: 34.5px;

  margin: 0 1px;
  /* Khoảng cách ngang rất nhỏ (1px) */

  /* Kéo hàng dưới lên để lồng vào hàng trên */
  /* Chiều cao 23px -> Kéo lên 6px là vừa khớp chữ V */
  margin-bottom: -6px;

  background-color: var(--clr, #ccc);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;

  /* Bóng đổ nhẹ */
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
  font-size: 0px !important;
  min-height: 0px !important;
  min-width: 0px !important;

}

/* --- 5. KỸ THUẬT SO LE (ZigZag) --- */
/* Logic: 4 ô thường -> 3 ô thụt vào -> 4 ô thường... */
/* Chu kỳ: 7 ô */

/* Chọn ô đầu tiên của hàng thụt vào (Ô thứ 5, 12, 19...) */
.honeycomb-container .hex-btn.small:nth-child(10n + 6) {
  /* Thụt vào = 1/2 chiều rộng ô (10px) + gap (1px) */
  margin-left: 12px;
}

/* --- HIỆU ỨNG HOVER --- */
.hex-btn.small:hover {
  transform: scale(1.5);
  /* Phóng to nhiều để dễ chọn */
  z-index: 100;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.3));
}

.hex-btn.small.active {
  z-index: 90;
  transform: scale(1.3);
  /* Viền trắng phát sáng */
  filter: drop-shadow(0 0 0 1.5px #fff) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

/* Xử lý màu trắng */
.hex-btn.small[data-color="#ffffff"] {
  background-color: #f8fafc;
}

@media (max-width: 1100px) {

  .wp-coloring-mobile-sidebar {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    padding: 10px 15px !important;
    background: #fff !important;
    border-top: 1px solid #e2e8f0 !important;

    flex-shrink: 0 !important;
    /* Cấm bị co lại, luôn hiển thị đủ */
    z-index: 100 !important;

    /* Đảm bảo an toàn cho iPhone đời mới (tai thỏ) */
    padding-bottom: env(safe-area-inset-bottom, 10px) !important;
  }

  .wp-coloring-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  .wp-coloring-sidebar.right,
  .wp-coloring-sidebar.left {
    display: none !important;
  }

  /* CHỈ ÁP DỤNG KHI KHÔNG PHẢI POPUP (Tức là đang xem Shortcode) */
  /* Ta dùng :not() để loại trừ trường hợp đang nằm trong popup */
  body:not(.coloring-popup-visible) .wp-coloring-shell {
    height: auto !important;
    /* Cho phép chiều cao tự do */
    min-height: 500px !important;
    /* Đảm bảo khung không bị xẹp */
    display: block !important;
    /* Bỏ Flexbox gây co rút */
  }

  body:not(.coloring-popup-visible) .wp-coloring-main {
    height: auto !important;
    min-height: 400px;
    /* Đảm bảo vùng vẽ đủ lớn */
    display: block !important;
    /* Để canvas bung ra */
    padding: 10px !important;
  }

  /* QUAN TRỌNG: Ép ảnh Rộng 100% thay vì Cao 100% */
  body:not(.coloring-popup-visible) .wp-coloring-canvas-outer {
    width: 100% !important;
    /* Chiếm hết chiều ngang màn hình */
    height: auto !important;
    /* Chiều cao tự tính theo tỷ lệ */
    max-height: none !important;
    /* Bỏ giới hạn chiều cao */

    margin: 0 auto !important;
    aspect-ratio: var(--canvas-aspect-ratio, 3/4);
  }

  /* Đảm bảo Grid hiển thị đúng */
  body:not(.coloring-popup-visible) .wp-coloring-grid {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
  }

  /* Đảm bảo thanh công cụ mobile hiện đúng */
  body:not(.coloring-popup-visible) .wp-coloring-mobile-sidebar {
    position: relative !important;
    width: 100% !important;
    margin-top: 10px;
  }
}

/* Brush Size Slider */
.brush-size-control {
  width: 100%;
  padding: 10px 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.brush-size-input {
  -webkit-appearance: none;
  width: 80%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  outline: none;
  opacity: 0.7;
  transition: opacity .2s;
}

.brush-size-input:hover {
  opacity: 1;
}

.brush-size-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: #3b82f6;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.brush-size-input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #3b82f6;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}