/* ==========================================================================
   PixelDot - Clean, Flat Solid Pastel App Design System
   No Gradients, Unified Solid Colors, Below-Tool Palette & Clamped Canvas
   ========================================================================== */

:root {
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-border: #e2e8f0;
  --bg-viewport: #e2e8f0;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-glow: rgba(79, 70, 229, 0.2);

  --secondary: #0284c7;
  --secondary-hover: #0369a1;

  --accent: #ec4899;
  --accent-hover: #db2777;
  --accent-glow: rgba(236, 72, 153, 0.2);

  --text-main: #0f172a;
  --text-sub: #475569;
  --text-muted: #94a3b8;

  --danger: #ef4444;
  --success: #10b981;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --font-body: 'Noto Sans KR', 'Outfit', system-ui, -apple-system, sans-serif;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 20px rgba(15, 23, 42, 0.08);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--bg-app);
  color: var(--text-main);
  user-select: none;
}

/* App Root Layout */
.app-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* Clean Header: Logo on Left, Hamburger Menu on Right */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  padding: 8px 16px;
  height: 48px;
  flex-shrink: 0;
  z-index: 50;
  border-bottom: 1px solid var(--bg-card-border);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo-icon {
  font-size: 1.5rem;
}

.logo-text {
  font-family: 'Outfit', var(--font-body);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.accent-text {
  color: var(--accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-lang-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-lang-toggle:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* Hamburger Button */
.btn-hamburger {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  width: 36px;
  height: 36px;
  background: #f1f5f9;
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  padding: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-hamburger:hover {
  background: #e2e8f0;
}

.hamburger-bar {
  width: 100%;
  height: 2px;
  background: var(--text-main);
  border-radius: 2px;
}

/* Slide-out Drawer Menu */
.hamburger-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 200;
  display: flex;
  justify-content: flex-end;
  pointer-events: auto;
  transition: opacity 0.2s ease;
}

.hamburger-menu.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.menu-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
}

.menu-drawer {
  position: relative;
  width: 290px;
  max-width: 85vw;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  background: var(--bg-card);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.25s ease-out;
  z-index: 201;
  overflow: hidden;
}

.hamburger-menu.hidden .menu-drawer {
  transform: translateX(100%);
}

.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--bg-card-border);
  background: #f8fafc;
  flex-shrink: 0;
}

.menu-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-main);
}

.btn-close-menu {
  background: none;
  border: none;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-sub);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.btn-close-menu:hover {
  color: var(--text-main);
}

.menu-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  padding-bottom: calc(48px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.menu-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  background: #f8fafc;
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.menu-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  transform: translateX(2px);
}

.menu-btn.hidden {
  display: none !important;
}

.menu-btn .icon {
  font-size: 1.15rem;
}

.menu-section-title {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 8px;
  margin-bottom: 2px;
  padding-left: 4px;
}

.menu-divider {
  height: 1px;
  background: var(--bg-card-border);
  margin: 4px 0;
}

.menu-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  cursor: pointer;
  user-select: none;
}

.menu-btn-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  text-align: left;
}

.toggle-switch-box {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.toggle-switch-box input {
  display: none;
}

.toggle-switch-track {
  width: 34px;
  height: 20px;
  background: #cbd5e1;
  border-radius: var(--radius-full);
  position: relative;
  transition: background 0.2s ease;
  display: inline-block;
  flex-shrink: 0;
}

.toggle-switch-track::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  top: 3px;
  left: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.toggle-switch-box input:checked + .toggle-switch-track {
  background: var(--accent);
}

.toggle-switch-box input:checked + .toggle-switch-track::before {
  transform: translateX(14px);
}

.menu-btn-danger {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.05);
}

.menu-btn-danger:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: var(--danger);
}

.menu-btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.menu-btn-primary:hover {
  background: var(--primary-hover);
}

/* Print sub-options collapsible panel */
.print-sub-options {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 8px 8px 8px 20px;
  border-left: 3px solid var(--primary);
  margin-left: 8px;
  background: #f8fafc;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.print-sub-options.open {
  display: flex;
}

.print-sub-toggle {
  font-size: 0.82rem;
  padding: 8px 10px;
}



/* Button System - Solid Clean Colors (No Gradients) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--text-main);
  border: 1px solid var(--bg-card-border);
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-accent {
  background: #ef4444;
  color: #fff;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.25);
}

.btn-accent:hover {
  background: #dc2626;
  transform: translateY(-1px);
}

.btn-large {
  padding: 14px 24px;
  font-size: 1.05rem;
  border-radius: var(--radius-md);
}

.btn-small {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.btn-tiny {
  padding: 3px 8px;
  font-size: 0.75rem;
}

.btn-block {
  width: 100%;
}

.btn-danger-text:hover {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.hidden {
  display: none !important;
}

/* Screen Sections */
.screen-section {
  flex: 1;
  width: 100%;
  position: relative;
  overflow: hidden;
}

/* =========================================================================
   SCREEN 1: Setup Phase Layout
   ========================================================================= */
#screen-setup {
  overflow-y: auto;
  padding: 16px;
}

.setup-container {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 30px;
}

.upload-card-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.upload-card {
  background: var(--bg-card);
  border: 2px dashed rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  max-width: 550px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.upload-icon-wrapper {
  font-size: 2.8rem;
  margin-bottom: 8px;
}

.upload-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.upload-desc {
  font-size: 0.82rem;
  color: var(--text-sub);
  line-height: 1.5;
  margin-bottom: 18px;
}

.sample-images {
  margin-top: 20px;
  border-top: 1px solid var(--bg-card-border);
  padding-top: 14px;
}

.sample-title {
  font-size: 0.82rem;
  color: var(--text-sub);
  margin-bottom: 8px;
}

.sample-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.sample-btn {
  background: #f1f5f9;
  border: 1px solid var(--bg-card-border);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.sample-btn:hover {
  background: var(--primary);
  color: #fff;
}

/* Setup Preview Pane */
.setup-preview-pane {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: stretch;
}

.setup-controls-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
  justify-content: space-between;
}

.setup-card-title {
  font-size: 1.05rem;
  font-weight: 800;
}

.image-meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.image-meta-row img {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 2px solid var(--primary);
}

.meta-tags {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.badge-ratio, .badge-dim {
  font-size: 0.75rem;
  font-weight: 700;
  background: #f1f5f9;
  color: var(--text-sub);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  width: fit-content;
}

.setup-slider-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 700;
}

.slider-val {
  color: var(--accent);
  background: rgba(236, 72, 153, 0.1);
  padding: 1px 8px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
}

.slider-track-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider-min-label, .slider-max-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

input[type="range"] {
  flex-grow: 1;
  appearance: none;
  -webkit-appearance: none;
  height: 8px;
  background: #cbd5e1;
  border-radius: var(--radius-full);
  outline: none;
  touch-action: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.setup-preview-box {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 400px;
}

.preview-box-label {
  font-size: 0.9rem;
  font-weight: 800;
  align-self: flex-start;
}

.setup-preview-viewport {
  width: 100%;
  flex: 1;
  min-height: 320px;
  background: #f1f5f9;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: hidden;
  position: relative;
}

#setup-preview-canvas {
  max-width: 100% !important;
  max-height: 100% !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
  border-radius: 4px;
  display: block;
}

/* =========================================================================
   SCREEN 2: Full-screen No-Scroll Coloring Workspace
   ========================================================================= */
#screen-coloring {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.coloring-screen-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: relative;
  overflow: hidden;
}

/* Control Header 1: Grid Toggles, Zoom, Progress, Actions */
.canvas-control-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border-bottom: 1px solid var(--bg-card-border);
  padding: 6px 12px;
  gap: 8px;
  flex-shrink: 0;
  z-index: 40;
}

/* Grid Line Toggle Pills */
.header-grid-toggles {
  display: flex;
  align-items: center;
  gap: 4px;
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-sub);
  cursor: pointer;
  border: 1px solid var(--bg-card-border);
  user-select: none;
}

.toggle-pill input {
  accent-color: var(--primary);
  cursor: pointer;
}

.zoom-fit-btn {
  font-weight: 800;
  padding: 4px 10px;
  font-size: 0.78rem;
  background: #f1f5f9;
  border: 1px solid var(--bg-card-border);
}

.zoom-fit-btn:hover {
  background: #e2e8f0;
}

#btn-toggle-minimap.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.header-right-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.progress-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #047857;
  font-weight: 800;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

/* Canvas Viewports & Dual View Split Layout */
.workspace-viewports-wrapper {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: row;
  position: relative;
  overflow: hidden;
  background: var(--bg-viewport);
}

.target-viewport-container,
.main-viewport-container {
  flex: 1;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: var(--bg-viewport);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.workspace-viewports-wrapper.dual-view-active .target-viewport-container {
  border-right: 2px solid var(--bg-card-border);
}

.viewport-label-tag {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 15;
  background: rgba(15, 23, 42, 0.75);
  color: #ffffff;
  padding: 2px 7px;
  border-radius: 0 0 6px 0;
  font-size: 0.68rem;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  user-select: none;
}

.viewport-label-tag.user-tag {
  background: rgba(79, 70, 229, 0.8);
}

#target-ref-canvas {
  display: block;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.2);
  border-radius: 4px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.canvas-transform-layer {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

#user-canvas {
  display: block;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.2);
  border-radius: 4px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Red Bounding Inspection Box with Dedicated Drag Handle */
.canvas-inspection-overlay {
  position: absolute;
  border: 3px solid #ef4444;
  background: rgba(239, 68, 68, 0.08);
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.5), inset 0 0 10px rgba(239, 68, 68, 0.1);
  border-radius: 2px;
  pointer-events: none;
  z-index: 20;
}

.inspection-drag-handle {
  position: absolute;
  top: -26px;
  left: -3px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #ef4444;
  color: #fff;
  padding: 3px 8px;
  border-radius: 4px 4px 0 0;
  font-size: 0.72rem;
  font-weight: 800;
  cursor: move;
  pointer-events: auto;
  touch-action: none;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}

.drag-icon {
  font-size: 0.85rem;
}

.inspection-tag {
  letter-spacing: 0.5px;
}

/* Fixed Answer Comparison Pane (Positioned directly ABOVE canvas viewport) */
.fixed-compare-pane {
  background: #ffffff;
  border-bottom: 2px solid #ef4444;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 12px;
  flex-shrink: 0;
  z-index: 38;
  overflow: hidden;
  animation: slideDownPane 0.2s ease-out;
}

.fixed-compare-pane.hidden {
  display: none !important;
}

@keyframes slideDownPane {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.compare-pane-body {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 3px;
}

#compare-canvas {
  display: block;
  border: 1.5px solid #ef4444;
  border-radius: 3px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  max-width: 100%;
  max-height: 90px;
  height: auto;
}

/* =========================================================================
   Bottom Bar: Palette placed BELOW Tools
   ========================================================================= */
.bottom-coloring-bar {
  background: var(--bg-card);
  border-top: 1px solid var(--bg-card-border);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  z-index: 40;
}

/* Upper Row: Tools & Unified Hint Switch */
.left-tools-col {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 520px;
}

.icon-tools-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f1f5f9;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.icon-tool-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.icon-tool-btn.active {
  border-color: var(--accent);
  background: rgba(236, 72, 153, 0.15);
  transform: scale(1.05);
}

.tool-divider {
  width: 1px;
  height: 20px;
  background: #cbd5e1;
}

.hint-progress-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Unified Hint Control */
.unified-hint-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.unified-hint-control:hover {
  background: #e2e8f0;
}

.hint-label-text {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-main);
}

.hint-switch-box {
  display: inline-flex;
  align-items: center;
}

.hint-switch-box input {
  display: none;
}

.hint-switch-track {
  width: 32px;
  height: 18px;
  background: #cbd5e1;
  border-radius: var(--radius-full);
  position: relative;
  transition: background 0.2s ease;
  display: inline-block;
}

.hint-switch-track::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  top: 3px;
  left: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.hint-switch-box input:checked + .hint-switch-track {
  background: var(--accent);
}

.hint-switch-box input:checked + .hint-switch-track::before {
  transform: translateX(14px);
}

/* Lower Row (Placed BELOW left-tools-col): Swatches area scrolling DOWNWARDS */
.palette-vertical-area {
  width: 100%;
  max-width: 520px;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

.palette-scroll-down-container {
  height: 94px;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 4px;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  background: #f8fafc;
}

.palette-swatches-vertical-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 8px;
  justify-items: center;
}

.swatch-item {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 2px solid rgba(0, 0, 0, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.swatch-item:hover {
  transform: scale(1.06);
}

.swatch-item.active {
  border-color: #000;
  transform: translateY(-4px) scale(1.1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  z-index: 10;
}

.swatch-num {
  font-size: 0.95rem;
  font-weight: 900;
  text-shadow: 0 0 3px rgba(255,255,255,0.9), 0 0 2px rgba(255,255,255,0.9);
}

.swatch-count {
  font-size: 0.58rem;
  font-weight: 800;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 0 3px;
  border-radius: var(--radius-full);
  position: absolute;
  bottom: -4px;
}

/* Print Template */
.print-template {
  display: none;
}

@media print {
  /* Printing is handled via iframe in print.js - hide everything else */
  body > * {
    display: none !important;
  }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .setup-preview-pane {
    grid-template-columns: 1fr;
  }

  .workspace-viewports-wrapper.dual-view-active {
    flex-direction: column;
  }

  .workspace-viewports-wrapper.dual-view-active .target-viewport-container {
    height: 50%;
    width: 100%;
    border-right: none;
    border-bottom: 2px solid var(--bg-card-border);
  }

  .workspace-viewports-wrapper.dual-view-active .main-viewport-container {
    height: 50%;
    width: 100%;
  }

  .btn {
    padding: 4px 8px;
    font-size: 0.76rem;
  }

  .toggle-pill {
    padding: 2px 6px;
    font-size: 0.7rem;
  }

  .icon-tool-btn {
    width: 34px;
    height: 34px;
    font-size: 1.05rem;
  }

  .swatch-item {
    width: 36px;
    height: 36px;
  }

  .palette-swatches-vertical-grid {
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  }
}

/* Custom Modal Overlay */
.custom-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn 0.18s ease-out;
}

.custom-modal-overlay.hidden {
  display: none !important;
}

.custom-modal-box {
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
}

.custom-modal-header {
  padding: 18px 20px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.custom-modal-icon {
  font-size: 1.5rem;
}

.custom-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-color);
  margin: 0;
}

.custom-modal-body {
  padding: 0 20px 18px;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.custom-modal-footer {
  padding: 12px 20px 16px;
  background: #f8fafc;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid #e2e8f0;
}

.btn-modal {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.btn-modal-cancel {
  background: #e2e8f0;
  color: #475569;
}
.btn-modal-cancel:hover {
  background: #cbd5e1;
}

.btn-modal-confirm {
  background: #ef4444;
  color: #ffffff;
}
.btn-modal-confirm:hover {
  background: #dc2626;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* Logo Header Image Icon */
.logo-img-icon {
  width: 26px;
  height: 26px;
  object-fit: contain;
  image-rendering: pixelated;
  margin-right: 6px;
  vertical-align: middle;
}

/* Google AdSense Bottom Banner Area (In-flow flex child inside .app-root) */
.google-ad-banner-area {
  display: none; /* Hidden by default when no ad is active/loaded */
  position: relative;
  width: 100%;
  min-height: 50px;
  max-height: 90px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  padding: 4px 12px;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  z-index: 30;
  box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}

/* Automatically show bottom ad banner when active ad script is enabled */
.google-ad-banner-area.active,
.google-ad-banner-area:has(ins.adsbygoogle) {
  display: flex !important;
}

.ad-banner-wrapper {
  width: 100%;
  max-width: 728px;
  height: 100%;
  max-height: 90px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ad-banner-wrapper ins.adsbygoogle {
  display: block !important;
  max-height: 90px !important;
  overflow: hidden !important;
}

.ad-label-tag {
  position: absolute;
  top: 2px;
  left: 6px;
  font-size: 0.62rem;
  background: #cbd5e1;
  color: #475569;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 700;
  line-height: 1;
  z-index: 2;
}

.ad-placeholder-box {
  width: 100%;
  height: 48px;
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #64748b;
  font-size: 0.82rem;
  font-weight: 600;
}
