:root {
  /* Colors */
  --bg-app: #0f172a; /* Slate 900 */
  --bg-panel: rgba(30, 41, 59, 0.7); /* Slate 800 with opacity */
  --bg-panel-hover: rgba(30, 41, 59, 0.9);
  --border-color: rgba(255, 255, 255, 0.1);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-accent: #38bdf8;
  
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  
  --sidebar-width: 260px;
  --header-height: 70px;
  --ad-banner-height: 90px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden; /* Prevent body scroll, layout handles it */
}

/* Layout */
.app-layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
}

/* Glassmorphism */
.glass-panel, .glass-card {
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  border-radius: 0;
  z-index: 10;
}

.logo-container {
  display: flex;
  align-items: center;
  padding: 24px;
  gap: 12px;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.nav-menu {
  flex: 1;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  padding: 16px 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-item:hover {
  background: var(--bg-panel-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  border-left: 3px solid var(--primary);
}

/* Ad Containers */
.ad-container {
  background: rgba(0,0,0,0.2);
  border: 1px dashed var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ad-label {
  font-size: 0.65rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.sidebar-ad {
  margin: 24px 16px;
  padding: 16px;
  border-radius: 8px;
  min-height: 250px; /* Standard sidebar ad size */
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
}

.sidebar-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s ease;
}

.sidebar-footer a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.sidebar-footer p {
  margin-top: 8px;
  font-size: 0.7rem;
}

.top-banner-ad {
  width: 100%;
  height: var(--ad-banner-height);
  flex-shrink: 0;
}

.ad-placeholder-box {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  position: relative;
}

.tool-view {
  display: none;
  min-height: 100%;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
}

.tool-view.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.view-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.view-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Workspace Layout */
.workspace-layout {
  display: flex;
  gap: 24px;
  flex: 1;
  min-height: 0;
}

.workspace-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* Drop Zone & Canvas */
.drop-zone {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border-color);
  transition: all 0.3s ease;
  cursor: pointer;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.05);
}

.drop-icon {
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.text-link {
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
}

.text-link:hover {
  color: var(--primary-hover);
}

.canvas-wrapper {
  position: relative;
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1e293b url('data:image/svg+xml;utf8,<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg"><rect width="10" height="10" fill="rgba(255,255,255,0.03)"/><rect x="10" y="10" width="10" height="10" fill="rgba(255,255,255,0.03)"/></svg>');
}

canvas {
  display: block;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  image-rendering: pixelated;
}

.region-overlay {
  position: absolute;
  top: 0; left: 0;
  transform: none;
  pointer-events: none;
}

.sprite-box {
  position: absolute;
  border: 1px solid #10b981;
  background: rgba(16, 185, 129, 0.2);
}

/* Controls Sidebar */
.workspace-sidebar {
  width: 280px;
  flex-shrink: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

/* Form Controls */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.control-header span {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-accent);
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 32px; /* Huge touch target */
  background: transparent;
  outline: none;
  margin: 0;
  padding: 0;
  cursor: pointer;
  touch-action: none;
}

.slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  box-sizing: border-box;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
  margin-top: -6px; /* (6px track height - 18px thumb height) / 2 = -6px */
  box-sizing: border-box;
}

.slider::-moz-range-track {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}

.slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
}

.input-text {
  width: 100%;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border-color);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
}

.input-text:focus {
  border-color: var(--primary);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  user-select: none;
}

.checkbox-label input {
  display: none;
}

/* Edit Toolbar */
.coloring-toolbar {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex: none;
}

.tool-group {
  display: flex;
  gap: 6px;
}

.tool-btn {
  padding: 6px 16px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.tool-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.tool-config {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 16px;
  border-left: 1px solid var(--border-color);
}

.tool-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.tool-actions {
  margin-left: auto;
}

.tool-action-btn {
  padding: 6px 16px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}
.tool-action-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.1);
}
.tool-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.custom-checkbox {
  width: 18px;
  height: 18px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.checkbox-label input:checked + .custom-checkbox {
  background: var(--primary);
  border-color: var(--primary);
}

.checkbox-label input:checked + .custom-checkbox::after {
  content: '';
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: 8px;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
}

.stat-row strong {
  color: #10b981;
}

/* Buttons */
.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

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

.btn-secondary {
  background: rgba(255,255,255,0.1);
  color: white;
}
.btn-secondary:hover { background: rgba(255,255,255,0.15); }

.btn-accent {
  background: var(--accent);
  color: white;
}
.btn-accent:hover { background: var(--accent-hover); }

.btn-full {
  width: 100%;
}

.hidden {
  display: none !important;
}

/* --- NEW LAYOUT STYLES --- */
.workspace-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
}

.settings-top-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 20px;
}

.settings-row {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}
.settings-row.divider {
  height: 1px;
  background: var(--border-color);
  width: 100%;
}

.setting-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 120px;
}

.setting-block.actions {
  flex-direction: row;
  align-items: flex-end;
  gap: 8px;
  margin-left: auto;
}

.options-block {
  flex-direction: row;
  align-items: center;
  gap: 16px;
}

.export-block {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}
.export-inputs {
  display: flex;
  gap: 8px;
}

.canvas-wrapper {
  flex: 1;
  overflow: hidden;
  display: flex;
  position: relative;
  min-height: 60vh;
  background: #1e293b url('data:image/svg+xml;utf8,<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg"><rect width="10" height="10" fill="rgba(255,255,255,0.03)"/><rect x="10" y="10" width="10" height="10" fill="rgba(255,255,255,0.03)"/></svg>');
}

.content-section {
  margin: 32px 0;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.content-section h3 {
  color: var(--text-primary);
  font-size: 1.4rem;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.content-section h4 {
  color: var(--text-primary);
  font-size: 1.1rem;
  margin-top: 24px;
  margin-bottom: 12px;
}

.content-section p {
  margin-bottom: 16px;
}

.content-section ul, .content-section ol {
  padding-left: 24px;
  margin-bottom: 16px;
}

.content-section li {
  margin-bottom: 8px;
}

/* The container MUST wrap the canvas exactly for the absolute overlay to match */
.canvas-container {
  position: relative;
  display: block; /* use block for proper auto margin */
  margin: auto; /* this centers it in flex parent without clipping overflow! */
  line-height: 0;
}

.region-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
}

.sprite-bottom-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  min-height: 150px;
  max-height: 40vh;
  flex-shrink: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel-header h3 {
  font-size: 14px;
  color: var(--text-secondary);
  text-transform: uppercase;
}
.preview-size-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.preview-size-control input { width: 100px; }

.preview-list-horizontal {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  align-items: flex-start;
  padding-bottom: 8px;
  padding-right: 8px;
}
.preview-list-horizontal::-webkit-scrollbar { width: 6px; }
.preview-list-horizontal::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

.preview-item {
  flex-direction: column;
  align-items: stretch;
  min-width: var(--preview-size, 80px);
  width: var(--preview-size, 80px);
  background: rgba(255,255,255,0.03);
  padding: 6px;
  gap: 6px;
}
.preview-item-thumb {
  width: 100%;
  height: var(--preview-size, 64px); /* Dynamic height via CSS var */
  position: relative;
}
.preview-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: bold;
  padding: 2px 4px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 2;
}
.preview-item-info {
  width: 100%;
}
.preview-item-actions {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-top: 4px;
}

.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* Region boxes */
.region-box {
  position: absolute;
  border: 2px solid var(--accent);
  background: rgba(139, 92, 246, 0.1);
  border-radius: 4px;
  pointer-events: auto;
  cursor: move;
}

.region-box:hover {
  border-color: #a78bfa;
  background: rgba(167, 139, 250, 0.2);
}

#floating-text-input {
  position: absolute;
  z-index: 100;
  background: transparent;
  border: 1px dashed var(--accent);
  outline: none;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  color: #000;
  padding: 0;
  margin: 0;
  line-height: 1;
  box-sizing: border-box;
  user-select: auto !important;
  -webkit-user-select: auto !important;
  pointer-events: auto !important;
}
#floating-text-input::placeholder {
  color: rgba(0,0,0,0.3);
}

/* Eraser Cursor */
.eraser-cursor {
  position: fixed;
  border: 1px dashed var(--accent);
  background: rgba(59, 130, 246, 0.3); /* Transparent blue */
  border-radius: 50%;
  pointer-events: none;
  display: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
}

/* Text Cursor */
.text-cursor {
  position: fixed;
  border: 1px dashed var(--accent);
  background: rgba(59, 130, 246, 0.1);
  pointer-events: none;
  display: none;
  z-index: 9999;
  transform: translate(0, -50%);
  box-sizing: border-box;
}

.region-label {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 2px 0 4px 0;
}

.region-delete {
  position: absolute;
  top: 0;
  right: 0;
  background: #f43f5e;
  color: white;
  border: none;
  font-size: 10px;
  width: 16px;
  height: 16px;
  border-radius: 0 2px 0 4px;
  cursor: pointer;
  opacity: 0;
}
.region-box:hover .region-delete { opacity: 1; }

.resize-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border: 1px solid white;
}
.resize-handle.nw { top: -4px; left: -4px; cursor: nw-resize; }
.resize-handle.ne { top: -4px; right: -4px; cursor: ne-resize; }
.resize-handle.sw { bottom: -4px; left: -4px; cursor: sw-resize; }
.resize-handle.se { bottom: -4px; right: -4px; cursor: se-resize; }

.drawing-overlay {
  position: absolute;
  inset: 0;
  cursor: crosshair;
  z-index: 10;
}
.draw-rect {
  position: absolute;
  border: 2px dashed #a78bfa;
  background: rgba(167, 139, 250, 0.1);
}

/* Legacy preview styles removed to use dynamic sizing above */

.preview-item-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.preview-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.preview-item-name-input {
  background: transparent;
  border: 1px dashed transparent;
  color: white;
  font-size: 12px;
  padding: 2px;
  width: 100%;
}
.preview-item-name-input:focus { border-color: var(--primary); }

.preview-item-size {
  font-size: 11px;
  color: var(--text-secondary);
}

.preview-item-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
}
.preview-item-btn:hover { color: white; }
.preview-item-btn.danger:hover { color: #f43f5e; }

/* ===== Coloring Page Styles ===== */

/* Before/After Compare Container */
.coloring-compare-container {
  position: relative;
  /* width and height set by JS */
  overflow: hidden;
  cursor: ew-resize;
  user-select: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.coloring-canvas-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

/* Slider Line */
.coloring-slider-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--primary);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
  z-index: 10;
  pointer-events: none;
  left: 50%;
  transform: translateX(-50%);
}

/* Slider Handle */
.coloring-slider-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid white;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: ew-resize;
  z-index: 11;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
  transition: transform 0.1s;
  touch-action: none;
}

.coloring-slider-handle:hover {
  transform: translate(-50%, -50%) scale(1.1);
}

.slider-arrow {
  font-size: 10px;
  color: white;
  line-height: 1;
}

/* Preset Buttons */
.coloring-preset-btn {
  padding: 6px 16px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
}

.coloring-preset-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.coloring-preset-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Progress Bar */
.coloring-progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
}

.coloring-progress-track {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}

.coloring-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 3px;
  transition: width 0.15s ease;
}

.coloring-progress-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
  min-width: 90px;
}

#print-container {
  display: none;
}

/* Global Footer */
.global-footer {
  text-align: center;
  padding: 24px 0;
  margin-top: 40px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}















@media print {
  html, body {
    width: 100%;
    height: 100%;
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
  }
  body > *:not(#print-container) {
    display: none !important;
  }
  #print-container {
    display: block !important;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  #print-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    margin: 0 auto;
  }
}

/* Mobile Responsiveness */
@media screen and (max-width: 768px) {
  /* Layout */
  .app-layout {
    flex-direction: column;
  }
  
  /* Sidebar -> Bottom Navigation */
  .sidebar {
    width: 100%;
    height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    flex-direction: row;
    order: 2;
    border-right: none;
    border-top: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.95);
    z-index: 100;
    padding: 0;
    flex-shrink: 0;
  }
  
  .logo-container, .sidebar-ad, .nav-section-title {
    display: none;
  }
  
  .nav-menu {
    flex-direction: row;
    width: 100%;
    padding: 0;
    margin: 0;
    gap: 0;
    justify-content: space-around;
  }
  
  
  .lang-item {
    margin-top: 0 !important;
    padding: 0 !important;
  }
  .lang-item select {
    padding: 0 !important;
    font-size: 0.65rem !important;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
  }
  .nav-item {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 6px 0;
    gap: 4px;
    border-radius: 0;
    font-size: 0.65rem;
    color: var(--text-muted);
    min-width: 0;
  }
  .nav-item span:not(.icon) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: inline-block;
  }
  
  .nav-item.active {
    border-left: none;
    background: transparent;
    color: var(--primary);
  }
  .nav-item.active .icon {
    transform: scale(1.1);
  }
  
  .nav-item .icon {
    font-size: 1.4rem;
    margin: 0;
  }
  
  /* Main Content */
  .main-content {
    order: 1;
    height: calc(100vh - 64px - env(safe-area-inset-bottom));
    height: calc(100dvh - 64px - env(safe-area-inset-bottom));
    flex: 1;
  }
  
  .top-banner-ad {
    display: none;
  }
  
  /* View Headers */
  .view-header {
    padding: 12px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .view-header > div:last-child {
    display: flex;
    width: 100%;
    justify-content: space-between;
  }
  .view-subtitle {
    display: none;
  }
  .view-header h2 {
    font-size: 1.2rem;
  }
  
  /* Mobile settings layout */
  .settings-top-bar {
    padding: 10px;
    max-width: 100vw;
    box-sizing: border-box;
  }
  .settings-row {
    flex-wrap: wrap;
    padding-bottom: 0;
    justify-content: flex-start;
    gap: 8px;
  }
  
  .setting-block {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
  
  .setting-block.actions,
  .options-block,
  .export-block {
    flex-wrap: wrap;
    margin-left: 0;
    width: 100%;
    flex: 1 1 100%;
    justify-content: flex-start;
  }
  
  .slider {
    height: 40px; /* Even bigger touch target for mobile */
    margin: 4px 0;
  }
  .slider::-webkit-slider-runnable-track {
    height: 6px;
  }
  .slider::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
    margin-top: -9px; /* (6 - 24) / 2 = -9px */
  }
  .slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
  }
  
  .setting-item {
    padding: 10px;
  }
  
  /* Style preset buttons: wrap to fit */
  .coloring-preset-btn {
    padding: 5px 10px;
    font-size: 0.7rem;
  }
  
  /* Make sidebar sections scrollable horizontally on mobile */
  .sidebar-section {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
  }
  
  .sidebar-section-content {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: 12px;
  }
  
  /* Splitter Grid */
  .sprites-grid {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    padding: 12px;
    gap: 12px;
  }
  
  /* Coloring Toolbar */
  .coloring-toolbar {
    padding: 8px;
  }
  .tool-btn {
    font-size: 0.8rem;
    padding: 6px 10px;
  }
  
  /* Coloring floating elements adjustments */
  .text-controls {
    bottom: 74px; /* above bottom nav */
    right: 10px;
    left: 10px;
    justify-content: space-between;
  }
  
  .eraser-size-control {
    bottom: 74px;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
  }
  
  /* Animator Workspace */
  #view-sprite-animator .workspace-main {
    flex-direction: column;
  }
  #view-sprite-animator .workspace-sidebar {
    width: 100%;
    height: auto;
    max-height: 40vh;
    border-left: none;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
  }
}

.global-footer .footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}
.global-footer .footer-links a:hover {
  color: var(--accent);
}
