:root {
  --bg-color: #0f172a;
  --panel-bg: #1e293b;
  --panel-border: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.5);
  --success: #10b981;
  --danger: #ef4444;
  --font-family: 'Inter', sans-serif;
  --glass-bg: rgba(15, 23, 42, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-accent: rgba(59, 130, 246, 0.15);
}

.ag-image-tool-app, .ag-image-tool-app * {
  box-sizing: border-box;
}

.ag-image-tool-app {
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  height: 100vh; /* Fill entire viewport for standalone/fullscreen */
  min-height: 600px;
  width: 100%;
  overflow: hidden; /* App feel by default, restricted to the container */
  display: flex;
  flex-direction: column;
  position: relative;
}

/* WordPress Shortcode Mode: Seamless Inline Integration */
.ag-image-tool-app.is-shortcode-mode {
  height: 850px !important; 
  min-height: 700px;
  max-height: 95vh;
  margin: 0 !important; /* Remove external margins to blend with GP containers */
  border-radius: 0; /* Flat edges for seamless blending */
  overflow: hidden !important; 
  touch-action: pan-y; 
  box-shadow: none; /* Remove shadows for flat integration */
  border: none; /* Remove borders */
  contain: content; 
  outline: none;
}

/* Internal Workspace Flattening for WordPress */
.ag-image-tool-app.is-shortcode-mode .drop-zone {
  border-radius: 0 !important;
}

.ag-image-tool-app.is-shortcode-mode:focus-within {
  outline: none;
}

/* Ensure Launcher Cards and AI Loaders are also square in Shortcode Mode */
.ag-image-tool-app.is-shortcode-mode .mode-card,
.ag-image-tool-app.is-shortcode-mode .loader-content,
.ag-image-tool-app.is-shortcode-mode .hub-card {
  border-radius: 0 !important;
}

/* =====================================================
   ZERO-FLICKER HUB INITIALIZATION
   Hides the interface until the mode is determined.
   ===================================================== */
#hub-phase-container, 
#hub-mode-display {
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* Show only when the mode attribute is present on the wrapper */
.ag-image-tool-app[data-app-mode] #hub-phase-container,
.ag-image-tool-app[data-app-mode] #hub-mode-display {
    opacity: 1;
}

/* Default: Hide all mode-specific components */
#hub-ai-demo-wrap, 
#hub-eraser-demo-wrap, 
#hub-ai-model-wrap, 
#hub-eraser-title-wrap,
#hub-quick-config-wrap, 
#hub-resizer-config-wrap {
    display: none !important;
}

/* Show components ONLY when the corresponding data-app-mode matches */
.ag-image-tool-app[data-app-mode="ai-bg"] #hub-ai-demo-wrap,
.ag-image-tool-app[data-app-mode="ai-bg"] #hub-ai-model-wrap,
.ag-image-tool-app[data-app-mode="all"] #hub-input-methods-wrap {
    display: block !important;
}

.ag-image-tool-app[data-app-mode="all"] #hub-phase-container {
    display: flex !important;
    justify-content: center;
}

.ag-image-tool-app[data-app-mode="eraser-magic"] #hub-eraser-demo-wrap,
.ag-image-tool-app[data-app-mode="eraser-magic"] #hub-eraser-title-wrap {
    display: block !important;
}

.ag-image-tool-app[data-app-mode="compressor"] #hub-quick-config-wrap {
    display: block !important;
}

.ag-image-tool-app[data-app-mode="resizer"] #hub-resizer-config-wrap {
    display: block !important;
}

/* Landing Page: Always scrollable */
.ag-image-tool-app.launcher-active {
  overflow-y: auto !important;
}

/* First Screen (Upload Phase): Enable scroll on the body ONLY for non-studio modes */
.ag-image-tool-app[data-app-mode]:not([data-app-mode="passport"]):not(.is-workspace-active) {
  overflow-y: auto !important;
}

/* Workspace Scroll Management */
.workspace {
  flex: 1;
  position: relative;
  overflow: hidden; /* Locked for editor */
}

/* First Screen Workspace: Allow content to flow if it's long */
.ag-image-tool-app[data-app-mode]:not([data-app-mode="passport"]):not(.is-workspace-active) .workspace {
  overflow-y: auto !important;
  display: block; /* Allow vertical flow */
}

/* Ensure empty-state (First Screen) can grow with content */
.ag-image-tool-app[data-app-mode]:not([data-app-mode="passport"]):not(.is-workspace-active) .empty-state {
  height: auto !important;
  min-height: 100%;
  padding-top: 40px;
  padding-bottom: 40px;
}

/* Header */
.app-header {
  display: none !important;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(to right, #fff, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo i {
  color: var(--accent);
  -webkit-text-fill-color: initial;
}

.header-status {
  font-size: 0.85rem;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Main Layout - Optimized for Launcher Preload */
.app-container {
  display: flex;
  flex: 1;
  position: relative;
  width: 100%;


  max-width: 1600px;
  margin: 0 auto;

  height: 100%;
  overflow: visible;
}

/* Shortcode Mode Internal Height Fix */
.ag-image-tool-app.is-shortcode-mode .app-container {
  height: 100% !important; /* Take up the parent's fixed 850px */
}
.ag-image-tool-app.launcher-active .app-container {
  visibility: hidden;
  filter: blur(10px);
}

/* Controls Sidebar */
.controls-panel {
  width: 30%;
  flex-shrink: 0;
  min-width: 300px;
  /* Professional midnight slate background */
  background: #0f172a;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  box-shadow: inset -5px 0 20px rgba(0, 0, 0, 0.2);
}

.resizer {
  width: 14px;
  background: var(--panel-bg);
  border-right: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--panel-border);
  cursor: col-resize;
  z-index: 10;
  transition: all 0.2s;
  font-size: 10px;
}
.resizer:hover, .resizer.active {
  background: var(--accent);
  color: #fff;
}

.control-group {
  background: rgba(30, 41, 59, 0.4); /* Slightly lighter slate for better glass definition */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 20px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.control-group:hover {
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.2);
}

.group-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 8px;
  color: var(--text-main);
}

.group-title span:first-child {
  background: linear-gradient(to right, #fff, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.group-title i {
  color: var(--accent);
  margin-right: 4px;
}

/* Tooltips */
.tooltip-icon {
  color: var(--text-muted);
  cursor: help;
  font-size: 0.85rem;
  position: relative;
  transition: color 0.2s;
}
.tooltip-icon:hover {
  color: var(--text-main);
}

.tooltip-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 240px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: var(--font-family);
  line-height: 1.4;
  text-align: left;
  white-space: pre-wrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
  pointer-events: none;
  z-index: 10000;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* Prevent tooltips on the right side from clipping out of the container bounds */
.group-title .tooltip-icon::after,
.url-input-wrapper .tooltip-icon::after,
.control-row .tooltip-icon::after {
  left: auto;
  right: -5px;
  transform: none;
}
.tooltip-icon:hover::after {
  opacity: 1;
  visibility: visible;
  bottom: 140%;
}

/* Inputs & Buttons */
.form-control {
  width: 100%;
  background: #0f172a;
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  transition: border 0.3s;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  font-family: inherit;
  cursor: pointer;
  border-radius: 12px;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  padding: 10px 15px;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 10px var(--accent-glow);
}
.btn-outline {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--panel-border);
}

.btn-danger {
  background-color: var(--danger) !important;
  color: #fff !important;
  border: none !important;
}

.btn-danger:hover {
  background-color: #dc2626 !important;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

.btn-toggle-active {
    background: transparent !important;
    border: 2px solid #ffffff !important;
    color: #ffffff !important;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

.btn-retouch-inactive {
    border-color: var(--accent) !important;
    color: var(--accent) !important;
}

.panel-active-style {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}
.btn-outline:hover {
  background: var(--panel-border);
}
.btn-action {
  background: #475569;
  color: white;
}
.btn-action:hover {
  background: #64748b;
}

.w-100 { width: 100%; }
.mt-10 { margin-top: 12px; }
.mb-10 { margin-bottom: 12px; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }

/* Control Rows structure */
.control-row {
  display: flex;
  gap: 12px;
  align-items: center;
}
.align-center {
  align-items: center;
}

.input-methods {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 440px;
}
.url-input-wrapper {
  display: flex;
  background: #0f172a;
  border: 1px solid var(--panel-border);
  border-radius: 50px;
  overflow: hidden;
  transition: all 0.3s;
}
.url-input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}
.url-input-wrapper input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: #fff;
  padding: 10px 18px;
  font-size: 0.9rem;
  outline: none;
}
#btn-fetch-url {
  flex-shrink: 0;
  border: none;
  background: rgba(255,255,255,0.05);
  border-left: 1px solid var(--panel-border);
  border-radius: 0;
  padding: 0 15px;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}
#btn-fetch-url:hover {
  background: var(--accent);
  color: #fff;
}
.url-input-wrapper .btn {
  border-radius: 0;
  border: none;
  height: 100%;
}

.hub-or-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 8px 0;
}

.hub-or-divider::before,
.hub-or-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(to var(--dir, right), rgba(59, 130, 246, 0.4), transparent);
}

.hub-or-divider::after {
    --dir: left;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--panel-border);
  transition: .4s;
  border-radius: 20px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  background-color: white;
  transition: .4s;
  border-radius: 100px; /* Large value for smoother circular corners */
  box-shadow: 0 0 1px rgba(0,0,0,0.5), 0 2px 4px rgba(0,0,0,0.3); /* Thin ring shadow helps anti-aliasing */
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  image-rendering: -webkit-optimize-contrast; /* Force sharpness */
}
input:checked + .slider { background-color: var(--accent) !important; }
input:focus + .slider { box-shadow: 0 0 1px var(--accent); }
input:checked + .slider:before { transform: translate(16px, -50%); }

.toggle-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  display:flex;
  align-items: center;
  gap:5px;
}

/* Dimensions specific layout */
.dimensions-row {
  display: flex;
  align-items: center;
  margin-top: 10px;
  gap: 8px;
}
.input-col { flex: 1; display:flex; flex-direction:column; gap:4px; font-size: 11px; color: var(--text-muted); }
.link-col { flex: 0 0 24px; display:flex; justify-content:center; margin-top:15px; }
.btn-icon { background:none; border:none; color: var(--text-muted); cursor:pointer; font-size:16px; transition:color 0.2s;}
.btn-icon.active { color: var(--accent); }

/* Range Slider */
/* Global Range Slider Styling (Comprehensive Overhaul) */
input[type="range"].form-range,
input[type="range"] {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--panel-border);
  height: 6px;
  border-radius: 4px;
  outline: none;
  margin-top: 10px;
  margin-bottom: 15px;
  cursor: pointer;
}

/* Webkit (Chrome, Edge, Safari) */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none !important;
  appearance: none !important;
  width: 22px !important;
  height: 22px !important;
  border-radius: 50% !important;
  background: var(--accent) !important;
  border: 3px solid #ffffff !important;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4), 0 0 10px rgba(59, 130, 246, 0.4);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  margin-top: -8px; /* Alignment fix */
}

/* Firefox */
input[type="range"]::-moz-range-thumb {
  width: 22px !important;
  height: 22px !important;
  border-radius: 50% !important;
  background: var(--accent) !important;
  border: 3px solid #ffffff !important;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4), 0 0 10px rgba(59, 130, 246, 0.4);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Hover effects */
input[type="range"]::-webkit-slider-thumb:hover,
input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.15) rotate(5deg);
  box-shadow: 0 6px 15px rgba(0,0,0,0.5), 0 0 15px var(--accent-glow);
}

/* Quick Size Pills */
.quick-size-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 5px;
}
.size-pill {
  background: var(--panel-border);
  color: var(--text-main);
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
}
.size-pill:hover {
  background: var(--accent);
}

/* Retouch Split Slider */
.split-image-container {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none; /* Let clicks pass through unless in compare mode */
  overflow: hidden;
  clip-path: polygon(0 0, 50% 0, 50% 100%, 0 100%);
}

.split-image-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  margin: 0;
  padding: 0;
  border: none;
}

/* Split Labels */
.split-label {
  position: absolute;
  top: 20px;
  background: rgba(15, 23, 42, 0.75);
  color: #f8fafc;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  backdrop-filter: blur(4px);
  pointer-events: none;
  z-index: 25;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.split-label-before {
  left: 20px;
}

.split-label-after {
  right: 20px;
}

.split-handle {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  height: 100%;
  width: 4px;
  background: transparent;
  cursor: ew-resize;
  z-index: 10;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Carousel UI */
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(15, 23, 42, 0.7);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 20; pointer-events: auto;
  transition: all 0.2s;
  display: none; /* Only visible in batch mode */
}
.carousel-btn:hover {
  background: var(--accent);
  transform: translateY(-50%) scale(1.1);
}
.carousel-indicator {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.8);
  color: white;
  padding: 6px 16px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 20; pointer-events: none;
  display: none;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  border: 1px solid var(--panel-border);
}

/* Global Loader Modal */
.global-overlay {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  backdrop-filter: none;
  background: rgba(0, 0, 0, 0.25);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.loader-content {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  padding: 40px;
  border-radius: 16px;
  text-align: center;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}
.loader-icon { font-size: 3rem; color: var(--accent); margin-bottom: 20px; }
.progress-bar-wrap {
  width: 100%; height: 8px; background: #0f172a; border-radius: 4px; margin: 20px 0; overflow:hidden;
}
#ai-progress-bar, #loader-progress {
  width: 0%;
  height: 100%;
  background: linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.15) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 255, 255, 0.15) 75%,
    transparent 75%,
    transparent
  ), var(--accent);
  background-size: 40px 40px;
  border-radius: 4px;
  transition: width 0.4s cubic-bezier(0.1, 0.5, 0.1, 1);
  box-shadow: 0 0 15px var(--accent-glow);
  animation: stripesMove 1.5s infinite linear;
}

@keyframes stripesMove {
  from { background-position: 0 0; }
  to { background-position: 40px 0; }
}
#loader-title { 
  font-weight: 600; 
  font-size: 1.1rem; 
  color: #fff; 
  margin-bottom: 8px; 
  word-break: break-all; 
  overflow-wrap: break-word; 
}
#loader-status { 
  color: var(--text-muted); 
  font-size: 0.85rem; 
  word-break: break-all; 
  overflow-wrap: break-word; 
}

.mode-switcher button {
  transition: all 0.2s ease;
  cursor: pointer;
  font-weight: 500;
}
.mode-switcher button.active {
  background: var(--primary) !important;
  color: #fff !important;
}
.split-handle-line {
  position: absolute;
  height: 100%;
  width: 2px;
  background-color: var(--accent);
  box-shadow: 0 0 5px rgba(0,0,0,0.5);
}
.split-handle-button {
  background-color: var(--accent);
  color: white;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
  font-size: 0.8rem;
  z-index: 2;
  transition: transform 0.2s;
}
.split-handle:hover .split-handle-button {
  transform: scale(1.1);
}
.slider-display {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 6px;
  color: var(--text-muted);
}
.slider-display span:last-child {
  color: var(--accent);
  font-weight: 600;
}

/* Workspace */
.workspace {
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: #0b0f19; /* Deep solid background to allow image-level grid to stand out */
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  overflow: hidden;
}

/* Empty State / Onboarding */
.empty-state {
  text-align: center;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: #0f172a;
  background-size: cover;
  background-position: center;
  position: relative;
  overflow: hidden;
}

.no-image-bg-container {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  overflow: hidden;
  background-attachment: fixed;
  background-size: cover;
  background-position: center;
  transition: background-image 0.4s ease-in-out;
}

/* Hide the source images - they only exist for WordPress path resolution */
.no-image-bg-container .bg-layer {
  display: none;
}

.no-image-bg-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.45) 0%, rgba(15, 23, 42, 0.85) 100%);
  z-index: 2;
  pointer-events: none;
}

/* Ensure content stays above the image layer */
#no-image-state > *:not(.no-image-bg-container) {
  position: relative;
  z-index: 10;
}

.drop-zone {
  border: 2px dashed rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
  padding: 60px;
  border-radius: 30px;
  background-color: rgba(15, 15, 15, 0.4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.2);
  transform: scale(1.05);
  box-shadow: 0 0 30px rgba(59, 130, 246, 0.3);
}
.btn-danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}
.empty-icon {
  font-size: 5rem;
  color: var(--accent);
  margin-bottom: 20px;
  filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.5));
}
.empty-state .drop-zone-title {
  font-size: 2rem;
  color: #fff;
  font-weight: 700;
  margin-bottom: 20px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.8);
}
.onboarding-steps {
  display: flex;
  flex-direction: column;
  gap: 15px;
  text-align: left;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}
.step {
  display: flex;
  align-items: center;
  gap: 15px;
  background: rgba(30, 41, 59, 0.8);
  padding: 12px 20px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  font-size: 0.95rem;
  backdrop-filter: blur(5px);
}
.step span {
  background: var(--accent);
  color: #fff;
  width: 24px; height: 24px;
  display: flex; align-items:center; justify-content:center;
  border-radius: 50%;
  font-weight: bold;
  font-size: 0.8rem;
}

/* Image State */
.image-workspace {
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.image-container {
  flex: 1 1 0%;
  max-height: 100%;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  padding: 3%;
  box-sizing: border-box;
}
.image-container img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* Circular crop hack override */
.cropper-view-box,
.cropper-face {
  transition: border-radius 0.3s ease;
}
.circle-crop-active .cropper-view-box,
.circle-crop-active .cropper-face {
  border-radius: 50%;
}

/* ---- Mobile crop fix --------------------------------------------------- */
/* Raise Cropper.js above the sheet-backdrop (z-index:190) so touch events  */
/* reach the crop handles instead of being intercepted by the backdrop.      */
.cropper-container {
  z-index: 210 !important;  /* above sheet-backdrop(190) and panel(200) */
  touch-action: none;       /* required for Cropper.js drag on mobile     */
}
/* Make sure the crop points are large enough to tap on small screens */
@media (max-width: 899px) {
  .cropper-point {
    width: 16px !important;
    height: 16px !important;
    opacity: 1 !important;
  }
  .cropper-point.point-e,
  .cropper-point.point-n,
  .cropper-point.point-w,
  .cropper-point.point-s {
    display: block !important; /* show mid-edge handles on mobile */
  }
}

.live-info-bar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: transparent;
  backdrop-filter: none;
  border: none;
  padding: 6px 24px;
  border-radius: 12px;
  opacity: 0.4;
  transition: opacity 0.3s ease, transform 0.3s ease;
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: center;
  z-index: 100;
  color: var(--text-main);
  white-space: nowrap;
  font-size: 1rem;
  font-weight: 500;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4), 0 0 20px rgba(59, 130, 246, 0.1);
  width: fit-content;
  max-width: 95%;
  user-select: none;
}

.live-info-bar:hover {
  opacity: 1;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}


#btn-close i {
  color: #ef4444 !important; /* Red Trash Icon */
}

.live-info-bar span {
  cursor: help;
  position: relative;
}

/* Custom Pro Tooltip */
.live-info-bar span::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%) translateY(5px);
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--accent);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 10000;
}

.live-info-bar span:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.live-info-bar i {
  color: var(--accent);
  margin-right: 8px;
  font-size: 1.1rem;
}
.live-info-bar button,
.live-info-bar .zoom-action-btn {
  background: rgba(15, 23, 42, 0.35) !important;
  backdrop-filter: blur(10px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.8rem;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  color: var(--text-main);
  opacity: 1 !important;
  margin: 0 4px;
  white-space: nowrap;
}

.live-info-bar .zoom-action-btn {
  width: 34px;
  padding: 0;
}

.live-info-bar button:hover,
.live-info-bar .zoom-action-btn:hover {
  background: rgba(15, 23, 42, 0.85) !important;
  border-color: var(--accent) !important;
  transform: translateY(-1px);
}

.status-msg {
  text-align: center;
  font-size: 0.8rem;
  color: var(--accent);
  margin-top: 10px;
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  0% { opacity: 0.6; }
  100% { opacity: 1; }
}

/* Disabled Panel State */
.disabled-panel {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(100%);
  user-select: none;
  transition: all 0.3s ease;
}

/* =====================================================
   STARTUP LAUNCHER SYSTEM
   ===================================================== */
.startup-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-color);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  transition: opacity 0.5s ease, visibility 0.5s;
}

/* WordPress Shortcode Mode: Instant Hide Launcher (Prevents Flicker) */
.ag-image-tool-app-wrapper.is-shortcode-mode .startup-overlay,
.ag-image-tool-app.is-shortcode-mode .startup-overlay {
    display: none;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.launcher-content {
  width: 90%;
  max-width: 1200px;
  padding: 40px 20px;
  text-align: center;
}

.launcher-branding {
  margin-bottom: 40px;
}

.launcher-branding .launcher-logo-icon {
  font-size: 3.5rem;
  color: var(--accent);
  margin-bottom: 15px;
  filter: drop-shadow(0 0 15px var(--accent-glow));
}

.launcher-branding .launcher-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: #fff;
  margin-top: 10px;
  letter-spacing: -0.5px;
}

.launcher-branding p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 10px;
}

.launcher-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.mode-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 30px 20px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.mode-card .card-icon {
  font-size: 2rem;
  color: var(--accent);
}

.mode-card .mode-title {
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
}

.mode-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* =====================================================
   MOBILE DOCK & SHEET — Default hidden (desktop-first)
   ===================================================== */
.mobile-dock       { display: none; }
.sheet-drag-handle { display: none; }
.sheet-backdrop    { display: none; }
.sheet-close-btn   { display: none; }

/* ---- Floating action bar (top-right of workspace) — desktop + mobile ---- */
.mobile-action-bar {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 50;
  display: flex;
  gap: 8px;
  align-items: center;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.mob-btn {
  font-family: var(--font-family);
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.mob-download {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.45);
}
.mob-download:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 18px rgba(59, 130, 246, 0.6);
  transform: translateY(-1px);
}
.mob-close-img {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 8px 11px;
}
.mob-close-img:hover {
  background: var(--danger);
  color: #fff;
}

/* Background Removal Tools */
.custom-bg-opt {
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.custom-bg-opt.active {
  border: 2px solid var(--accent) !important;
  transform: scale(1.05);
  box-shadow: 0 0 8px var(--accent-glow);
}
.workspace.eraser-mode {
  cursor: crosshair !important;
}
.eraser-brush-cursor {
  position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.1);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5);
  display: none;
  transition: border-color 0.2s, background 0.2s;
}

.eraser-brush-cursor.magic-mode {
  border-color: rgba(239, 68, 68, 0.9);
  background: rgba(239, 68, 68, 0.15);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

/* Neural Filling Animation */
@keyframes neuralPulse {
  0% { filter: brightness(1) saturate(1); }
  50% { filter: brightness(1.2) saturate(1.2) contrast(1.1); }
  100% { filter: brightness(1) saturate(1); }
}

.workspace.processing-ai img {
  animation: neuralPulse 1.5s infinite ease-in-out;
}

/* Shake animation for "load an image first" hint */
@keyframes shakeHint {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-8px); }
  40%     { transform: translateX(1px); }
  60%     { transform: translateX(-5px); }
  80%     { transform: translateX(1px); }
}
.shake-hint { animation: shakeHint 0.45s ease; }

/* Dock badge for batch image count */
.dock-badge {
  position: absolute;
  top: 5px; right: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
  line-height: 1;
  box-shadow: 0 0 6px var(--accent-glow);
}

/* =====================================================
   MOBILE RESPONSIVE — CANVA / SNAPSEED STYLE
   Breakpoint: max-width 768px
   All desktop styles remain COMPLETELY untouched.
   ===================================================== */
@media (max-width: 768px) {

  #batch-toggle-container {
    flex-direction: column !important;
    gap: 8px !important;
  }

  /* --- Root & Body (Mobile) --------------------------------- */
  .ag-image-tool-app {
    height: 95dvh;
    overflow: hidden; /* App feel, no scroll trap for WP */
  }
  
  .ag-image-tool-app.is-shortcode-mode {
    height: 90dvh !important; /* Take up more of the screen on mobile */
    min-height: 500px;
    max-height: 100dvh;
    margin: 0 !important;
    border-radius: 0;
    border: none;
    box-shadow: none;
    overflow: hidden !important; /* Contain the tools for better focus */
    touch-action: pan-y; /* Explicitly allow vertical page scrolling */
    contain: content; /* Isolation */
  }

  /* --- Header: compact on mobile ------------------ */
  .app-header {
    display: none !important;
  }
  .logo { font-size: 1.05rem; }
  .header-status { font-size: 0.7rem; gap: 3px; }

  /* --- App container: workspace + panel stack vertically ---------- */
  /* padding-bottom reserves 60px for the fixed dock nav bar        */
  .app-container {
    flex-direction: column;
    height: 100%;

    padding-bottom: 60px;
    position: relative;
    overflow: hidden;
  }

  /* --- Hide the drag resizer ---------------------- */
  .resizer { display: none; }

  /* --- Workspace: full-screen canvas -------------- */
  /* order:1 ensures workspace always renders ABOVE the controls-panel (order:2) */
  .workspace {
    flex: 1;
    width: 100%;
    min-height: 0;
    position: relative;
    overflow: hidden;
    order: 1;
  }

  /* Live info bar: floats at bottom of workspace (workspace is above the dock padding) */
  .live-info-bar {
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 14px;
    gap: 12px;
    font-size: 0.75rem;
    border-radius: 20px;
    white-space: nowrap;
    max-width: calc(100vw - 20px);
    background: transparent;
    backdrop-filter: none;
    border: none;
    opacity: 1;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .live-info-bar::-webkit-scrollbar { display: none; }

  .live-info-bar .info-value,
  .live-info-bar #info-dimensions,
  .live-info-bar #info-size {
    display: none !important; /* Hide file info entirely on mobile */
  }

  .live-info-bar .zoom-slider-container {
    display: none; /* Hide the slider on mobile */
  }

  .live-info-bar .zoom-group {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    backdrop-filter: none !important;
    gap: 4px;
  }
  .live-info-bar #btn-reset,
  .live-info-bar #btn-close {
    padding: 6px 10px;
    height: 34px;
    width: auto;
    min-width: 0;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .live-info-bar #btn-reset i,
  .live-info-bar #btn-close i {
    margin-right: 4px;
    font-size: 0.9rem;
  }

  .live-info-bar i {
    margin-right: 4px;
    font-size: 0.9rem;
  }

  /* Carousel buttons: bigger touch targets */
  .carousel-btn {
    width: 52px;
    height: 52px;
    font-size: 1rem;
  }
  /* Move them slightly inward on small screens */
  #carousel-prev { left: 8px !important; }
  #carousel-next { right: 8px !important; }

  /* Carousel indicator above dock */
  .carousel-indicator { top: 12px; }

  /* --- Drop Zone (empty state) ------------------- */
  .drop-zone {
    padding: 24px 20px;
    border-radius: 0;
    border: none;
    background-color: rgba(10, 10, 10, 0.35);
  }
  .empty-state .drop-zone-title {
    font-size: 1.4rem;
    margin-bottom: 14px;
  }
  .empty-icon {
    font-size: 3.2rem;
    margin-bottom: 14px;
  }
  .onboarding-steps { max-width: 280px; }
  .step {
    padding: 9px 14px;
    font-size: 0.82rem;
  }

  /* --- Tooltips: disable on touch (no hover) ----- */
  .tooltip-icon::after { display: none !important; }

  /* --- Size pills: horizontal scroll row ---------- */
  .quick-size-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    gap: 8px;
  }
  .quick-size-pills::-webkit-scrollbar { display: none; }
  .size-pill {
    flex-shrink: 0;
    font-size: 0.72rem;
    padding: 6px 12px;
  }

  /* Touch-friendly range sliders (Inherit global styles) */
  input[type="range"]::-webkit-slider-thumb {
    width: 26px !important;
    height: 26px !important;
    margin-top: -10px !important;
  }
  input[type="range"]::-moz-range-thumb {
    width: 26px !important;
    height: 26px !important;
  }

  /* Floating annotation buttons: easier to tap */
  #floating-delete-btn,
  #floating-rotate-btn {
    width: 40px !important;
    height: 40px !important;
  }

  /* Split compare labels: smaller on mobile */
  .split-label { font-size: 0.72rem; padding: 4px 10px; }

  /* ------------------------------------------------
     BOTTOM SHEET — controls-panel transforms
     ------------------------------------------------ */

  /* Sheet backdrop: invisible tap-target only — no dim/blur so image     */
  /* colours are judged accurately while adjusting brightness/contrast.   */
  .sheet-backdrop {
    display: none !important;
    position: absolute;
    top: 0; left: 0; right: 0;
    bottom: 60px;
    background: transparent;
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  .sheet-backdrop.visible {
    opacity: 1;                 /* still invisible visually */
    pointer-events: none;
  }

  /* Sheet drag handle – pill at the top of the sheet */
  .sheet-drag-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0 6px;
    position: sticky;
    top: 0;
    background: var(--panel-bg);
    z-index: 5;
    flex-shrink: 0;
    touch-action: none;
    cursor: grab;
    user-select: none;
    -webkit-user-drag: none;
  }
  .sheet-drag-handle:active {
    cursor: grabbing;
  }

  /* ---- Panel close / minimize button ---- */
  .sheet-close-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.7);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background 0.2s, color 0.2s;
  }
  .sheet-close-btn:active {
    background: rgba(255, 255, 255, 0.28);
  }
  .handle-pill {
    width: 36px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    transition: background 0.2s, width 0.2s;
  }
  .sheet-drag-handle:active .handle-pill {
    background: var(--accent);
    width: 48px;
  }

  /* The in-flow bottom sheet — sits BELOW workspace in the flex column  */
  /* order:2 keeps it below the workspace (order:1) regardless of HTML order */
  .controls-panel {
    position: relative;
    width: 100%;
    height: 0;
    flex-shrink: 0;
    order: 2;                   /* always renders below workspace */
    min-width: unset;
    max-width: 100%;
    border-right: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px 20px 0 0;
    padding: 0;
    overflow: hidden;
    z-index: 9999 !important; /* Always on top */
    transition: height 0.42s cubic-bezier(0.32, 0.72, 0, 1);
    background: var(--panel-bg);
    box-shadow: 0 -12px 50px rgba(0, 0, 0, 0.65);
    display: flex;
    flex-direction: column;
  }

  /* Sheet fully expanded — 46vh keeps image fully visible above */
  .controls-panel.sheet-open {
    height: 46vh;
  }

  /* Inner scroll container */
  .editor-controls {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 4px 14px 48px; /* 48px bottom padding so last item scrolls clear */
    flex: 1;
    min-height: 0;
  }

  /* Control groups within sheet */
  .control-group {
    margin-bottom: 10px;
    scroll-margin-top: 8px;   /* offset for sticky handle when using scrollIntoView */
  }

  /* ------------------------------------------------
     MOBILE DOCK — Canva-style 5-tab icon bar
     ------------------------------------------------ */
  .mobile-dock {
    display: flex !important;
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    /* Respect iPhone notch / gesture bar */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    /* Deep glass effect */
    background: rgba(10, 16, 30, 0.95);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    z-index: 1100;
    align-items: stretch;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.55);
  }

  .dock-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-family);
    padding: 6px 4px;
    position: relative;
    /* Spring bounce on state change */
    transition: color 0.2s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    /* WCAG 2.5.5 – minimum 44px touch target */
    min-width: 44px;
    min-height: 44px;
    user-select: none;
  }

  .dock-tab i {
    font-size: 1.15rem;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
                             /* Springy bounce easing */
  }

  .dock-tab span {
    font-size: 0.52rem;
    font-weight: 500;
    letter-spacing: 0.2px;
    line-height: 1;
  }

  /* Press feedback */
  .dock-tab:active { transform: scale(0.88); }

  /* Active state – accent color, icon springs up, bar indicator at top */
  .dock-tab.active { color: var(--accent); }

  .dock-tab.active i {
    transform: scale(1.2) translateY(-2px);
  }

  /* Glowing top-bar indicator (like Canva) */
  .dock-tab.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 3px;
    background: var(--accent);
    border-radius: 0 0 4px 4px;
    box-shadow: 0 0 10px var(--accent-glow);
  }

  /* Action buttons in the dock (Direct triggers) */
  .dock-tab.action-btn {
    color: var(--text-main);
  }
  
  /* When a specific tool is active (Manual Eraser, Filler, etc) */
  .dock-tab.tool-active {
    background: rgba(59, 130, 246, 0.2) !important;
    color: #60a5fa !important;
  }
  .dock-tab.tool-active i {
    color: #60a5fa !important;
  }
  .dock-tab.tool-active::before {
    background: #60a5fa !important;
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.5) !important;
  }


  /* When a panel is open: hide the action bar and info-bar so they don't  */
  /* clutter the image while the user is editing sliders / crop / resize.  */
  .ag-image-tool-app.sheet-is-open .mobile-action-bar {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
  }
  .ag-image-tool-app.sheet-is-open .live-info-bar {
    opacity: 0;
    pointer-events: none;
  }

  #magic-notice {
    width: calc(100vw - 32px);
    max-width: 400px;
    padding: 12px 16px;
    padding-right: 40px;
    font-size: 0.8rem;
    top: 60px;
    border-radius: 12px;
    white-space: normal !important;
  }
  #magic-notice-close {
    right: 10px;
    font-size: 1rem;
  }

  /* --- AI Processing Overlay Responsive Fix --- */
  .premium-overlay {
    overflow: hidden !important;
    justify-content: center !important;
    padding: 20px !important;
  }
  .premium-ai-content {
    padding: 0;
    transform: translateY(-10px); /* Slight nudge up */
  }
  .ai-loader-hub {
    width: 220px;
    height: 220px;
    margin-bottom: 10px !important;
    transform: scale(0.65);
  }
  .premium-progress-wrap {
    width: 240px !important;
    max-width: 80vw !important;
    margin-bottom: 10px !important;
  }
  #ai-processing-msg, #bg-processing-msg {
    font-size: 0.85rem !important;
    margin-bottom: 8px !important;
    padding: 0 15px;
    max-width: 90vw;
    line-height: 1.4;
  }
  .premium-progress-hint {
    font-size: 0.65rem !important;
    max-width: 85vw !important;
    margin: 0 auto !important;
    line-height: 1.3;
    opacity: 0.8;
  }
  .brain-core-unit i {
    font-size: 80px;
  }
  .ai-text-overlay {
    font-size: 24px;
  }

} /* end @media (max-width: 899px) */


/* Eraser Mode Enhancements */
.eraser-mode #image-info-bar {
  display: none !important;
}
.eraser-mode #preview-image {
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
}
.eraser-mode #image-container-wrapper {
  overflow: hidden;
}


/* Passport Studio Styles */
#passport-studio-wrapper .btn-xs {
  transition: all 0.2s ease;
}
#passport-studio-wrapper .btn-xs.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}
#passport-studio-wrapper .btn-xs.btn-action {
  background: rgba(255,255,255,0.1);
  border-color: var(--panel-border);
}

.passport-grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: none;
    border: 2px dashed #a78bfa;
    box-sizing: border-box;
    z-index: 55;
}

#passport-studio-wrapper input:focus, 
#passport-studio-wrapper select:focus {
    outline: none;
    border-color: #a78bfa;
    box-shadow: 0 0 5px rgba(167, 139, 250, 0.4);
}

/* Passport Head Alignment Guide Overlay */
.passport-head-guide {
    position: absolute;
    border: 2px dashed rgba(167, 139, 250, 0.6);
    border-radius: 50% / 45%;
    pointer-events: none;
    display: none;
    z-index: 100;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.3);
}
.passport-head-guide::after {
    content: 'ALIGN FACE';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    color: #a78bfa;
    white-space: nowrap;
    font-weight: bold;
}
/* --- Startup Launcher Overhaul: Global Phase --- */
.startup-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Fix: Start from top to allow scrolling */
    overflow-y: auto;        /* Fix: Global Scrollability */
    padding: 60px 20px;
    -webkit-overflow-scrolling: touch;
}

.launcher-content {
    width: 100%;
    max-width: 1100px;
    margin: auto; /* Centering while allowing flex-start scroll */
    text-align: center;
    position: relative;
    z-index: 5;
}

/* --- Premium Hub View (Desktop 769px+) --- */
@media (min-width: 769px) {
    /* Safe-Wiring: Hide Sidebar specifically while workspace is inactive in specialized modes */
    .ag-image-tool-app:not(.is-workspace-active):not([data-app-mode="all"]) .controls-panel,
    .ag-image-tool-app:not(.is-workspace-active):not([data-app-mode="all"]) #app-resizer {
        display: none !important;
    }

        /* Hub Phase 1: Dual-Panel Dashboard (Compressor & Resizer Reversed for Consistency) */
        .ag-image-tool-app[data-app-mode="compressor"]:not(.is-workspace-active) #hub-phase-container,
        .ag-image-tool-app[data-app-mode="resizer"]:not(.is-workspace-active) #hub-phase-container {
            display: flex;
            flex-direction: row-reverse; /* Swap Tools to Left, Upload to Right */
            align-items: stretch;
            justify-content: center;
            gap: 60px;
            width: 100%;
            max-width: 1100px;
            margin: 0 auto 30px auto;
            animation: fadeIn 0.8s ease;
        }

        /* AI Mode remains standard Row layout */
        .ag-image-tool-app[data-app-mode="ai-bg"]:not(.is-workspace-active) #hub-phase-container {
            display: flex;
            flex-direction: row;
            align-items: stretch;
            justify-content: center;
            gap: 60px;
            width: 100%;
            max-width: 1100px;
            margin: 0 auto 30px auto;
            animation: fadeIn 0.8s ease;
        }

        .ag-image-tool-app[data-app-mode="compressor"]:not(.is-workspace-active) #hub-input-methods-wrap,
        .ag-image-tool-app[data-app-mode="resizer"]:not(.is-workspace-active) #hub-input-methods-wrap {
            flex: 1;
            max-width: 380px !important;
            margin: 0 !important;
            display: flex;
            flex-direction: column;
            justify-content: center;
            background: rgba(15, 23, 42, 0.4);
            backdrop-filter: blur(20px);
            padding: 40px;
            border-radius: 20px;
            border: 1px solid rgba(59, 130, 246, 0.2);
            box-shadow: 0 30px 60px rgba(0,0,0,0.5);
            max-width: 50% !important;
        }

        .ag-image-tool-app[data-app-mode="compressor"]:not(.is-workspace-active) #hub-quick-config-wrap,
        .ag-image-tool-app[data-app-mode="resizer"]:not(.is-workspace-active) #hub-resizer-config-wrap {
            display: block !important;
            flex: 1;
            max-width: 440px !important;
        }

        /* AI Mode Minimalist Refinement: Hide steps and Branding text if requested */
        .ag-image-tool-app[data-app-mode="ai-bg"] .launcher-branding,
        .ag-image-tool-app[data-app-mode="ai-bg"] .onboarding-steps,
        .ag-image-tool-app[data-app-mode="ai-bg"] .empty-icon,
        .ag-image-tool-app[data-app-mode="ai-bg"] .drop-zone-title {
            display: none !important;
        }

        .ag-image-tool-app[data-app-mode="ai-bg"] #hub-phase-container {
            margin-top: 60px;
        }
        
        .ag-image-tool-app[data-app-mode="ai-bg"]:not(.is-workspace-active) #hub-ai-demo-wrap {
            flex: 1;
            display: flex !important;
            align-items: center;
            justify-content: center;
            max-width: unset !important; /* Allow 50% split */
        }

        .ag-image-tool-app[data-app-mode="ai-bg"]:not(.is-workspace-active) #hub-input-methods-wrap {
            flex: 1;
            display: flex !important;
            flex-direction: column;
            justify-content: center;
            align-items: center; /* Center the constrained content */
            margin: 0 !important;
            background: transparent !important;
            border: none !important;
            box-shadow: none !important;
            backdrop-filter: none !important;
        }

        /* Constrain the inner content width for a "normal" look */
        .ag-image-tool-app[data-app-mode="ai-bg"]:not(.is-workspace-active) #hub-input-methods-wrap > * {
            width: 100%;
            max-width: 380px; /* Professional, focused width */
        }

        .ag-image-tool-app[data-app-mode="ai-bg"]:not(.is-workspace-active) #hub-ai-model-wrap {
            display: block !important;
            width: 100%;
            max-width: 400px;
        }

        /* Instructions always flow below in dual-panel mode */
        .ag-image-tool-app[data-app-mode="compressor"]:not(.is-workspace-active) .onboarding-steps,
        .ag-image-tool-app[data-app-mode="resizer"]:not(.is-workspace-active) .onboarding-steps {
            width: 100%;
            max-width: 900px !important;
            margin-top: 20px;
        }

    /* Fallback for Phase 2: Collapse everything back to sidebar-ready state */
    .ag-image-tool-app.is-workspace-active #hub-phase-container {
        display: block !important;
        width: auto;
        margin: 0;
    }
    .ag-image-tool-app.is-workspace-active #hub-input-methods-wrap {
        max-width: 320px !important;
    }
    .ag-image-tool-app.is-workspace-active #hub-quick-config-wrap,
    .ag-image-tool-app.is-workspace-active #hub-resizer-config-wrap {
        display: none !important;
    }

    /* Hub Quick Settings - Premium Styling */
    .hub-quick-settings {
        box-shadow: 0 15px 35px rgba(0,0,0,0.4), inset 0 0 20px rgba(255,255,255,0.02);
        animation: slideUp 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    }
    
    .hub-quick-settings label {
        text-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
    }

    .hub-quick-settings .form-range::-webkit-slider-runnable-track {
        background: rgba(255, 255, 255, 0.1);
        height: 6px;
        border-radius: 3px;
    }
    
    .hub-quick-settings .form-range::-webkit-slider-thumb {
        -webkit-appearance: none !important;
        appearance: none !important;
        width: 22px !important;
        height: 22px !important;
        border-radius: 50% !important;
        background: var(--accent) !important;
        border: 2px solid #ffffff !important;
        box-shadow: 0 0 15px var(--accent-glow) !important;
        margin-top: -9px !important;
        cursor: pointer;
    }

    .hub-quick-settings .form-range::-moz-range-thumb {
        width: 22px !important;
        height: 22px !important;
        border-radius: 50% !important;
        background: var(--accent) !important;
        border: 2px solid #ffffff !important;
        box-shadow: 0 0 15px var(--accent-glow) !important;
        cursor: pointer;
    }

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

    .startup-overlay {
        background-color: #0f172a !important;
        background-image: none !important;
        backdrop-filter: none;
    }

    .launcher-content {
        max-width: 1100px;
        perspective: 1000px;
    }

    .launcher-branding {
        margin-bottom: 60px;
    }

    .launcher-branding .launcher-title {
        font-size: 3.5rem;
        background: linear-gradient(to right, #fff, var(--accent));
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
        filter: drop-shadow(0 0 30px rgba(59, 130, 246, 0.3));
    }

    .launcher-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 24px;
        padding: 20px;
    }

    .mode-card {
        background: var(--glass-bg);
        border: 1px solid var(--glass-border);
        backdrop-filter: blur(10px);
        padding: 40px 20px;
        position: relative;
        overflow: hidden;
        box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    }

    .mode-card::before {
        content: '';
        position: absolute;
        top: 0; left: 0; right: 0; height: 1px;
        background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    }

    .mode-card .card-icon {
        font-size: 2.5rem;
        margin-bottom: 15px;
        transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }

    .mode-card:hover .card-icon {
        transform: scale(1.2) translateY(-5px);
        filter: drop-shadow(0 0 15px var(--accent-glow));
    }

    .mode-card .mode-title {
        font-size: 1.1rem;
        letter-spacing: 0.5px;
    }

    .mode-card p {
        font-size: 0.8rem;
        opacity: 0.8;
    }

    /* Cinematic Hover State */
    .mode-card:hover {
        background: var(--glass-accent);
        border-color: var(--accent);
        transform: translateY(-12px) scale(1.02);
        box-shadow: 0 25px 50px rgba(0,0,0,0.5), 0 0 20px rgba(59, 130, 246, 0.2);
    }

    /* All-in-One Premium Highlight */
    .mode-card.card-all {
        border: 2px solid #cbd5e1 !important; /* Elegant Silver/Slate Light */
        box-shadow: 0 0 20px rgba(203, 213, 225, 0.2);
    }
    
    .mode-card.card-all:hover {
        border-color: #f1f5f9 !important; /* Bright Silver on hover */
        box-shadow: 0 0 30px rgba(255, 255, 255, 0.2);
    }
}

/* Cleanup existing utility */
.launcher-footer {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 20px;
    opacity: 0.6;
}

/* Hide UI elements based on modes */
.ag-image-tool-app.mode-compact aside,
.ag-image-tool-app.mode-compact .app-header div:last-child button {
    display: flex;
}

/* Specific Tool Hiding classes */
.hidden-by-mode {
    display: none !important;
}

/* Professional UI Field Styling */
.pro-field {
    background-color: #000000 !important;
    color: #ffffff !important;
    border: 1px solid var(--panel-border) !important;
    border-radius: 4px;
    padding: 6px;
    font-size: 0.8rem;
}

.pro-field::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Resizer Locked Dimension Effect - Stronger Specificity */
.pro-field.locked-dim, .locked-dim {
    background-color: #1a1a1a !important;
    color: #cbd5e1 !important; /* Lighter gray for better visibility */
    opacity: 0.85 !important; /* Increased opacity */
    filter: grayscale(0.5) !important;
    font-style: italic;
    cursor: default;
    border-color: #334155 !important;
}

/* SMART-RESIZER ASSISTANT BANNER */
.smart-assistant {
    display: none;
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 95%;
    max-width: 850px;
    animation: slideDownFade 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.assistant-content {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px) saturate(160%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 12px;
    padding: 8px 24px;
    display: flex;
    justify-content: center;
    gap: 50px;
    align-items: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4), 0 0 20px rgba(59, 130, 246, 0.1);
}

.assistant-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.assistant-info i {
    font-size: 1.2rem;
    color: var(--accent);
    filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.5));
}

.assistant-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.3px;
}

.assistant-msg {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.assistant-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-close-assistant {
    color: #fff;
    opacity: 0.5;
    padding: 4px;
}

.btn-close-assistant:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* AI VISUAL DEMO CARD (Two-Image Layered System) */
.ai-visual-demo {
    width: 100%;
}

.demo-image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1100 / 1200;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    margin-bottom: 20px;
    border: 1px solid rgba(255,255,255,0.1);
}

.demo-bg-checker {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: 
        linear-gradient(45deg, #2a2a2a 25%, transparent 25%), 
        linear-gradient(-45deg, #2a2a2a 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #2a2a2a 75%), 
        linear-gradient(-45deg, transparent 75%, #2a2a2a 75%) !important;
    background-size: 20px 20px !important;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px !important;
    background-color: #1a1a1a !important;
    opacity: 0.8;
}

.demo-img-stable {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 20; pointer-events: none;
    pointer-events: none;
}

.demo-img-reveal-wrap {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 100%;
    overflow: hidden;
    animation: scanRevealWidth 4s ease-in-out infinite;
    border-right: 2px solid var(--accent);
    box-shadow: 10px 0 30px rgba(59, 130, 246, 0.4);
    z-index: 10;
}

.demo-img-full {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* =========================================================================
   SIDEBAR MINIMIZERS (COLLAPSIBLE TOOLS)
   ========================================================================= */

.minimizer-wrap {
    margin-bottom: 30px;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    overflow: visible;
    background: rgba(15, 23, 42, 0.4);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.minimizer-header {
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.04);
    user-select: none;
    transition: background 0.2s;
}

.minimizer-header:hover {
    background: rgba(255, 255, 255, 0.08);
}

.minimizer-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    pointer-events: none;
}

.minimizer-icon {
    font-size: 0.75rem;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: var(--accent);
    pointer-events: none;
}

.minimizer-content {
    max-height: 2000px;
    opacity: 1;
    transition: all 0.35s ease-in-out;
    padding: 15px;
    border-top: 1px solid rgba(255,255,255,0.03);
    margin-top: 5px; /* Added gap between drawer label/header and content as requested */
}

/* Collapsed State */
.minimizer-wrap.is-collapsed {
    background: transparent;
    border-color: rgba(255,255,255,0.05);
}

.minimizer-wrap.is-collapsed .minimizer-content {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-top: none;
    pointer-events: none;
    margin-top: 0;
}

.minimizer-wrap.is-collapsed .minimizer-icon {
    transform: rotate(-90deg);
}

/* Hidden Header (For All-in-One and Passport modes) */
.minimizer-header.hidden-header {
    display: none !important;
}

.minimizer-wrap.no-border {
    border: none !important;
    background: transparent !important;
    margin-bottom: 0px !important;
}

.minimizer-wrap.no-border .minimizer-content {
    padding: 0 !important;
    margin-top: 0 !important;
    border-top: none !important;
}

/* Sidebar Footer (Global Download Area) */
.sidebar-footer {
    flex-shrink: 0;
    padding: 15px 20px;
    background: transparent;
    border-top: none;
    z-index: 50;
}

@media (min-width: 900px) {
    .sidebar-footer {
        margin: 0 -20px -20px -20px; /* Offset the parent padding */
        position: sticky;
        bottom: -20px; /* Stick to bottom of container */
    }
}

@media (max-width: 899px) {
    .sidebar-footer {
        padding: 12px 16px;
        background: transparent;
        border-top: none;
        box-shadow: none;
        margin: 0;
        position: relative;
        bottom: 0;
    }
}

#download-status {
    text-align: center;
    color: var(--accent);
    font-size: 0.75rem;
    margin-top: 8px;
    font-weight: 600;
}

@keyframes scanRevealWidth {
    0% { width: 100%; }
    50% { width: 0%; }
    100% { width: 100%; }
}

.demo-info {
    text-align: left;
}

.demo-info h3 {
    font-size: 1.25rem;
    margin-bottom: 5px;
    background: linear-gradient(to right, #fff, var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.demo-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- HUB PHASE CARDS --- */
.hub-card {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 30px;
    position: relative;
    overflow: hidden;
    width: 100%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.eraser-visual-demo {
    min-height: 350px; /* Ensure visibility */
    display: flex;
    flex-direction: column;
}

.eraser-demo-container {
    position: relative;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    margin-bottom: 5px;
    border: 1px solid rgba(255,255,255,0.1);
}

.eraser-step-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: block;
    transform: translateX(100%); 
    transition: transform 1.2s cubic-bezier(0.4, 0, 0.2, 1); /* Slower, smoother slide */
}

.eraser-step-slide[data-step="1"] {
    position: relative;
    transform: translateX(0);
}

.eraser-step-slide img {
    width: 100%;
    height: auto;
    display: block;
}

.eraser-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(transparent, rgba(0,0,0,0.95));
    color: #fff;
    padding: 25px 20px;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.5px;
    z-index: 30;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Sliding Carousel Animation (No-Gap Version) */
.eraser-step-slide[data-step="1"] { animation: eraserSlideEffect 6s infinite 0s; }
.eraser-step-slide[data-step="2"] { animation: eraserSlideEffect 6s infinite 2s; }
.eraser-step-slide[data-step="3"] { animation: eraserSlideEffect 6s infinite 4s; }

@keyframes eraserSlideEffect {
    0% { transform: translateX(100%); z-index: 20; }
    12%, 35% { transform: translateX(0); z-index: 20; }
    47%, 100% { transform: translateX(-100%); z-index: 10; }
}

.eraser-progress-dots {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 50;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(12px);
    padding: 8px 15px;
    border-radius: 40px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.dot {
    width: 10px;
    height: 10px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    transition: all 0.3s;
}

/* Dots Sync Animation */
.dot:nth-child(1) { animation: dotPulse 6s infinite 0s; }
.dot:nth-child(2) { animation: dotPulse 6s infinite 2s; }
.dot:nth-child(3) { animation: dotPulse 6s infinite 4s; }

@keyframes dotPulse {
    0%, 30% { background: var(--accent); transform: scale(1.3); box-shadow: 0 0 15px var(--accent-glow); }
    33.33%, 100% { background: rgba(255,255,255,0.2); transform: scale(1); box-shadow: none; }
}

#hub-phase-container {
    display: flex;
    flex-direction: row;
    align-items: stretch; /* Cards will match height */
    justify-content: center;
    gap: 40px;
    width: 100%;
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

/* Responsiveness for Hub Split Phase */
@media (max-width: 900px) {
    .ag-image-tool-app[data-app-mode="ai-bg"]:not(.is-workspace-active) #hub-phase-container,
    .ag-image-tool-app[data-app-mode="eraser-magic"]:not(.is-workspace-active) #hub-phase-container {
        flex-direction: row !important; /* Forces 50/50 split as requested */
        align-items: stretch;
        gap: 6px; /* Tighter gap */
        padding: 0 5px; /* Minimal side margins */
    }
    
    .hub-card {
        padding: 8px !important; /* Extremely tight padding for mobile */
        border-radius: 10px;
    }

    /* Scaling down demo content */
    .eraser-caption {
        font-size: 0.7rem !important;
        padding: 10px 5px !important;
    }
    
    .eraser-progress-dots {
        top: 10px;
        right: 10px;
        padding: 4px 10px;
        transform: scale(0.8);
    }

    #hub-eraser-title-wrap div, #hub-ai-model-wrap div {
        font-size: 1rem !important; /* Smaller titles */
        margin-bottom: 10px !important;
    }

    /* Scaling down input controls */
    .input-methods .btn-primary {
        font-size: 0.85rem !important;
        padding: 8px !important;
    }
    
    .hub-or-divider {
        font-size: 0.65rem;
        margin: 5px 0;
    }
    
    .url-input-wrapper input {
        font-size: 0.75rem !important;
        padding: 6px 12px !important;
    }

    .onboarding-steps {
        display: none !important; /* Hide instructions on mobile to save space */
    }

    .hide-mobile {
        display: none !important;
    }
}
/* Transparency Grid (Box-box effect) for identification of artifacts */
.transparency-grid {
    background-color: #1a1a1a;
    background-image: conic-gradient(#2a2a2a 25%, transparent 0 50%, #2a2a2a 0 75%, transparent 0);
    background-size: 20px 20px;
}

/* Ensure Cropper background matches our grid */
.cropper-bg {
    background-color: #1a1a1a;
    background-image: conic-gradient(#2a2a2a 25%, transparent 0 50%, #2a2a2a 0 75%, transparent 0);
    background-size: 20px 20px;
    opacity: 1;
}

/* AI MAGIC ERASER STYLES */
.eraser-magic-mode .workspace {
    cursor: none !important;
}

.eraser-brush-cursor {
    position: fixed;
    pointer-events: none;
    border: 2px solid #fff;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    z-index: 10000;
    display: none;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
    transform: translate(-50%, -50%);
}

.eraser-brush-cursor.magic-mode {
    border-color: #fff !important;
    background: rgba(255, 255, 255, 0.1) !important;
}

/* Button State Enhancements */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed !important;
    filter: grayscale(0.5);
    pointer-events: auto !important; /* Ensure tooltips work */
}

/* Hide Drag & Drop in AI Modes */
.ag-image-tool-app[data-app-mode="ai-bg"] .empty-icon,
.ag-image-tool-app[data-app-mode="ai-bg"] .drop-zone-title,
.ag-image-tool-app[data-app-mode="eraser-magic"] .empty-icon,
.ag-image-tool-app[data-app-mode="eraser-magic"] .drop-zone-title {
    display: none !important;
}

.btn-stop-active {
    background: var(--danger) !important;
    border-color: #b91c1c !important;
    color: white !important;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

.btn-stop-active:hover {
    background: #dc2626 !important;
}

#magic-canvas {
    opacity: 0.45;
    transition: opacity 0.3s ease;
}

/* Magic Eraser Instruction Notice */
#magic-notice {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(15px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 16px 28px;
    padding-right: 48px;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 500;
    display: none;
    z-index: 200;
    box-shadow: 0 15px 35px rgba(0,0,0,0.5);
    animation: slideDownNotice 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-align: center;
    line-height: 1.5;
    pointer-events: auto;
    white-space: nowrap;
}

#magic-notice-close {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s;
    font-size: 1.1rem;
    color: #fff;
}

#magic-notice-close:hover {
    opacity: 1;
    transform: translateY(-50%) scale(1.15);
}

@keyframes slideDownNotice {
    from { opacity: 0; transform: translate(-50%, -30px) scale(0.9); }
    to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.notice-highlight {
    color: #60a5fa;
    font-weight: 700;
}

/* --- Navigation Cursors --- */
.panning-mode {
    cursor: grab !important;
}

.panning-mode #magic-canvas, 
.panning-mode .image-container {
    cursor: grab !important;
}

.panning-active,
.panning-active * {
    cursor: grabbing !important;
}

/* --- Premium Glass AI Processing Overlay --- */


#ai-processing-msg {
  color: #fff;
  font-weight: 700;
  font-size: 1.25rem;
  margin-bottom: 20px;
  text-shadow: 0 4px 15px rgba(0,0,0,0.5);
  letter-spacing: 0.5px;
}



#ai-progress-bar {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #93c5fd, #3b82f6);
  background-size: 200% 100%;
  animation: shimmer 2s infinite linear;
  border-radius: 20px;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.ai-progress-hint {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.85rem;
  max-width: 80%;
  text-align: center;
  margin-top: 15px;
  line-height: 1.5;
}

/* --- Neural Animations --- */
@keyframes neural-pulse {
  0% { box-shadow: 0 0 10px rgba(59, 130, 246, 0.4); opacity: 0.9; }
  50% { box-shadow: 0 0 30px rgba(59, 130, 246, 0.9); opacity: 1; }
  100% { box-shadow: 0 0 10px rgba(59, 130, 246, 0.4); opacity: 0.9; }
}

.neural-breathing {
    animation: neural-pulse 1.5s infinite ease-in-out !important;
}

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

/* --- Premium Dedicated BG Removal Overlay --- */




@keyframes aura-pulse {
  0% { transform: scale(0.8) rotate(0deg); opacity: 0.3; }
  100% { transform: scale(1.2) rotate(180deg); opacity: 0.6; }
}

.bg-ai-content {
  position: relative;
  z-index: 2;
  text-align: center;
  width: 80%;
  max-width: 400px;
}

#bg-processing-msg {
  color: #fff;
  font-weight: 700;
  font-size: 1.4rem;
  margin-bottom: 25px;
  text-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
  letter-spacing: -0.02em;
}

.bg-progress-wrap {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

#bg-progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa, #3b82f6);
  background-size: 200% 100%;
  animation: bg-shimmer 2s infinite linear;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.8);
  border-radius: 100px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes bg-shimmer {
  0% { background-position: 100% 0%; }
  100% { background-position: -100% 0%; }
}

.bg-progress-hint {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
  line-height: 1.4;
}




/* =========================================================================
   STABLE PREMIUM AI OVERLAY & LOADER (FINAL VERSION)
   ========================================================================= */

.premium-overlay {
  display: none;
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(15, 23, 42, 0.35) !important; /* Dark Midnight Slate with slight blue hint */
  backdrop-filter: blur(12px) saturate(160%) !important;
  z-index: 2000 !important;
  border-radius: 12px;
  overflow: hidden !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none; /* Block-level safety: don't block the UI when hidden */
}

.premium-overlay[style*="display: flex"],
.premium-overlay[style*="display:flex"] {
  pointer-events: all !important;
}

.premium-ai-aura {
  position: absolute;
  top: 50%; left: 50%;
  width: 600px; height: 600px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.12), transparent 70%);
  animation: auraRotateFinal 15s infinite linear;
  pointer-events: none;
  z-index: 1;
}

@keyframes auraRotateFinal {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.premium-ai-content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  padding: 20px;
}

.ai-loader-hub {
  display: grid;
  place-items: center;
  width: 350px;
  height: 350px;
  margin-bottom: 25px;
  position: relative;
}

.brain-core-unit {
  grid-area: 1/1;
  display: grid;
  place-items: center;
  z-index: 20; pointer-events: none;
  /* VISUAL CORRECTION: Nudging the entire unit right to center the brain's split on the wires */
  transform: translateX(1px); 
}

.brain-core-unit i {
  grid-area: 1/1;
  font-size: 110px;
  color: transparent;
  -webkit-text-stroke: 2px #fff;
  filter: drop-shadow(0 0 20px var(--accent));
  animation: brainBreathCoreFinal 3s infinite ease-in-out;
}

.ai-text-overlay {
  grid-area: 1/1;
  z-index: 30;
  color: #fff;
  font-size: 34px;
  font-weight: 900;
  text-shadow: 0 0 15px rgba(0,0,0,1);
  letter-spacing: 1px;
  animation: textPulseFinal 3s infinite ease-in-out;
  pointer-events: none;
}

.neural-wires {
  grid-area: 1/1;
  position: relative;
  width: 0;
  height: 0;
  z-index: 15;
}

.wire {
  position: absolute;
  top: -1.5px; 
  left: 0;
  width: 100px; 
  height: 4px;
  background: rgba(59, 130, 246, 0.2);
  transform-origin: 0 50%;
  transform: rotate(var(--angle)) translateX(70px);
}

.wire-signal {
  position: absolute;
  top: 0; left: 0;
  width: 0; height: 100%;
  background: #fff; /* High contrast white signal */
  box-shadow: 0 0 20px #fff, 0 0 35px var(--accent);
  animation: signalFlowRetreat 4s infinite ease-in-out;
}

.wire-signal::after {
  content: '';
  position: absolute;
  right: -8px; top: 50%;
  width: 16px; height: 16px;
  transform: translateY(-50%) scale(0);
  background: #fff;
  border: 3px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent);
  opacity: 0;
  animation: nodePopRetreat 4s infinite ease-in-out;
}

/* Staggered Delay Logic */
.wire[style*="0deg"] .wire-signal, .wire[style*="0deg"] .wire-signal::after { animation-delay: 0s; }
.wire[style*="45deg"] .wire-signal, .wire[style*="45deg"] .wire-signal::after { animation-delay: 0.5s; }
.wire[style*="90deg"] .wire-signal, .wire[style*="90deg"] .wire-signal::after { animation-delay: 1s; }
.wire[style*="135deg"] .wire-signal, .wire[style*="135deg"] .wire-signal::after { animation-delay: 1.5s; }
.wire[style*="180deg"] .wire-signal, .wire[style*="180deg"] .wire-signal::after { animation-delay: 2s; }
.wire[style*="225deg"] .wire-signal, .wire[style*="225deg"] .wire-signal::after { animation-delay: 2.5s; }
.wire[style*="270deg"] .wire-signal, .wire[style*="270deg"] .wire-signal::after { animation-delay: 3s; }
.wire[style*="315deg"] .wire-signal, .wire[style*="315deg"] .wire-signal::after { animation-delay: 3.5s; }

#ai-processing-msg, #bg-processing-msg {
  color: #fff;
  font-weight: 700;
  font-size: 1.6rem;
  margin-bottom: 25px;
  text-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
}

#premium-pbar-magic, #premium-pbar-bg {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 0%;
  height: 100% !important;
  background: linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.2) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, 0.2) 50%,
    rgba(255, 255, 255, 0.2) 75%,
    transparent 75%,
    transparent
  ), linear-gradient(90deg, #3b82f6, #60a5fa, #3b82f6) !important;
  background-size: 40px 40px, 200% 100% !important;
  animation: stripesMove 1s infinite linear, shimmerFlowFinal 1.5s infinite linear !important;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.6) !important;
  transition: width 0.4s cubic-bezier(0.1, 0.5, 0.1, 1) !important;
  border-radius: 20px !important;
}

/* Brilliant Head Glow Effect */
#premium-pbar-magic::after, #premium-pbar-bg::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 20px;
  background: #fff;
  filter: blur(8px);
  opacity: 0.8;
  border-radius: 50%;
  box-shadow: 0 0 15px #fff, 0 0 30px var(--accent);
}

.premium-progress-wrap {
  position: relative !important;
  width: 350px !important;
  height: 10px !important;
  background: rgba(255,255,255,0.1) !important;
  border-radius: 20px !important;
  overflow: hidden !important;
  margin: 10px auto 20px !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
}

.premium-progress-hint {
  color: rgba(255,255,255,0.5);
  font-size: 0.9rem;
  max-width: 400px;
  line-height: 1.5;
  margin-top: 10px;
}

@keyframes shimmerFlowFinal {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

@keyframes brainBreathCoreFinal {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.05); opacity: 1; }
}

@keyframes textPulseFinal {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.1); opacity: 1; }
}

@keyframes signalFlowRetreat {
  0% { width: 0; opacity: 0; }
  5% { opacity: 1; }
  35% { width: 100%; opacity: 1; }
  65% { width: 100%; opacity: 1; }
  95% { width: 0%; opacity: 1; }
  100% { width: 0%; opacity: 0; }
}

@keyframes nodePopRetreat {
  0%, 25% { opacity: 0; transform: translateY(-50%) scale(0); }
  30% { opacity: 1; transform: translateY(-50%) scale(1.25); }
  35%, 65% { opacity: 1; transform: translateY(-50%) scale(1); }
  95% { opacity: 1; transform: translateY(-50%) scale(0.8); }
  100% { opacity: 0; transform: translateY(-50%) scale(0); }
}


.brain-core-unit::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 100px; height: 100px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, #fff 0%, var(--accent) 40%, transparent 80%);
  border-radius: 50%;
  z-index: 10;
  pointer-events: none;
  animation: brainGlowPulse 4s infinite ease-in-out;
  box-shadow: 0 0 30px rgba(59, 130, 246, 0.6);
}

@keyframes brainGlowPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
  50% { transform: translate(-50%, -50%) scale(2.2); opacity: 0.5; }
}








/* === SURGICAL ZOOM & SCROLL SYSTEM === */
.image-container {
  overflow: auto !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) rgba(0,0,0,0.2);
}

.image-container::-webkit-scrollbar {
  width: 10px; height: 10px;
}

.image-container::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 5px;
}

#preview-image {
  flex-shrink: 0 !important;
  margin: auto !important; /* Forces scrollbars to respect center while allowing overflow */
  transition: width 0.1s ease-out, height 0.1s ease-out;
}

.zoom-group {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(15, 23, 42, 0.6);
  padding: 5px 15px;
  border-radius: 30px;
  border: 1px solid rgba(255,255,255,0.1);
  margin: 0 15px;
  backdrop-filter: blur(5px);
}

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

#zoom-range-slider {
  width: 100px;
  cursor: pointer;
  accent-color: var(--accent);
}

#zoom-val-display {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--accent);
  min-width: 42px;
}

.zoom-action-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.2s;
  padding: 5px;
  font-size: 1rem;
}

.zoom-action-btn:hover {
  opacity: 1;
  color: var(--accent);
  transform: scale(1.15);
}

@media (max-width: 768px) {
  .zoom-group {
    margin: 5px 0;
    padding: 3px 10px;
  }
  #zoom-range-slider { width: 70px; }
  #zoom-val-display { display: none; }
}


/* === DEFINITIVE DESKTOP CLEANUP === */
@media (min-width: 900px) { .mobile-dock, .sheet-backdrop, .sheet-drag-handle, #mobile-dock { display: none !important; visibility: hidden !important; height: 0 !important; padding: 0 !important; margin: 0 !important; pointer-events: none !important; opacity: 0 !important; } }

/* Segmented Control UI (Premium) */
.segmented-control {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  gap: 4px;
  margin-bottom: 8px;
}

.segment-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 4px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
}

.segment-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.segment-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Success Stats Popup - V2 (Unique Design) */
.success-content {
  background: rgba(15, 23, 42, 0.65); /* Glassier */
  backdrop-filter: blur(25px) saturate(200%);
  -webkit-backdrop-filter: blur(25px) saturate(200%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 25px;
  border-radius: 20px;
  width: 90%;
  max-width: 480px;
  position: relative;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(59, 130, 246, 0.05);
  animation: modalSlideFade 0.6s cubic-bezier(0.23, 1, 0.32, 1);
  z-index: 10001;
  text-align: left;
}

@keyframes modalSlideFade {
  from { transform: translateY(30px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.success-content .close-btn {
  position: absolute;
  top: 12px;
  right: 15px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s, transform 0.2s;
  padding: 5px;
}

.success-content .close-btn:hover {
  color: #fff;
  transform: rotate(90deg);
}

.stats-row {
  display: flex;
  align-items: center;
  gap: 25px;
  margin-bottom: 15px;
}

.file-indicator-container {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.file-shape-outline {
  width: 65px;
  height: 85px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px 20px 6px 6px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

.file-shape-outline i {
  font-size: 2rem;
  color: rgba(255, 255, 255, 0.2);
  z-index: 2;
  position: relative;
}

.file-fill-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--accent);
  box-shadow: 0 0 25px rgba(59, 130, 246, 0.5);
  transition: height 3.5s cubic-bezier(0.19, 1, 0.22, 1);
  z-index: 1;
}

.percentage-overlay {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#saved-percent {
  font-size: 2.2rem;
  font-weight: 900;
  color: #fff;
  line-height: 1;
  letter-spacing: -1px;
}

.tiny-label {
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 2.5px;
  text-transform: uppercase;
  margin-top: 4px;
}

.stats-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.stats-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 20px;
}

.stats-subtitle span {
  color: #fff;
  font-weight: 700;
}

.size-comparison-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.size-node {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.size-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 1px;
}

.size-val {
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
}

.size-node.new .size-val {
  color: #2dd4bf;
}

.size-arrow {
  color: rgba(255, 255, 255, 0.2);
  font-size: 1rem;
}

