/* ==========================================
   1. CSS VARIABLES (THEME)
   ========================================== */
:root {
  --primary: #1eb6de;
  --primary-dark: #1892b2;
  --light-bg: #f8fcff;
  --border: #e1e5f1;
  --text: #1e293b;
  --text-light: #475569;
  --card-bg: #ffffff;
  --toast-bg: #2c3e50;
  --danger: #e53e3e;
  --danger-dark: #c53030;
  --success: #42b673;
  --success-dark: #23623d;
  --warning: #ed8936;
  --info: #4299e1;
}

[data-theme="dark"] {
  --primary: #1eb6de;
  --primary-dark: #1892b2;
  --light-bg: #292b32;
  --border: #4a4a5a;
  --text: #f1f5f9;
  --text-light: #cbd5e1;
  --card-bg: #1e1f28;
  --toast-bg: #111827;
  --danger: #f56565;
  --danger-dark: #e53e3e;
  --success: #48bb78;
  --success-dark: #38a169;
  --warning: #f6ad55;
  --info: #63b3ed;
}

/* ==========================================
   2. BASE & RESET
   ========================================== */
.mb10 { margin-bottom: 10px !important; }
hr.compact { margin: 8px 0 !important; }

.container-custom *,
.container-custom *::before,
.container-custom *::after { box-sizing: border-box; }

/* ==========================================
   3. CONTAINER LAYOUT
   ========================================== */
.container-custom {
  width: 100%;
  margin: 20px auto;
  background: var(--card-bg);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 40px);
  overflow: hidden;
  position: relative;
}

/* ==========================================
   LOADING OVERLAY
   ========================================== */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 50;
  color: var(--primary);
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
}

[data-theme="dark"] .loading-overlay {
  background: rgba(30, 31, 40, 0.85);
}

.loading-overlay i {
  font-size: 28px;
}

/* ==========================================
   4. HEADER
   ========================================== */
.tool-header {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: 6px 6px 0 0;
}

.tool-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tool-title {
  padding-bottom: 0 !important;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
}

.tool-subtitle {
  margin: 0;
  color: var(--text-light);
  font-size: 0.75rem;
  line-height: normal;
}

.tool-actions { display: flex; gap: 6px; }

/* ==========================================
   5. BUTTONS & ACTIONS
   ========================================== */
.action-btn,
.secondary-btn,
.success-btn,
.danger-btn,
.mini-btn,
.seed-btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  padding: 8px 12px;
  white-space: nowrap;
  border-radius: 4px;
  outline: none;
  text-shadow: none !important;
  box-shadow: none !important;
  transform: none !important;
  filter: none !important;
  backdrop-filter: none !important;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.action-btn i,
.secondary-btn i,
.seed-btn i,
.success-btn i,
.danger-btn i { font-size: 15px; }

.action-btn { background: var(--primary); color: #ffffff; }
.action-btn:hover,
.action-btn:active,
.action-btn:focus {
  color: #ffffff;
  background: var(--primary-dark);
  border: none;
  text-shadow: none;
}

.secondary-btn {
  background: var(--light-bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.secondary-btn:hover,
.secondary-btn:active,
.secondary-btn:focus {
  background: var(--card-bg);
  color: var(--primary);
  border: 1px solid var(--primary);
  text-shadow: none;
}

.success-btn { background: var(--success); color: #ffffff; }
.success-btn:hover,
.success-btn:active,
.success-btn:focus {
  color: #ffffff;
  background: var(--success-dark);
  border: none;
  text-shadow: none;
}

.danger-btn { background: var(--danger); color: #ffffff; }
.danger-btn:hover,
.danger-btn:active,
.danger-btn:focus {
  color: #ffffff;
  background: var(--danger-dark);
  border: none;
  text-shadow: none;
}

.seed-button-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.seed-btn {
  flex: 1;
  padding: 8px;
  font-size: 12px;
  font-weight: 600;
  background: var(--light-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.seed-btn:hover {
  background: var(--card-bg);
  color: var(--primary);
  border-color: var(--primary);
  text-shadow: none;
}

#UploadImageBtn i {
  color: var(--primary);
}
[data-theme="dark"] #UploadImageBtn i {
  color: var(--primary);
}

/* ==========================================
   6. WORKSPACE GRID
   ========================================== */
.tool-workspace {
  display: grid;
  grid-template-columns: 220px 1fr 260px;
  gap: 0;
  flex: 1;
  overflow: hidden;
}

/* ==========================================
   7. PANELS
   ========================================== */
.left-panel,
.right-panel {
  background: var(--light-bg);
  padding: 5px;
  overflow-y: auto;
  height: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.left-panel::-webkit-scrollbar,
.right-panel::-webkit-scrollbar { width: 5px; }

.left-panel::-webkit-scrollbar-track,
.right-panel::-webkit-scrollbar-track { background: transparent; }

.left-panel::-webkit-scrollbar-thumb,
.right-panel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.left-panel::-webkit-scrollbar-thumb:hover,
.right-panel::-webkit-scrollbar-thumb:hover { background: var(--primary); }

.right-panel {
  position: relative;
  z-index: 1;
}

.middle-panel {
  padding: 10px;
  background: var(--light-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* ==========================================
   8. PANEL SECTIONS
   ========================================== */
.panel-section {
  margin-bottom: 10px;
  background: var(--card-bg);
  border-radius: 4px;
  border: 1px solid var(--border);
}

.panel-section:last-child { margin-bottom: 0; }

.panel-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--light-bg);
  border-radius: 4px 4px 0 0;
  transition: background 0.15s;
}

.panel-section-header:hover { background: var(--border); }

.panel-section-header i {
  font-size: 9px;
  color: var(--text-light);
}

.panel-section-header i.fa-chevron-down { transition: transform 0.2s; }

.panel-section.collapsed .panel-section-header i.fa-chevron-down { transform: rotate(-90deg); }

.panel-section.collapsed .panel-section-header { border-radius: 4px; }

.panel-section-content {
  padding: 5px;
  max-height: 800px;
  overflow: hidden;
  transition: max-height 0.2s ease-in-out, padding 0.2s ease-in-out, opacity 0.15s ease;
  opacity: 1;
}

.panel-section.collapsed .panel-section-content {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}

/* ==========================================
   9. FORM CONTROLS & WRAPS
   ========================================== */
.control-group { margin-bottom: 5px; }
.control-group:last-child { margin-bottom: 0; }

.control-group label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 10px;
}

.slider-row:last-child {
  margin-bottom: 0;
}

.slider-label {
  font-size: 11px;
  color: var(--text);
  font-weight: 500;
  width: 65px;
  flex-shrink: 0;
}

.slider-value {
  font-size: 10px;
  color: var(--text);
  font-family: monospace;
  width: 32px;
  text-align: right;
  flex-shrink: 0;
}

/* ==========================================
   10. RANGE INPUTS (SLIDERS)
   ========================================== */
.slider-row input[type="range"],
input[type="range"] {
  flex: 1;
  width: 100%;
  margin: 0;
  padding: 0;
  height: 10px;
  cursor: pointer;
  display: block;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  margin-top: -8px;
  transition: transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

input[type="range"]::-moz-range-track {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s;
}

input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.15);
}

/* ==========================================
   11. DROPDOWNS (EXACT ORIGINAL STYLES)
   ========================================== */
.custom-dropdown { position: relative; width: 100%; }

.custom-dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  transition: border-color 0.15s;
  text-shadow: none !important;
  box-shadow: none !important;
  transform: none !important;
}

.custom-dropdown-trigger:hover { border-color: var(--primary); }

.custom-dropdown-trigger.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(30, 182, 222, 0.15);
}

.custom-dropdown-trigger i {
  font-size: 9px;
  color: var(--primary);
  transition: transform 0.15s;
}

.custom-dropdown-trigger.active i { transform: rotate(180deg); }

.custom-dropdown-menu {
  position: fixed;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  display: none;
  max-height: 182px;
  overflow-y: auto;
  min-width: 200px;
}

.custom-dropdown-menu.open { display: block; }

.custom-dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  outline: none;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
  text-shadow: none !important;
  box-shadow: none !important;
  transform: none !important;
  text-transform: none !important;
}

.custom-dropdown-item:last-child { border-bottom: none; }

.custom-dropdown-item:hover {
  background: var(--light-bg);
  color: var(--primary);
  border: none;
  border-bottom: 1px solid var(--border);
}

.custom-dropdown-item.selected {
  background: rgba(30, 182, 222, 0.1);
  color: var(--primary);
  font-weight: 600;
}

/* ==========================================
   12. PREVIEW & DROP ZONE
   ========================================== */
.preview-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  object-fit: contain;
  background: transparent;
}

.modified-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  background: transparent;
}

.drop-zone {
  width: 100%;
  height: 100%;
  min-height: 400px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
  cursor: pointer;
}

.drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(30, 182, 222, 0.05);
  transform: scale(1.01);
}

.drop-zone-icon {
  font-size: 48px;
  color: var(--primary);
  margin-bottom: 12px;
  opacity: 0.8;
}

.drop-zone-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.drop-zone-subtitle {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 12px;
}

.drop-zone-formats {
  font-size: 11px;
  color: var(--text-light);
  background: var(--light-bg);
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.truncate-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  display: block;
  cursor: help;
}

/* ==========================================
   13. COMPARISON CONTAINER & ZOOM/PAN
   ========================================== */
.comparison-container {
  position: relative;
  max-width: 100%;
  max-height: calc(100vh - 120px);
  width: 100%;
  height: 100%;
  margin: 0 auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  border-radius: 4px;
  overflow: hidden;
  user-select: none;
  display: none;
  align-items: center;
  justify-content: center;
  background-color: var(--card-bg);
  background-image: 
    linear-gradient(45deg, rgba(0,0,0,0.06) 25%, transparent 25%), 
    linear-gradient(-45deg, rgba(0,0,0,0.06) 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, rgba(0,0,0,0.06) 75%), 
    linear-gradient(-45deg, transparent 75%, rgba(0,0,0,0.06) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

[data-theme="dark"] .comparison-container {
  background-image: 
    linear-gradient(45deg, rgba(255,255,255,0.06) 25%, transparent 25%), 
    linear-gradient(-45deg, rgba(255,255,255,0.06) 25%, transparent 25%), 
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.06) 75%), 
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.06) 75%);
}

.comparison-container.zoomed {
  cursor: grab;
}

.comparison-container.zoomed:active {
  cursor: grabbing;
}

.zoom-wrapper {
  position: relative;
  transform-origin: center center;
  transition: transform 0.1s ease-out;
  flex-shrink: 0;
}

.comparison-image {
  display: block;
  pointer-events: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.original-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  clip-path: inset(0 50% 0 0);
}

.comparison-slider-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--primary);
  z-index: 30;
  pointer-events: none;
}

.comparison-slider-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  z-index: 31;
  cursor: ew-resize;
  transition: box-shadow 0.15s, background 0.15s;
}

.comparison-slider-handle:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  background: var(--primary-dark);
}

.comparison-label {
  position: absolute;
  top: 10px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  pointer-events: none;
  z-index: 40;
  display: none;
}

.original-label { left: 10px; }
.quantized-label { right: 10px; }

.tile-count-badge {
  position: absolute;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  z-index: 20;
  pointer-events: none;
  display: none;
}

.zoom-indicator {
  position: absolute;
  top: 35px;
  right: 10px;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  z-index: 35;
  pointer-events: none;
  display: none;
  transition: right 0.2s;
}

.zoom-controls-wrap {
  position: absolute;
  bottom: 15px;
  right: 15px;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 35;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.75);
  padding: 4px 6px;
  border-radius: 4px;
}

.comparison-container:hover .zoom-controls-wrap {
  opacity: 1;
  pointer-events: auto;
}

.zoom-btn {
  background: transparent;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  padding: 4px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  text-shadow: none;
  width: 28px;
  height: 28px;
}

.zoom-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  text-shadow: none;
  color: #ffffff;
}

.zoom-btn i {
  font-size: 12px;
}

.zoom-slider {
  width: 80px;
  height: 4px;
  margin: 0 4px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  outline: none;
  align-self: center;
}

.zoom-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  margin-top: -5px;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.zoom-slider::-moz-range-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.zoom-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ==========================================
   14. BORDER & COLOR SETTINGS WRAP
   ========================================== */
.border-settings-wrap {
  display: flex;
  flex-wrap: wrap;
  column-gap: 8px;
  row-gap: 6px;
  background: var(--light-bg);
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  align-items: center;
}

.border-settings-wrap input[type="color"] {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  padding: 0;
  background: none;
  cursor: pointer;
  border-radius: 4px;
  flex-shrink: 0;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.border-settings-wrap input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 3px;
  overflow: hidden;
}

.border-settings-wrap input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}

.border-settings-wrap input[type="color"]::-moz-color-swatch {
  border: none;
}

.border-settings-wrap .color-hex {
  cursor: default;
  font-size: 11px;
  color: var(--text-light);
  font-family: monospace;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.border-toggle-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  margin-left: auto;
}

.border-toggle-switch .toggle-label {
  font-size: 11px;
  color: var(--text);
}

.border-toggle-switch input { display: none; }

.border-toggle-switch .toggle-slider {
  width: 32px;
  height: 18px;
  background-color: var(--border);
  border-radius: 18px;
  position: relative;
  transition: background-color 0.2s;
}

.border-toggle-switch .toggle-slider::before {
  content: "";
  position: absolute;
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.border-toggle-switch input:checked + .toggle-slider { background-color: var(--primary); }

.border-toggle-switch input:checked + .toggle-slider::before { transform: translateX(14px); }

/* ==========================================
   15. EXPORT GRID
   ========================================== */
.export-content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.export-content-grid button {
  width: 100%;
  padding: 6px 2px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================
   16. TOAST & FULLSCREEN
   ========================================== */
#toastContainer {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  max-width: calc(100% - 40px);
}

.toast {
  background: var(--toast-bg);
  color: white;
  padding: 8px 14px;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  margin-top: 6px;
  animation: slideUp 0.2s ease, fadeOut 0.2s ease 2.8s forwards;
  max-width: 280px;
  border-left: 3px solid var(--primary);
  text-shadow: none !important;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateY(10px); }
}

.container-custom.is-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0; /* Prevents 100vw scrollbar calculation bugs */
  width: 100%;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  z-index: 9999;
  box-shadow: none;
  border-radius: 0;
}

.container-custom.is-fullscreen .tool-workspace {
  flex: 1;
  height: calc(100vh - 45px);
}

/* ==========================================
   17. CUSTOM NUMBER INPUTS FOR EXPORT
   ========================================== */
.custom-number-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card-bg);
  color: var(--text);
  font-size: 11px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
}

.custom-number-input::-webkit-outer-spin-button,
.custom-number-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.custom-number-input:focus {
  border-color: var(--primary);
}

/* ==========================================
   18. SLIDER ADJUST BUTTONS (+ / -)
   ========================================== */
.slider-adjust-btn {
  width: 20px;
  height: 20px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-light);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s;
  text-shadow: none;
}

.slider-adjust-btn i {
  color: var(--text-light);
  font-size: 10px;
}

.slider-adjust-btn:hover {
  color: var(--primary);
  background: transparent;
}

.slider-adjust-btn:active {
  transform: scale(0.9);
}

/* ==========================================
   19. ICON SELECTORS (GRID & SHAPE)
   ========================================== */
.icon-selector-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 4px;
}

.icon-selector-btn {
  width: 35px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  padding: 0;
  outline: none;
}

.icon-selector-btn:hover {
  border-color: var(--primary);
  background: var(--light-bg);
}

.icon-selector-btn.active {
  border-color: var(--primary);
  background: rgba(30, 182, 222, 0.1);
}

.icon-selector-btn svg {
  width: 24px;
  height: 24px;
  color: var(--text);
}

.icon-selector-btn.active svg {
  color: var(--primary);
}

/* ==========================================
   20. STITCH LEGEND TABLE STYLES (NEW)
   ========================================== */
.stitch-legend-header,
.stitch-legend-row {
  display: grid;
  grid-template-columns: 24px 45px 55px 45px 45px;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
}

.stitch-legend-header {
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  font-size: 9px;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 2px;
  padding-bottom: 6px;
}

.stitch-legend-row:last-child {
  border-bottom: none;
}

.stitch-legend-symbol {
  font-family: monospace;
  font-weight: 700;
  font-size: 12px;
  color: var(--text);
  text-align: center;
}

.stitch-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.stitch-legend-code {
  font-family: monospace;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 10px;
}

.stitch-legend-count,
.stitch-legend-percent {
  text-align: right;
  color: var(--text-light);
  font-family: monospace;
  white-space: nowrap;
  font-size: 10px;
}

.stitch-legend-count {
  font-weight: 500;
  color: var(--text);
}


/* ==========================================
   VIEW MODE TOGGLE (SLIDER VS TOGGLE)
   ========================================== */
.view-mode-toggle {
  position: absolute;
  bottom: 60px;
  right: 15px;
  display: flex;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 35;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.comparison-container:hover .view-mode-toggle {
  opacity: 1;
  pointer-events: auto;
}

.view-mode-btn {
  background: transparent;
  color: #ffffff;
  border: none;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s, color 0.15s;
  text-shadow: none !important;
  box-shadow: none !important;
  transform: none !important;
  filter: none !important;
  backdrop-filter: none !important;
  font-family: inherit;
  outline: none;
}

.view-mode-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  text-shadow: none;
  color: #ffffff;
}


.view-mode-btn i {
  font-size: 12px;
}




/* ==========================================
   PATTERN INFO PANEL (PROFESSIONAL UPGRADE)
   ========================================== */
.pattern-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.info-item {
  background: var(--light-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 4px;
  display: flex;

  flex-direction: column;
  align-items: center;
  text-align: center;
}

.info-label {
  font-size: 10px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  font-weight: 600;
}

.info-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  font-family: monospace;
}

.info-note {
  font-size: 10px;
  color: var(--text-light);
  text-align: center;
  font-style: italic;
}
/* ==========================================
   PATTERN INFO STACKED VALUES
   ========================================== */
.info-value-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.info-value-sub {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-light);
  font-family: monospace;
}



/* ==========================================
   FULLSCREEN SCROLLBAR FIX
   ========================================== */
body.tool-is-fullscreen,
html.tool-is-fullscreen {
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
}



/* ==========================================
   21. RESPONSIVE
   ========================================== */
@media (max-height: 800px) {
  .container-custom {
    margin: 10px auto;
    max-height: calc(100vh - 20px);
    border-radius: 6px;
  }
  .tool-header { padding: 6px 12px; }
  .panel-section-content { padding: 4px; }
}

@media (max-width: 900px) {
  .container-custom {
    max-height: none;
    height: auto;
    overflow: visible;
  }
  
  .tool-workspace {
    grid-template-columns: 1fr;
    overflow: visible;
    height: auto;
  }
  
  .left-panel,
  .right-panel {
    border: none;
    border-bottom: 1px solid var(--border);
    overflow-y: visible;
    height: auto;
  }
  
  .middle-panel {
    padding: 10px;
    overflow: visible;
    align-items: center;
  }
  
  .drop-zone {
    min-height: 300px;
  }
  
  .comparison-container {
    max-height: 60vh;
    height: 60vh;
    min-height: 300px;
    margin: 0;
  }

  .container-custom.is-fullscreen .comparison-container {
    max-height: calc(100vh - 80px);
    height: calc(100vh - 80px);
  }
}