/* ═══════════════════════════════════════════════════════
   CSS TOOLS HUB — STYLESHEET
   ═══════════════════════════════════════════════════════ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Design Tokens ── */
:root {
  /* Woodsmoke Ultra-Dark Theme */
  --bg-primary:   #0a0a0a; /* Ultra Black */
  --bg-secondary: #121212; /* Deep Grey */
  --bg-card:      #1b1b1b; /* Card Surface */
  --bg-hover:     #262626; /* Hover Highlight */
  --border:       #262626; /* Subtle Border */
  --text-primary: #f1f1f1; /* High Contrast White */
  --text-secondary:#9d9d9d; /* Dimmed Gray */
  --text-muted:   #555555; /* Muted Details */
  --accent:       #6c63ff; /* User Preferred Original Purple */
  --accent-glow:  rgba(108,99,255,0.15);
  --accent-hover: #7b72ff;
  --success:      #10b981;
  --danger:       #f43f5e;
  --radius-sm:    10px;
  --radius-md:    14px;
  --radius-lg:    20px;
  --shadow-sm:    0 2px 10px rgba(0,0,0,0.6);
  --shadow-md:    0 4px 24px rgba(0,0,0,0.7);
  --shadow-lg:    0 8px 48px rgba(0,0,0,0.8);
  --sidebar-w:    240px;
  --topbar-h:     60px;
  --transition:   0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-primary:   #f5f5ff;
  --bg-secondary: #eeeeff;
  --bg-card:      #ffffff;
  --bg-hover:     #e8e8ff;
  --border:       #d0d0ee;
  --text-primary: #1a1a3f;
  --text-secondary:#4a4a80;
  --text-muted:   #8888aa;
  --accent:       #5a52ee;
  --accent-glow:  rgba(90,82,238,0.15);
  --accent-hover: #4a43dd;
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:    0 4px 20px rgba(0,0,0,0.1);
  --shadow-lg:    0 8px 40px rgba(0,0,0,0.12);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
}
input, select, button, textarea { font-family: inherit; }
a { text-decoration: none; color: inherit; }

/* ════════════════════ LAYOUT ════════════════════ */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), background var(--transition);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

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

.logo-icon {
  font-size: 22px;
  filter: drop-shadow(0 0 8px var(--accent));
}

.logo-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  width: 28px; height: 28px;
  border-radius: 6px;
  transition: background var(--transition);
}

.sidebar-close:hover { background: var(--bg-hover); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}

.nav-item:hover, .nav-item.active {
  background: var(--bg-hover);
  color: var(--accent);
  transform: translateX(4px);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

.theme-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

/* ── Top Bar (Shared) ── */
.topbar {
  display: flex; /* Always visible now */
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  transition: background var(--transition);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-left: 20px;
}

.top-nav-link {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}

.top-nav-link:hover, .top-nav-link.active {
  color: var(--accent);
  background: var(--bg-hover);
  box-shadow: 0 2px 0 var(--accent);
}

.theme-toggle-top {
  width: auto !important; /* Allow button width to expand for text */
  padding: 0 16px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  margin-right: 8px; /* Little distance from right */
  transition: all var(--transition);
}

.theme-toggle-top span {
  pointer-events: none;
}

.menu-btn, .theme-toggle-top {
  background: transparent; /* Fix: remove default white button background */
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-primary);
  height: 40px;
  padding: 0 10px;
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
}

.menu-btn {
  width: 44px;
  border-radius: var(--radius-sm);
}



.menu-btn {
  display: none; /* Hide on desktop by default */
}


.menu-btn:hover, .theme-toggle-top:hover { background: var(--bg-hover); }

.main-content {
  margin-left: var(--sidebar-w);
  padding-top: calc(var(--topbar-h) + 40px); /* Add extra breathing room below topbar */
  min-height: 100vh;
  padding-left: 32px;
  padding-right: 32px;
  padding-bottom: 32px;
  transition: margin var(--transition);
}

.sidebar-heading {
  padding: 16px 20px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

/* ════════════════════ SECTIONS ════════════════════ */
.tool-section { display: none; animation: fadeIn 0.3s ease; }
.tool-section.active { display: block; }

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

.section-header {
  margin-bottom: 28px;
}

.section-header h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.section-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ════════════════════ HOME ════════════════════ */
.home-hero {
  text-align: center;
  padding: 48px 24px 36px;
}

.home-hero h1 {
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 800;
  color: #B667CD;
  letter-spacing: -1px;
  margin-bottom: 14px;
}

.hero-sub {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 460px;
  margin: 0 auto;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  margin-top: 12px;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  cursor: pointer;
  transition: all 0.25s ease;
  display: block;
}

.tool-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-md);
  transform: translateY(-3px);
}

.tc-icon {
  font-size: 28px;
  margin-bottom: 12px;
}

.tool-card h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.tool-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ════════════════════ TOOL LAYOUT ════════════════════ */
.tool-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
  align-items: start;
}

/* ── Controls Panel ── */
.controls-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 24px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.control-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Ranges */
input[type="range"] {
  width: 100%;
  height: 4px;
  border-radius: 4px;
  background: var(--border);
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 0 3px var(--accent-glow);
  transition: transform var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* Selects */
select {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}

select:focus { border-color: var(--accent); }

/* Text inputs */
.text-input, .hex-input {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}

.text-input { width: 100%; }
.hex-input { width: 90px; font-family: 'JetBrains Mono', monospace; }
.text-input:focus, .hex-input:focus { border-color: var(--accent); }

/* Color row */
.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="color"] {
  width: 38px; height: 38px;
  padding: 2px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: none;
  cursor: pointer;
  outline: none;
}

input[type="color"]:hover { border-color: var(--accent); }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 38px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.3s;
}
.slider::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* Checkbox label */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary) !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
}

.checkbox-label input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Segmented buttons */
.btn-group {
  display: flex;
  gap: 6px;
}

.seg-btn {
  flex: 1;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}

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

/* Preset chips */
.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 4px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.chip:hover, .chip.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

/* Action row */
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  justify-content: center;
}

.btn-copy {
  flex: 1 1 140px; /* Allow growing and shrinking with a base of 140px */
  padding: 12px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.btn-copy:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px var(--accent-glow);
  transform: translateY(-2px);
}

.btn-copy::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.1), transparent);
  pointer-events: none;
}

@media (max-width: 600px) {
  .action-row {
    flex-direction: column;
  }
  .btn-copy, .btn-reset {
    width: 100%;
    flex: none;
  }
}


.btn-reset {
  padding: 10px 16px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-reset:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ── Preview Panel ── */
.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preview-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  overflow: hidden;
  position: relative;
}

/* Code output */
.code-block {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  overflow-x: auto;
}

.code-block pre {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--accent);
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.7;
}

/* ════════════════════ TOOL-SPECIFIC PREVIEWS ════════════════════ */

/* Gradient Dynamic Colors */
.btn-add-color {
  width: 100%;
  margin-top: 10px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  color: var(--accent);
  border: 1px dashed var(--accent);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-add-color:hover {
  background: var(--accent-glow);
  color: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-add-color .icon {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}
#colorsContainer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 6px;
}

#colorsContainer::-webkit-scrollbar {
  width: 4px;
}

#colorsContainer::-webkit-scrollbar-track {
  background: transparent;
}

#colorsContainer::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

#colorsContainer::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.color-row-wrapper {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--transition);
}

.color-row-wrapper:hover {
  border-color: var(--accent-glow);
}

.color-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.color-inputs-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all var(--transition);
}

.btn-remove:hover {
  background: var(--danger);
  color: #fff;
}

.color-pos-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: -4px;
}

.color-pos-label span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.color-pos-val {
  color: var(--accent);
}

#gradientPreview {
  width: 100%; min-height: 260px;
  border-radius: var(--radius-lg);
  transition: background 0.3s;
}

/* Shadow */
.shadow-canvas { background: repeating-linear-gradient(45deg, var(--bg-hover) 0, var(--bg-hover) 10px, transparent 10px, transparent 20px); }
.shadow-demo {
  width: 140px; height: 100px;
  background: var(--bg-card);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  color: var(--text-secondary);
  transition: box-shadow 0.2s;
}

/* Border Radius */
.br-demo {
  width: 160px; height: 160px;
  transition: border-radius 0.2s, background 0.2s;
}

/* Flex */
.flex-canvas { padding: 20px; }
.flex-demo {
  width: 100%; min-height: 200px;
  display: flex;
  transition: all 0.2s;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 8px;
}

.flex-item {
  min-width: 50px; min-height: 50px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  opacity: 0.85;
}

.flex-item:nth-child(2) { opacity: 0.7; background: #ff6b9d; }
.flex-item:nth-child(3) { opacity: 0.6; background: #ffd93d; color: #333; }
.flex-item:nth-child(4) { opacity: 0.9; background: #22c55e; }
.flex-item:nth-child(5) { background: #f97316; }
.flex-item:nth-child(6) { background: #06b6d4; }
.flex-item:nth-child(7) { background: #ec4899; }
.flex-item:nth-child(8) { background: #8b5cf6; }

/* Grid */
.grid-canvas { padding: 20px; }
.grid-demo {
  width: 100%;
  display: grid;
  transition: all 0.2s;
}

.grid-item {
  background: var(--accent);
  border-radius: 6px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  opacity: 0.85;
}

.grid-item:nth-child(2n) { opacity: 0.7; background: #ff6b9d; }
.grid-item:nth-child(3n) { opacity: 0.85; background: #22c55e; }

/* Animation */
.anim-canvas { overflow: hidden; }
.anim-demo {
  width: 80px; height: 80px;
  background: var(--accent);
  border-radius: 14px;
  transition: background 0.2s;
}

/* Button preview */
.btn-canvas { background: repeating-linear-gradient(45deg, var(--bg-hover) 0, var(--bg-hover) 10px, transparent 10px, transparent 20px); }
.btn-preview {
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
}

/* Glass */
.glass-canvas {
  background: linear-gradient(135deg, #6c63ff 0%, #ff6b9d 50%, #ffd93d 100%);
  min-height: 280px;
}

.glass-demo {
  padding: 28px 32px;
  text-align: center;
  transition: all 0.2s;
}

.glass-demo h3 { font-size: 18px; margin-bottom: 8px; color: white; }
.glass-demo p  { font-size: 13px; color: rgba(255,255,255,0.8); }

/* Clip */
.clip-canvas { background: repeating-linear-gradient(45deg, var(--bg-hover) 0, var(--bg-hover) 10px, transparent 10px, transparent 20px); }
.clip-demo {
  width: 180px; height: 180px;
  background: var(--accent);
  transition: clip-path 0.3s, background 0.2s;
}

/* Loader */
.loader-canvas { flex-direction: column; gap: 20px; }

/* ═══ LOADER TYPES ═══ */
.spinner-ring {
  border-radius: 50%;
  border: 4px solid rgba(108,99,255,0.2);
  border-top-color: var(--loader-color, #6c63ff);
  animation: spin var(--loader-speed, 1s) linear infinite;
}

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

.spinner-dots {
  display: flex;
  gap: 8px;
  align-items: center;
}

.spinner-dots span {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--loader-color, #6c63ff);
  animation: bounce var(--loader-speed, 1s) ease-in-out infinite;
}
.spinner-dots span:nth-child(2) { animation-delay: 0.15s; }
.spinner-dots span:nth-child(3) { animation-delay: 0.30s; }

@keyframes bounce {
  0%, 100% { transform: translateY(0); opacity: 1; }
  50%       { transform: translateY(-16px); opacity: 0.5; }
}

.spinner-bars {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  height: 50px;
}

.spinner-bars span {
  width: 8px;
  background: var(--loader-color, #6c63ff);
  border-radius: 4px;
  animation: bar-pulse var(--loader-speed, 1s) ease-in-out infinite;
}

.spinner-bars span:nth-child(1) { animation-delay: 0s; }
.spinner-bars span:nth-child(2) { animation-delay: 0.1s; }
.spinner-bars span:nth-child(3) { animation-delay: 0.2s; }
.spinner-bars span:nth-child(4) { animation-delay: 0.3s; }
.spinner-bars span:nth-child(5) { animation-delay: 0.4s; }

@keyframes bar-pulse {
  0%, 100% { height: 12px; opacity: 0.5; }
  50%       { height: 50px; opacity: 1; }
}

.spinner-dual {
  border-radius: 50%;
  border: 4px solid transparent;
  border-top-color: var(--loader-color, #6c63ff);
  border-bottom-color: var(--loader-color, #6c63ff);
  animation: spin var(--loader-speed, 1s) linear infinite;
}

.spinner-ripple {
  position: relative;
}

.spinner-ripple span {
  position: absolute;
  border-radius: 50%;
  border: 3px solid var(--loader-color, #6c63ff);
  animation: ripple-anim var(--loader-speed, 1s) ease-out infinite;
}

.spinner-ripple span:nth-child(2) { animation-delay: 0.5s; }

@keyframes ripple-anim {
  0%   { transform: scale(0); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

/* ════════════════════ ANIMATION KEYFRAMES ════════════════════ */
@keyframes anim-fade     { from { opacity: 0; } to { opacity: 1; } }
@keyframes anim-slide-up { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: translateY(0); } }
@keyframes anim-slide-left { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes anim-bounce   {
  0%, 100% { transform: translateY(0); animation-timing-function: cubic-bezier(0.8,0,1,1); }
  50%       { transform: translateY(-30px); animation-timing-function: cubic-bezier(0,0,0.2,1); }
}
@keyframes anim-rotate   { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes anim-scale    { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.3); } }
@keyframes anim-shake    {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
  20%, 40%, 60%, 80% { transform: translateX(6px); }
}

/* ════════════════════ TOAST ════════════════════ */
.toast {
  position: fixed;
  bottom: 32px;
  right: 32px;
  background: var(--success);
  color: #fff;
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.4,0,0.2,1);
  z-index: 9999;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ════════════════════ RESPONSIVE ════════════════════ */
@media (max-width: 900px) {
  .tool-layout {
    grid-template-columns: 1fr;
  }
  .controls-panel {
    position: static;
  }
}

@media (max-width: 800px) {
  .topbar-nav { display: none; }
  .menu-btn { display: flex; }
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; align-items: center; justify-content: center; }
  .main-content {
    margin-left: 0;
    padding-top: calc(var(--topbar-h) + 24px);
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: 32px;
  }
}

/* Overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.show { display: block; }

/* ════════════════════ SCROLLBAR ════════════════════ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ════════════════════ BUTTONS GALLERY ════════════════════ */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  margin-top: 20px;
}

.gallery-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s ease;
}

.gallery-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

.card-preview {
  height: 160px;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  position: relative;
  /* Ensure children (pre-built buttons) can use their own styles */
}

.card-info {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-info h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-mini-copy {
  flex: 1;
  min-width: 80px;
  padding: 6px 4px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.btn-mini-copy:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-mini-copy svg {
  width: 12px;
  height: 12px;
}

/* Pre-built Button Specific Styles (Injected via JS but defined here for consistency) */
/* We will inject these styles dynamically or ensure they are scoped */

@media (max-width: 600px) {
  .gallery-grid {
    grid-template-columns: 1fr;
  }
}
