/* ==========================================================================
   Sprite Generator GOM — Premium Dark Game-Dev UI
   Game Over México
   ========================================================================== */

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

/* --- CSS Custom Properties --- */
:root {
  /* Base palette */
  --bg-base:      #0e0d0f;
  --bg-deep:      #0a090b;
  --bg-card:      #18161a;
  --bg-card-hover:#19171c;
  --bg-input:     #141216;
  --bg-overlay:   rgba(14,13,15,0.92);

  /* Accent colours */
  --blue:         #22ff00;
  --blue-dim:     #1bcc00;
  --violet:       #883aed;
  --violet-dim:   #6221b6;
  --pink:         #f472af;
  --green:        #27b910;
  --amber:        #59f50b;
  --red:          #ef4444;

  /* Gradient */
  --grad-primary: linear-gradient(135deg, #883aed 0%, #22ff00 100%);
  --grad-subtle:  linear-gradient(135deg, rgba(136,58,237,0.15) 0%, rgba(34,255,0,0.15) 100%);
  --grad-glow:    linear-gradient(135deg, rgba(136,58,237,0.4) 0%, rgba(34,255,0,0.4) 100%);

  /* Borders */
  --border-base:  rgba(136,58,237,0.2);
  --border-hover: rgba(34,255,0,0.4);
  --border-active:rgba(34,255,0,0.8);

  /* Typography */
  --font-head:    'Space Grotesk', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  /* Text */
  --text-primary:   #ddf9d9;
  --text-secondary: #75e963;
  --text-muted:     #289a16;
  --text-accent:    #22ff00;

  /* Glow effects */
  --glow-blue:    0 0 20px rgba(34,255,0,0.4), 0 0 40px rgba(34,255,0,0.15);
  --glow-violet:  0 0 20px rgba(136,58,237,0.5), 0 0 40px rgba(136,58,237,0.2);
  --glow-green:   0 0 16px rgba(39,185,16,0.5);
  --glow-amber:   0 0 16px rgba(89,245,11,0.5);

  /* Spacing */
  --sp-xs:  4px;
  --sp-sm:  8px;
  --sp-md:  12px;
  --sp-lg:  16px;
  --sp-xl:  24px;
  --sp-2xl: 32px;

  /* Radius */
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   20px;

  /* Transition */
  --ease:   cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --t-fast: 150ms var(--ease);
  --t-std:  250ms var(--ease);
  --t-slow: 400ms var(--ease);
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 14px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Ambient background grid */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(136,58,237,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(136,58,237,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* Ambient top gradient */
body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 300px;
  background: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(136,58,237,0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ==========================================================================
   Header
   ========================================================================== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-xl);
  height: 56px;
  background: rgba(14,13,15,0.85);
  border-bottom: 1px solid var(--border-base);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
}

.brand-logo {
  font-family: var(--font-head);
  font-size: 1.4rem;
  font-weight: 700;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
  text-shadow: none;
  filter: drop-shadow(0 0 12px rgba(34,255,0,0.4));
}

.brand-sep {
  width: 1px;
  height: 20px;
  background: var(--border-base);
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
}

.header-badge {
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.badge-local {
  background: rgba(39,185,16,0.15);
  color: var(--green);
  border: 1px solid rgba(39,185,16,0.3);
}

.badge-free {
  background: rgba(136,58,237,0.15);
  color: #9afa8b;
  border: 1px solid rgba(136,58,237,0.3);
}

.header-shortcuts {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  gap: var(--sp-md);
  align-items: center;
}

kbd {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-base);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-secondary);
  box-shadow: 0 1px 0 rgba(136,58,237,0.3);
  margin: 0 1px;
}

/* ==========================================================================
   Main layout: 3-column grid
   ========================================================================== */
.main-layout {
  display: grid;
  grid-template-columns: 300px 1fr 280px;
  grid-template-rows: 1fr;
  gap: 0;
  flex: 1;
  height: calc(100vh - 56px - 160px); /* subtract header + gallery */
  min-height: 600px;
}

.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border-base);
}

.panel:last-child { border-right: none; }

.panel-inner {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-lg);
  scrollbar-width: thin;
  scrollbar-color: var(--border-base) transparent;
}

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

.panel-header {
  padding: var(--sp-md) var(--sp-lg);
  border-bottom: 1px solid var(--border-base);
  background: rgba(24,22,26,0.6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.panel-title {
  font-family: var(--font-head);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* ==========================================================================
   Form elements
   ========================================================================== */
.form-group {
  margin-bottom: var(--sp-lg);
}

.form-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: var(--sp-sm);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-base);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  padding: 8px 12px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--blue-dim);
  box-shadow: 0 0 0 2px rgba(34,255,0,0.12), 0 0 12px rgba(34,255,0,0.08);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

input[type="number"].form-input {
  -moz-appearance: textfield;
}
input[type="number"].form-input::-webkit-outer-spin-button,
input[type="number"].form-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

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

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--grad-primary);
  border: 2px solid var(--bg-card);
  box-shadow: 0 0 6px rgba(136,58,237,0.6);
  cursor: pointer;
  transition: box-shadow var(--t-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 12px rgba(34,255,0,0.6);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--grad-primary);
  border: 2px solid var(--bg-card);
  cursor: pointer;
}

input[type="color"] {
  width: 32px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--border-base);
  border-radius: var(--r-sm);
  background: var(--bg-input);
  cursor: pointer;
  vertical-align: middle;
}

/* Slider row */
.slider-row {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.slider-row input[type="range"] { flex: 1; }

.slider-value {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-accent);
  min-width: 30px;
  text-align: right;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  padding: 8px 16px;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  outline: none;
  text-decoration: none;
  transition: all var(--t-std);
  white-space: nowrap;
  user-select: none;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary gradient button */
.btn-primary {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: 0 2px 12px rgba(136,58,237,0.3);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.btn-primary:hover {
  box-shadow: var(--glow-violet), 0 4px 20px rgba(34,255,0,0.2);
  transform: translateY(-1px);
  filter: brightness(1.1);
}

.btn-primary:active { transform: translateY(0); }

/* Generate button — extra special */
.btn-generate {
  width: 100%;
  padding: 14px 20px;
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--grad-primary);
  color: #fff;
  border-radius: var(--r-lg);
  box-shadow: 0 4px 20px rgba(136,58,237,0.4);
  position: relative;
  overflow: hidden;
  animation: idle-pulse 3s ease-in-out infinite;
}

.btn-generate::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: var(--grad-primary);
  border-radius: inherit;
  filter: blur(8px);
  opacity: 0;
  transition: opacity var(--t-std);
  z-index: -1;
}

.btn-generate:hover {
  animation: none;
  box-shadow: var(--glow-blue), var(--glow-violet);
  transform: translateY(-2px);
  filter: brightness(1.15);
}

.btn-generate:hover::before { opacity: 0.6; }
.btn-generate:active { transform: translateY(0); }

.btn-generate.generating {
  animation: none;
  background: linear-gradient(135deg, #511c96, #1f900e);
  cursor: wait;
}

@keyframes idle-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(136,58,237,0.4); }
  50%       { box-shadow: 0 4px 28px rgba(136,58,237,0.7), 0 0 40px rgba(34,255,0,0.2); }
}

/* Ghost / outline button */
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-base);
  color: var(--text-secondary);
}

.btn-ghost:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
}

/* Icon button */
.btn-icon {
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-size: 0.8rem;
}

/* Export button */
.btn-export {
  width: 100%;
  padding: 12px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  background: linear-gradient(135deg, #2be90e, #27b910);
  color: #fff;
  border-radius: var(--r-lg);
  box-shadow: 0 2px 16px rgba(39,185,16,0.3);
}

.btn-export:hover {
  box-shadow: var(--glow-green);
  transform: translateY(-1px);
  filter: brightness(1.1);
}

/* Danger button */
.btn-danger {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--red);
}

.btn-danger:hover {
  background: rgba(239,68,68,0.2);
  border-color: var(--red);
  box-shadow: 0 0 12px rgba(239,68,68,0.3);
}

/* Small random prompt button */
.btn-random {
  padding: 6px 12px;
  font-size: 0.78rem;
  background: rgba(89,245,11,0.1);
  border: 1px solid rgba(89,245,11,0.3);
  color: var(--amber);
  border-radius: var(--r-sm);
}

.btn-random:hover {
  background: rgba(89,245,11,0.18);
  box-shadow: var(--glow-amber);
}

/* Copy button */
.btn-copy {
  padding: 5px 10px;
  font-size: 0.75rem;
  background: rgba(34,255,0,0.08);
  border: 1px solid rgba(34,255,0,0.2);
  color: var(--blue);
  border-radius: var(--r-sm);
}

.btn-copy:hover {
  background: rgba(34,255,0,0.15);
  box-shadow: 0 0 10px rgba(34,255,0,0.25);
}

/* ==========================================================================
   Category icon grid (8 categories)
   ========================================================================== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-sm);
  margin-bottom: var(--sp-lg);
}

.cat-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-base);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
  user-select: none;
  text-align: center;
}

.cat-btn:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

.cat-btn.active {
  border-color: var(--blue);
  background: rgba(34,255,0,0.08);
  box-shadow: 0 0 12px rgba(34,255,0,0.15);
}

.cat-icon {
  font-size: 1.4rem;
  line-height: 1;
  filter: grayscale(0.2);
}

.cat-label {
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.cat-btn.active .cat-label { color: var(--blue); }

/* ==========================================================================
   Art style grid (8 cards)
   ========================================================================== */
.style-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-sm);
  margin-bottom: var(--sp-lg);
}

.style-card {
  padding: 10px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-base);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
  user-select: none;
  text-align: center;
}

.style-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.style-card.active {
  border-color: var(--violet);
  background: rgba(136,58,237,0.1);
  box-shadow: 0 0 14px rgba(136,58,237,0.2);
}

.style-icon {
  font-size: 1.2rem;
  display: block;
  margin-bottom: 4px;
}

.style-name {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.2;
}

.style-card.active .style-name { color: #9afa8b; }

/* ==========================================================================
   Collapsible accordion
   ========================================================================== */
.accordion {
  border: 1px solid var(--border-base);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-md);
  overflow: hidden;
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-input);
  cursor: pointer;
  user-select: none;
  transition: background var(--t-fast);
}

.accordion-header:hover { background: var(--bg-card-hover); }

.accordion-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.accordion-arrow {
  color: var(--text-muted);
  font-size: 0.6rem;
  transition: transform var(--t-fast);
}

.accordion.open .accordion-arrow { transform: rotate(180deg); }

.accordion-body {
  display: none;
  padding: var(--sp-md);
  border-top: 1px solid var(--border-base);
  background: rgba(14,13,15,0.5);
}

.accordion.open .accordion-body { display: block; }

/* ==========================================================================
   LEFT PANEL — bottom buttons row
   ========================================================================== */
.panel-actions {
  padding: var(--sp-md) var(--sp-lg);
  border-top: 1px solid var(--border-base);
  display: flex;
  gap: var(--sp-sm);
  flex-shrink: 0;
  background: rgba(14,13,15,0.6);
}

/* ==========================================================================
   CENTER PANEL — Canvas area
   ========================================================================== */
.canvas-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
}

.canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 60% at 50% 50%, rgba(136,58,237,0.04) 0%, transparent 70%),
    repeating-conic-gradient(rgba(255,255,255,0.02) 0% 25%, transparent 0% 50%) 0 0 / 20px 20px;
}

#mainCanvas {
  border-radius: var(--r-md);
  box-shadow: 0 0 40px rgba(34,255,0,0.06), 0 20px 60px rgba(0,0,0,0.5);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: box-shadow var(--t-std);
  border: 1px solid var(--border-base);
}

#mainCanvas.active {
  box-shadow: 0 0 30px rgba(34,255,0,0.15), 0 20px 60px rgba(0,0,0,0.6);
  border-color: rgba(34,255,0,0.3);
}

/* Loading overlay */
.canvas-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-lg);
  background: rgba(14,13,15,0.88);
  backdrop-filter: blur(6px);
  border-radius: var(--r-md);
  z-index: 10;
  display: none;
}

.canvas-loading.visible { display: flex; }

.spinner {
  width: 52px;
  height: 52px;
  border: 3px solid rgba(136,58,237,0.2);
  border-top-color: var(--violet);
  border-right-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  font-family: var(--font-head);
  font-size: 0.85rem;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
}

.loading-subtext {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  max-width: 200px;
}

/* Drop zone hint */
.canvas-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-md);
  pointer-events: none;
}

.canvas-empty-icon {
  font-size: 3rem;
  opacity: 0.2;
  filter: grayscale(1);
}

.canvas-empty-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.canvas-empty-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.6;
}

/* Drop zone active state */
.canvas-wrapper.drag-over::after {
  content: 'Suelta para cargar imagen';
  position: absolute;
  inset: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--blue);
  border: 2px dashed var(--blue);
  border-radius: var(--r-lg);
  background: rgba(34,255,0,0.05);
  pointer-events: none;
  z-index: 20;
  font-family: var(--font-head);
  font-weight: 600;
}

/* ==========================================================================
   Playback controls
   ========================================================================== */
.playback-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-lg);
  background: var(--bg-card);
  border-top: 1px solid var(--border-base);
  flex-shrink: 0;
}

.playback-btns {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pb-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: var(--bg-input);
  border: 1px solid var(--border-base);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.75rem;
  transition: all var(--t-fast);
}

.pb-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.pb-btn.active {
  background: rgba(34,255,0,0.1);
  border-color: var(--blue);
  color: var(--blue);
  box-shadow: 0 0 8px rgba(34,255,0,0.2);
}

.pb-play {
  width: 36px;
  height: 36px;
  background: var(--grad-primary);
  border-radius: 50%;
  color: #fff;
  border: none;
  font-size: 0.8rem;
  box-shadow: 0 2px 10px rgba(136,58,237,0.4);
}

.pb-play:hover {
  transform: scale(1.1);
  box-shadow: var(--glow-violet);
}

.pb-sep {
  width: 1px;
  height: 20px;
  background: var(--border-base);
  margin: 0 4px;
}

.pb-fps-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.pb-fps-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pb-fps-slider {
  width: 80px;
  height: 3px;
}

.pb-fps-val {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-accent);
  min-width: 28px;
}

.pb-frame-counter {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: auto;
}

.pb-frame-counter span {
  color: var(--text-primary);
  font-weight: 600;
}

/* Frame action buttons in playback */
.canvas-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-lg);
  border-top: 1px solid var(--border-base);
  background: rgba(14,13,15,0.5);
  flex-shrink: 0;
}

/* ==========================================================================
   Frame timeline strip
   ========================================================================== */
.timeline-strip {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px var(--sp-lg);
  overflow-x: auto;
  background: var(--bg-deep);
  border-top: 1px solid var(--border-base);
  flex-shrink: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-base) transparent;
}

.timeline-strip::-webkit-scrollbar { height: 3px; }
.timeline-strip::-webkit-scrollbar-track { background: transparent; }
.timeline-strip::-webkit-scrollbar-thumb { background: var(--border-base); border-radius: 2px; }

.timeline-frame {
  width: 48px;
  height: 48px;
  border-radius: var(--r-sm);
  border: 2px solid var(--border-base);
  cursor: pointer;
  flex-shrink: 0;
  overflow: hidden;
  transition: all var(--t-fast);
  position: relative;
  background: var(--bg-card);
  image-rendering: pixelated;
}

.timeline-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.timeline-frame:hover {
  border-color: var(--border-hover);
  transform: scale(1.08);
}

.timeline-frame.current {
  border-color: var(--blue);
  box-shadow: 0 0 10px rgba(34,255,0,0.4);
}

.timeline-frame .frame-num {
  position: absolute;
  bottom: 1px;
  right: 2px;
  font-family: var(--font-mono);
  font-size: 0.5rem;
  color: rgba(255,255,255,0.6);
  line-height: 1;
}

/* Descarga individual de un frame: aparece al pasar el mouse por encima
   de la miniatura, para no ensuciar el timeline. En táctil se queda fijo. */
.timeline-frame .frame-dl {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: rgba(0,0,0,0.72);
  color: #fff;
  font-size: 0.62rem;
  line-height: 16px;
  text-align: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s ease, background .12s ease;
}

.timeline-frame:hover .frame-dl,
.timeline-frame .frame-dl:focus-visible {
  opacity: 1;
}

.timeline-frame .frame-dl:hover {
  background: var(--accent, #55ff00);
  color: #0d0d0e;
}

@media (hover: none) {
  .timeline-frame .frame-dl { opacity: .85; }
}

.timeline-empty {
  font-size: 0.75rem;
  color: var(--text-muted);
  width: 100%;
  text-align: center;
}

/* ==========================================================================
   RIGHT PANEL — Sheet builder + export
   ========================================================================== */
.sheet-config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}

.sheet-config-grid .form-group { margin-bottom: 0; }

/* Frame count display */
.frame-count-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-base);
  border-radius: var(--r-sm);
  margin-bottom: var(--sp-md);
}

.frame-count-num {
  font-family: var(--font-head);
  font-size: 1.4rem;
  font-weight: 700;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.frame-count-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Transparent background toggle */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}

.toggle-row label {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.toggle {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--bg-input);
  border: 1px solid var(--border-base);
  border-radius: 20px;
  cursor: pointer;
  transition: all var(--t-fast);
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--t-fast);
}

.toggle input:checked + .toggle-track {
  background: rgba(34,255,0,0.15);
  border-color: var(--blue);
}

.toggle input:checked + .toggle-track::after {
  left: 18px;
  background: var(--blue);
  box-shadow: 0 0 6px rgba(34,255,0,0.6);
}

/* Export format chips */
.export-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-md);
}

.export-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-base);
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--t-fast);
  user-select: none;
}

.export-chip:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.export-chip.selected {
  background: rgba(136,58,237,0.15);
  border-color: var(--violet);
  color: #bffdb5;
  box-shadow: 0 0 10px rgba(136,58,237,0.2);
}

.chip-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--t-fast);
}

.export-chip.selected .chip-dot { background: var(--violet); box-shadow: 0 0 6px rgba(136,58,237,0.8); }

/* ==========================================================================
   Animation presets accordion
   ========================================================================== */
.preset-group-title {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--sp-sm);
  margin-top: var(--sp-md);
}

.preset-group-title:first-child { margin-top: 0; }

.preset-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: var(--sp-sm);
}

.preset-tag {
  padding: 3px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-base);
  border-radius: 100px;
  font-size: 0.65rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
}

.preset-tag:hover {
  border-color: var(--violet);
  color: #bffdb5;
  background: rgba(136,58,237,0.08);
}

.preset-tag.active {
  background: rgba(136,58,237,0.15);
  border-color: var(--violet);
  color: #bffdb5;
}

/* ==========================================================================
   BOTTOM — Session gallery
   ========================================================================== */
.gallery-section {
  border-top: 1px solid var(--border-base);
  background: var(--bg-card);
  flex-shrink: 0;
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-sm) var(--sp-xl);
  border-bottom: 1px solid var(--border-base);
}

.gallery-title {
  font-family: var(--font-head);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.gallery-strip {
  display: flex;
  gap: var(--sp-sm);
  padding: var(--sp-sm) var(--sp-xl);
  overflow-x: auto;
  height: 100px;
  align-items: center;
  scrollbar-width: thin;
  scrollbar-color: var(--border-base) transparent;
}

.gallery-strip::-webkit-scrollbar { height: 3px; }
.gallery-strip::-webkit-scrollbar-track { background: transparent; }
.gallery-strip::-webkit-scrollbar-thumb { background: var(--border-base); border-radius: 2px; }

.gallery-empty {
  font-size: 0.78rem;
  color: var(--text-muted);
  width: 100%;
  text-align: center;
  font-style: italic;
}

.gallery-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  width: 72px;
  cursor: pointer;
}

.gallery-thumb {
  width: 64px;
  height: 64px;
  border-radius: var(--r-sm);
  border: 2px solid var(--border-base);
  overflow: hidden;
  background: var(--bg-input);
  transition: all var(--t-fast);
  position: relative;
  image-rendering: pixelated;
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gallery-thumb:hover {
  border-color: var(--border-hover);
  box-shadow: 0 0 12px rgba(34,255,0,0.2);
}

.gallery-thumb-actions {
  position: absolute;
  inset: 0;
  background: rgba(14,13,15,0.8);
  display: none;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: var(--r-sm);
}

.gallery-card:hover .gallery-thumb-actions { display: flex; }

.gallery-action-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 3px;
  transition: color var(--t-fast), transform var(--t-fast);
}

.gallery-action-btn:hover { color: var(--blue); transform: scale(1.2); }

.gallery-ts {
  font-size: 0.55rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1;
}

/* ==========================================================================
   Toast notifications
   ========================================================================== */
#toast-container {
  position: fixed;
  top: 66px;
  right: var(--sp-lg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 0.82rem;
  font-weight: 500;
  max-width: 340px;
  pointer-events: all;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-sm);
  animation: toast-in 0.3s var(--ease);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}

.toast.removing { animation: toast-out 0.3s var(--ease) forwards; }

@keyframes toast-in {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes toast-out {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(120%); opacity: 0; }
}

.toast-success {
  background: rgba(39,185,16,0.15);
  border: 1px solid rgba(39,185,16,0.4);
  color: #7cea6b;
}

.toast-error {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.4);
  color: #fca5a5;
}

.toast-info {
  background: rgba(34,255,0,0.1);
  border: 1px solid rgba(34,255,0,0.3);
  color: #8efc7d;
}

.toast-warn {
  background: rgba(89,245,11,0.12);
  border: 1px solid rgba(89,245,11,0.35);
  color: #87fc4d;
}

.toast-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; line-height: 1.4; }
.toast-close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  padding: 0 2px;
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: opacity var(--t-fast);
}
.toast-close:hover { opacity: 1; }

/* ==========================================================================
   Setup/API key modal
   ========================================================================== */
.setup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,9,11,0.95);
  backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-xl);
  display: none;
}

.setup-overlay.visible { display: flex; }

.setup-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-base);
  border-radius: var(--r-xl);
  padding: var(--sp-2xl);
  max-width: 520px;
  width: 100%;
  box-shadow: 0 40px 80px rgba(0,0,0,0.6), 0 0 60px rgba(136,58,237,0.1);
}

.setup-logo {
  font-family: var(--font-head);
  font-size: 2rem;
  font-weight: 700;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: var(--sp-sm);
  display: block;
}

.setup-modal h2 {
  font-family: var(--font-head);
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: var(--sp-sm);
}

.setup-modal p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
  margin-bottom: var(--sp-lg);
}

.setup-steps {
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  margin-bottom: var(--sp-xl);
}

.setup-step {
  display: flex;
  gap: var(--sp-md);
  align-items: flex-start;
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--grad-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.step-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding-top: 3px;
  line-height: 1.5;
}

.step-text a {
  color: var(--blue);
  text-decoration: none;
}
.step-text a:hover { text-decoration: underline; }

.step-text code {
  font-family: var(--font-mono);
  background: var(--bg-input);
  border: 1px solid var(--border-base);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.78rem;
  color: var(--pink);
}

.setup-modal .btn-primary {
  width: 100%;
  padding: 12px;
}

/* ==========================================================================
   Utility classes
   ========================================================================== */
.hidden   { display: none !important; }
.mt-sm    { margin-top: var(--sp-sm); }
.mt-md    { margin-top: var(--sp-md); }
.mt-lg    { margin-top: var(--sp-lg); }
.mb-sm    { margin-bottom: var(--sp-sm); }
.mb-md    { margin-bottom: var(--sp-md); }
.gap-sm   { gap: var(--sp-sm); }
.flex     { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full   { width: 100%; }
.text-muted  { color: var(--text-muted); }
.text-accent { color: var(--text-accent); }
.text-mono   { font-family: var(--font-mono); }
.text-sm     { font-size: 0.78rem; }
.text-xs     { font-size: 0.68rem; }
.font-bold   { font-weight: 700; }

/* Divider */
.divider {
  height: 1px;
  background: var(--border-base);
  margin: var(--sp-md) 0;
}

/* Glow text */
.glow-text {
  text-shadow: 0 0 12px currentColor;
}

/* Dot separator */
.dot-sep {
  color: var(--text-muted);
  margin: 0 4px;
}

/* Scroll hint */
.scroll-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
  padding: 4px;
  opacity: 0.6;
}

/* Section label */
.section-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--sp-sm);
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-base);
}

/* Color picker + transparent row */
.color-row {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

/* ==========================================================================
   Responsive adjustments
   ========================================================================== */
@media (max-width: 1100px) {
  .main-layout {
    grid-template-columns: 260px 1fr 240px;
  }
}

@media (max-width: 900px) {
  .main-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    height: auto;
  }

  .header-shortcuts { display: none; }
}

/* Subtle pulse on frame counter when frame changes */
@keyframes counter-flash {
  0%   { color: var(--blue); }
  100% { color: var(--text-muted); }
}

.counter-flash { animation: counter-flash 0.4s ease-out; }

/* Progress bar for export */
.progress-bar-wrap {
  width: 100%;
  height: 3px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
  margin-top: var(--sp-sm);
}

.progress-bar-fill {
  height: 100%;
  background: var(--grad-primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ==========================================================================
   Base Character (img2img) section
   ========================================================================== */
.base-char-zone {
  border: 2px dashed var(--border-base);
  border-radius: var(--r-md);
  background: var(--bg-input);
  cursor: pointer;
  transition: border-color var(--t-std), background var(--t-std);
  position: relative;
  min-height: 80px;
  overflow: hidden;
}
.base-char-zone:hover, .base-char-zone.drag-over {
  border-color: var(--blue);
  background: rgba(34,255,0,0.05);
}
.base-char-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 12px;
  text-align: center;
}
.base-char-icon { font-size: 22px; line-height: 1; }
.base-char-hint { font-size: 11px; color: var(--text-muted); }
.base-char-preview {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px;
}
.base-char-preview img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  image-rendering: pixelated;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-active);
  background: repeating-conic-gradient(#19171c 0% 25%, #18161a 0% 50%) 0 0 / 12px 12px;
}
.base-char-clear {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--red);
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: opacity var(--t-fast);
}
.base-char-clear:hover { opacity: 0.8; }
.base-char-label {
  font-size: 10px;
  color: var(--green);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-img2img {
  background: linear-gradient(135deg, #27b910, #22ff00);
  color: #000;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 6px rgba(39,185,16,0.4); }
  50%       { box-shadow: 0 0 14px rgba(39,185,16,0.8); }
}
