/* MemeForge Styles - CSS Custom Properties Design System */
/* Following SPEC-ENHANCED.md */

:root {
  /* Base surfaces */
  --bg-primary: #0A0A0F;
  --bg-secondary: #1A1A2E;
  --bg-card: #12121A;
  --bg-overlay: rgba(0, 0, 0, 0.75);

  /* Text hierarchy - WCAG AAA compliant */
  --text-primary: #FAFAFA;
  --text-secondary: #A0A0B0;
  --text-muted: #6B6B7B;

  /* Neon Accents - used sparingly per accessibility rules */
  --accent-cyan: #00D4FF;
  --accent-cyan-hover: #33DDFF;
  --accent-cyan-active: #00AACC;
  --accent-pink: #FF6B9D;
  --accent-warning: #FFB800;
  --pro-badge: #00D4FF;

  /* Functional */
  --error: #FF4444;
  --success: #10B981;

  /* Borders */
  --color-border: #2A2A3E;
  --color-border-hover: #3A3A4E;

  /* Focus ring for accessibility */
  --color-ring: #00D4FF;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(0, 212, 255, 0.3);

  /* Font stacks */
  --font-ui: 'Poppins', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-meme: Impact, 'Arial Black', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* Type scale */
  --font-size-xs: 11px;
  --font-size-sm: 13px;
  --font-size-base: 15px;
  --font-size-lg: 18px;
  --font-size-xl: 24px;
  --font-size-2xl: 32px;

  /* Line heights */
  --line-height-tight: 1.2;
  --line-height-base: 1.5;
  --line-height-relaxed: 1.75;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Timing */
  --duration-fast: 50ms;
  --duration-normal: 100ms;
  --duration-slow: 150ms;
  --duration-slower: 200ms;
  --duration-fade-in: 300ms;

  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
  --ease-in: cubic-bezier(0.32, 0, 0.67, 0);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Z-index scale */
  --z-base: 0;
  --z-gallery: 10;
  --z-header: 40;
  --z-overlay: 50;
  --z-editor: 60;
  --z-modal: 70;
  --z-toast: 100;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* Subtle grain texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* Custom scrollbar for dark theme */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-border-hover);
}

/* Custom text selection */
::selection {
  background: rgba(0, 212, 255, 0.3);
  color: var(--text-primary);
}

/* Ensure touch targets are large enough */
button, input, select, textarea {
  min-height: 44px;
  font-family: inherit;
  font-size: inherit;
}

/* Skip Link - Accessibility */
.skip-link {
  position: absolute;
  top: -50px;
  left: var(--space-4);
  background: var(--accent-cyan);
  color: #000;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-weight: 600;
  z-index: 1000;
  transition: top var(--duration-slow) var(--ease-out);
}

.skip-link:focus {
  top: var(--space-4);
  outline: none;
}

/* ============ NAVBAR ============ */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--color-border);
  z-index: var(--z-header);
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--text-primary);
}

.logo-icon {
  width: 28px;
  height: 28px;
  color: var(--accent-cyan);
}

.logo-text {
  font-family: 'Bangers', Impact, sans-serif;
  font-size: 26px;
  letter-spacing: 0.05em;
  color: var(--accent-cyan);
  transform: translateY(2px);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.search-wrapper {
  position: relative;
}

.search-input {
  width: 200px;
  padding: var(--space-2) var(--space-4);
  padding-left: 36px;
  background: var(--bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  transition: border-color var(--duration-slow) var(--ease-out);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.pro-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: transparent;
  border: 2px solid var(--pro-badge);
  border-radius: var(--radius-md);
  color: var(--pro-badge);
  font-size: var(--font-size-sm);
  font-weight: 700;
  cursor: pointer;
  transition: all var(--duration-slow) var(--ease-out);
}

.pro-btn svg {
  width: 14px;
  height: 14px;
}

.pro-btn:hover {
  background: var(--pro-badge);
  color: #000;
}

/* ============ CATEGORY TABS ============ */
.category-tabs {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--color-border);
  z-index: var(--z-header);
  padding: var(--space-3) 0;
}

.tabs-scroll {
  display: flex;
  gap: var(--space-2);
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-6);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tabs-scroll::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  flex-shrink: 0;
  padding: var(--space-2) var(--space-4);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--duration-slow) var(--ease-out);
}

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

.tab-btn.active {
  color: var(--accent-cyan);
  background: rgba(0, 212, 255, 0.1);
  font-weight: 600;
  position: relative;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: var(--accent-cyan);
  border-radius: 1px;
}

.tab-btn:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}

/* ============ MAIN CONTENT ============ */
.main-content {
  padding-top: 130px;
  padding-bottom: 80px;
  min-height: 100vh;
}

.gallery-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  min-height: 200px;
}

@media (max-width: 480px) {
  .navbar-inner {
    padding: 0 var(--space-4);
  }

  .search-input {
    width: 140px;
    font-size: var(--font-size-base);
  }

  .pro-btn span {
    display: none;
  }

  .tabs-scroll {
    padding: 0 var(--space-4);
  }

  .gallery-section {
    padding: 0 var(--space-4);
  }

  .editor-container {
    margin: 0;
    border-radius: 0;
    min-height: 100vh;
  }

  .editor-body {
    padding: var(--space-4);
  }
}

@media (min-width: 640px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-5);
  }
}

@media (min-width: 1440px) {
  .gallery-section {
    max-width: 1100px;
  }
}

/* Template Card */
.template-card {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1;
  transition: transform var(--duration-slow) var(--ease-out),
              box-shadow var(--duration-slow) var(--ease-out);
  animation: fadeSlideUp var(--duration-fade-in) var(--ease-out) forwards;
  opacity: 0;
  will-change: transform;
  border: 1px solid transparent;
}

.template-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  border-color: rgba(0, 212, 255, 0.15);
}

.template-card:active {
  transform: translateY(-2px) scale(0.97);
  transition-duration: var(--duration-fast);
}

.template-card:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}

.template-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-slower) var(--ease-out);
}

.template-card:hover .template-card-img {
  transform: scale(1.08);
}

.template-card-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-4) var(--space-3) var(--space-3);
  background: linear-gradient(transparent 0%, rgba(0, 0, 0, 0.85) 60%);
  transition: padding var(--duration-slow) var(--ease-out);
}

.template-card:hover .template-card-info {
  padding-bottom: var(--space-4);
}

.template-card-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  line-height: var(--line-height-tight);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.template-card-category {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

/* Gallery fade transition */
@keyframes galleryIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.gallery-grid:not([hidden]) {
  animation: galleryIn 200ms var(--ease-out);
}

/* Pro locked overlay */
.template-card.locked {
  pointer-events: none;
}

.template-card.locked::after {
  content: '';
  position: absolute;
  inset: 0;
  backdrop-filter: blur(4px);
  background: rgba(0, 0, 0, 0.5);
}

.template-card.locked .pro-badge {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 32px;
  height: 32px;
  background: var(--pro-badge);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.4);
  animation: pulseGlow 2s ease-in-out infinite;
}

.template-card.locked .pro-badge svg {
  width: 16px;
  height: 16px;
  color: #000;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 12px rgba(0, 212, 255, 0.4); }
  50% { box-shadow: 0 0 20px rgba(0, 212, 255, 0.7); }
}

/* Upload card */
.template-card.upload-card {
  border: 2px dashed var(--color-border);
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  color: var(--text-secondary);
  transition: all var(--duration-slow) var(--ease-out);
  cursor: pointer;
}

.template-card.upload-card:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  background: rgba(0, 212, 255, 0.03);
  box-shadow: 0 0 30px rgba(0, 212, 255, 0.08);
  transform: translateY(-2px);
}

.template-card.upload-card:active {
  transform: translateY(0) scale(0.97);
}

.template-card.upload-card:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}

.template-card.upload-card svg {
  width: 36px;
  height: 36px;
  opacity: 0.6;
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}

.template-card.upload-card:hover svg {
  opacity: 1;
  transform: translateY(-4px);
}

.template-card.upload-card span {
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Empty state */
.gallery-empty {
  text-align: center;
  padding: var(--space-8);
  color: var(--text-secondary);
}

.gallery-empty svg {
  width: 64px;
  height: 64px;
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.gallery-empty p {
  margin-bottom: var(--space-2);
}

.empty-hint {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

/* ============ EDITOR OVERLAY ============ */
.editor-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: var(--z-editor);
  overflow-y: auto;
  animation: fadeIn var(--duration-slower) var(--ease-out);
}

.editor-container {
  max-width: 1000px;
  margin: var(--space-6) auto;
  background: var(--bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: slideUp var(--duration-slower) var(--ease-out);
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-6);
  background: var(--bg-card);
  border-bottom: 1px solid var(--color-border);
}

.editor-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
}

.editor-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.editor-x-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--duration-slow) var(--ease-out);
}

.editor-x-close:hover {
  color: var(--text-primary);
  background: rgba(255, 68, 68, 0.1);
  border-color: rgba(255, 68, 68, 0.3);
}

.editor-x-close:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}

.editor-x-close svg {
  width: 18px;
  height: 18px;
}

.editor-back {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-slow) var(--ease-out);
}

.editor-back:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.editor-back svg {
  width: 18px;
  height: 18px;
}

.editor-title {
  font-family: 'Bangers', Impact, sans-serif;
  font-size: 22px;
  letter-spacing: 0.03em;
  color: var(--text-primary);
  transform: translateY(1px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.download-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  background: var(--accent-cyan);
  color: #000;
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  font-weight: 700;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-slow) var(--ease-out);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.download-btn:hover {
  background: var(--accent-cyan-hover);
  transform: scale(1.02);
}

.download-btn:active {
  background: var(--accent-cyan-active);
  transform: scale(0.98);
  transition-duration: var(--duration-fast);
}

.download-btn:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}

.download-btn svg {
  width: 18px;
  height: 18px;
}

.download-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.download-btn.success {
  background: var(--success);
}

.editor-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  padding: var(--space-6);
}

@media (min-width: 768px) {
  .editor-body {
    grid-template-columns: 1fr 320px;
  }
}

/* Meme Preview */
.meme-preview-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  min-height: 300px;
  border: 1px solid var(--color-border);
  position: relative;
}

.meme-preview-wrapper::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), transparent 50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-slow) var(--ease-out);
}

.meme-preview-wrapper:focus-within::after {
  opacity: 1;
}

.meme-preview {
  max-width: 100%;
  max-height: 400px;
  position: relative;
  z-index: 1;
}

.meme-preview canvas {
  max-width: 100%;
  max-height: 400px;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Editor Controls */
.editor-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.editor-controls .control-group label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.control-group label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.control-row {
  display: flex;
  gap: var(--space-4);
}

.control-group.half {
  flex: 1;
}

.text-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-card);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: var(--font-size-base);
  transition: border-color var(--duration-slow) var(--ease-out),
              box-shadow var(--duration-slow) var(--ease-out);
}

.text-input::placeholder {
  color: var(--text-muted);
}

.text-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15), 0 0 12px rgba(0, 212, 255, 0.08);
}

.text-input:focus-visible {
  outline: none;
}

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

.font-color-toggle {
  display: flex;
  gap: var(--space-2);
}

.color-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--bg-card);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-slow) var(--ease-out);
}

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

.color-btn.active {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.color-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
}

.color-swatch.white {
  background: #FFF;
}

.color-swatch.black {
  background: #000;
}

.slider-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.slider-input {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  cursor: pointer;
}

.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent-cyan);
  border: 3px solid var(--bg-secondary);
  border-radius: 50%;
  cursor: grab;
  transition: transform var(--duration-fast) var(--ease-out);
}

.slider-input::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.1);
}

.slider-input:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 4px;
}

.slider-value {
  min-width: 40px;
  font-size: var(--font-size-sm);
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent-cyan);
  font-weight: 500;
}

.select-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-card);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: var(--font-size-base);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A0A0B0' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

.select-input:hover {
  border-color: var(--color-border-hover);
}

.select-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15);
}

.pro-features {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.pro-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--pro-badge);
}

.pro-label svg {
  width: 14px;
  height: 14px;
}

.pro-feature-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all var(--duration-slow) var(--ease-out);
}

.pro-feature-btn:hover {
  border-color: var(--pro-badge);
  color: var(--text-primary);
}

.pro-feature-btn svg {
  width: 16px;
  height: 16px;
  color: var(--pro-badge);
}

.pro-feature-btn.locked {
  opacity: 0.6;
  pointer-events: none;
}

.pro-feature-btn.locked::after {
  content: 'PRO';
  margin-left: auto;
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--pro-badge);
}

.copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-4);
  background: transparent;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: var(--font-size-base);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-slow) var(--ease-out);
}

.copy-btn:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

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

/* ============ PRO MODAL ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  animation: fadeIn var(--duration-slow) var(--ease-out);
}

/* Force hidden to beat display:flex — UA [hidden] rule has no !important in spec */
.modal-overlay[hidden] {
  display: none !important;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  max-width: 400px;
  width: 100%;
  padding: var(--space-8);
  position: relative;
  animation: modalIn var(--duration-slower) var(--ease-out);
}

.modal-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  padding: var(--space-2);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--duration-slow);
}

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

.modal-close svg {
  width: 20px;
  height: 20px;
}

.modal-header {
  text-align: center;
  margin-bottom: var(--space-6);
}

.pro-icon {
  width: 48px;
  height: 48px;
  color: var(--pro-badge);
  margin-bottom: var(--space-4);
}

.modal-header h2 {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
}

.modal-body p {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: var(--space-6);
}

.pro-benefits {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.benefit {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

.benefit svg {
  width: 18px;
  height: 18px;
  color: var(--success);
  flex-shrink: 0;
}

.unlock-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.unlock-form label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.unlock-btn {
  padding: var(--space-4);
  background: var(--accent-cyan);
  color: #000;
  font-family: var(--font-ui);
  font-size: var(--font-size-base);
  font-weight: 700;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-slow) var(--ease-out);
}

.unlock-btn:hover {
  background: var(--accent-cyan-hover);
}

/* Buy Now button in Pro modal */
.buy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4);
  background: var(--accent-cyan);
  color: #000;
  font-family: var(--font-ui);
  font-size: var(--font-size-base);
  font-weight: 700;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--duration-slow) var(--ease-out);
}

.buy-btn:hover {
  background: var(--accent-cyan-hover);
}

.toggle-unlock {
  display: block;
  width: 100%;
  margin-top: var(--space-3);
  padding: var(--space-2);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: var(--font-size-sm);
  cursor: pointer;
  text-decoration: underline;
}

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

.existing-unlock {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

/* ============ TOAST ============ */
.toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: 360px;
  padding: var(--space-4) var(--space-5);
  background: var(--bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: toastSlideIn var(--duration-slower) var(--ease-out);
  backdrop-filter: blur(8px);
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--error);
}

.toast.info {
  border-left: 4px solid var(--accent-cyan);
}

.toast-message {
  flex: 1;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

.toast-close {
  padding: var(--space-1);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

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

.toast-close svg {
  width: 16px;
  height: 16px;
}

/* ============ FOOTER AD ============ */
.footer-ad {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-3) var(--space-6);
  background: var(--bg-secondary);
  border-top: 1px solid var(--color-border);
  text-align: center;
  z-index: var(--z-base);
}

.ad-placeholder {
  display: inline-block;
  background: var(--bg-card);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.footer-ad.hidden {
  display: none;
}

/* Hide ad for pro users via JS adding .hidden to #footer-ad */

/* ============ ANIMATIONS ============ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Stagger animation for template cards */
.template-card:nth-child(1) { animation-delay: 0ms; }
.template-card:nth-child(2) { animation-delay: 50ms; }
.template-card:nth-child(3) { animation-delay: 100ms; }
.template-card:nth-child(4) { animation-delay: 150ms; }
.template-card:nth-child(5) { animation-delay: 200ms; }
.template-card:nth-child(6) { animation-delay: 250ms; }
.template-card:nth-child(7) { animation-delay: 300ms; }
.template-card:nth-child(8) { animation-delay: 350ms; }
.template-card:nth-child(9) { animation-delay: 400ms; }
.template-card:nth-child(10) { animation-delay: 450ms; }

/* ============ REDUCED MOTION ============ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 150ms !important;
  }

  .template-card {
    opacity: 1;
  }
}

/* ============ PRINT STYLES (hide UI) ============ */
@media print {
  .navbar,
  .category-tabs,
  .editor-overlay,
  .footer-ad,
  .toast-container {
    display: none !important;
  }
}