/* ============================================
   StitchPixel — Design System & Styles
   Inspired by dontboardme.com — warm, cute, playful
   ============================================ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Fredoka:wght@400;500;600;700&display=swap');

/* ── CSS Variables (Design Tokens) ── */
:root {
  /* Colors — Warm & Cozy (Kawaii Style) */
  --cream: #FFF8F0;
  --cream-dark: #F5F0E8;
  --blush: #F2D1CC;
  --blush-deep: #E8B4AE;
  --coral: #FF6B6B;
  /* Brighter, happier coral */
  --coral-dark: #FF5252;
  --coral-light: #FF8A76;
  --lavender: #D4C5F9;
  --lavender-light: #EDE7FB;
  --mint: #B8E8D0;
  --mint-light: #E0F5EA;
  --peach: #FFD4B8;
  --yellow-soft: #FFF3C4;
  --text-dark: #4A4A4A;
  /* Softer black */
  --text-medium: #7D6B6B;
  --text-light: #A59696;
  --white: #FFFFFF;

  --shadow-soft: rgba(255, 107, 107, 0.15);
  /* Tinted shadow */
  --shadow-medium: rgba(255, 107, 107, 0.25);

  --peach: #FFD4B8;
  --yellow-soft: #FFF3C4;
  --text-dark: #4A4A4A;
  /* Softer black */
  --text-medium: #7D6B6B;
  --text-light: #A59696;
  --white: #FFFFFF;

  --shadow-soft: rgba(255, 107, 107, 0.15);
  /* Tinted shadow */
  --shadow-medium: rgba(255, 107, 107, 0.25);

  /* Gradient accents - Muted & Elegant */
  --gradient-hero: linear-gradient(135deg, #F5F2EB 0%, #EBE6DC 100%);
  --gradient-glow: radial-gradient(circle at 50% 50%, rgba(199, 107, 88, 0.08) 0%, transparent 70%);
  --gradient-border: linear-gradient(135deg, #C76B58, #A8B7C2);

  /* Typography */
  --font-heading: 'ZCOOL KuaiLe', 'Balsamiq Sans', cursive;
  --font-body: 'Balsamiq Sans', 'ZCOOL KuaiLe', sans-serif;

  /* Spacing - Hand-crafted feel */
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --radius-xl: 40px;
  --radius-full: 9999px;

  /* Transitions */
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-jelly: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --duration-fast: 0.2s;
  --duration-normal: 0.35s;
  --duration-slow: 0.6s;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  color: var(--text-dark);
  background: var(--cream);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
  overflow-x: hidden;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--cream-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--blush-deep);
  border-radius: var(--radius-full);
}

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

/* ── Navigation ── */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 16px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 248, 240, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(242, 209, 204, 0.4);
  transition: all var(--duration-normal) var(--ease-smooth);
}

.nav.scrolled {
  padding: 10px 40px;
  box-shadow: 0 4px 30px var(--shadow-soft);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon {
  width: 38px;
  height: 38px;
}

.logo-text {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--coral-dark);
  letter-spacing: -0.5px;
}

.logo-text span {
  color: var(--lavender);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 32px;
  list-style: none;
}

.nav-links a {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  text-transform: uppercase;
  color: var(--text-medium);
  text-decoration: none;
  letter-spacing: 0.5px;
  position: relative;
  transition: color var(--duration-fast);
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2.5px;
  background: var(--coral);
  border-radius: var(--radius-full);
  transition: width var(--duration-normal) var(--ease-bounce);
}

.nav-links a:hover {
  color: var(--coral);
}

.nav-links a:hover::after {
  width: 100%;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-switch-container {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--cream-dark);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  color: var(--text-medium);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s var(--ease-bounce);
  white-space: nowrap;
}

.lang-btn .lang-icon {
  font-size: 1.1rem;
}

.lang-btn:hover {
  background: var(--cream);
  color: var(--coral);
  transform: translateY(-1px);
}

#font-btn {
  padding: 8px;
}

#font-btn .lang-icon {
  margin: 0;
}

.lang-btn:active {
  transform: translateY(1px) scale(0.98);
}

.btn-lang {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 8px 18px;
  border: 2px solid var(--blush-deep);
  background: transparent;
  color: var(--text-medium);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth);
}

.btn-lang:hover {
  background: var(--blush);
  color: var(--coral-dark);
  border-color: var(--coral);
}

/* ── Buttons ── */
.btn-primary {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.2rem;
  /* Larger for XiaoWei */
  padding: 12px 36px;
  background: var(--coral);
  color: var(--white);
  border: 2px dashed rgba(255, 255, 255, 0.6);
  /* Stitch effect */
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-bounce);
  box-shadow: 0 4px 0 rgba(232, 97, 77, 0.3);
  /* Flat shadow */
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.btn-primary:hover {
  background: var(--coral-dark);
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 30px rgba(232, 97, 77, 0.4);
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:active {
  transform: scale(0.95);
  animation: jelly 0.5s;
}

/* Pulse animation for CTA */
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.4);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(255, 107, 107, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(255, 107, 107, 0);
  }
}

.btn-primary.pulse {
  animation: pulse 2s infinite;
}

@keyframes jelly {

  0%,
  100% {
    transform: scale(1, 1);
  }

  25% {
    transform: scale(0.9, 1.1);
  }

  50% {
    transform: scale(1.1, 0.9);
  }

  75% {
    transform: scale(0.95, 1.05);
  }
}

.btn-secondary {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 24px;
  background: var(--white);
  color: var(--coral);
  border: 2px solid var(--coral);
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth);
}

.btn-secondary:hover {
  background: var(--coral);
  color: var(--white);
}

.btn-icon {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--cream-dark);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--text-medium);
  transition: all var(--duration-fast);
}

.btn-icon:hover {
  background: var(--blush);
  color: var(--coral);
  transform: scale(1.1);
}

/* ── Hero Section ── */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--gradient-hero);
  position: relative;
  overflow: hidden;
  padding: 120px 40px 80px;
}

.hero::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: var(--gradient-glow);
  top: 10%;
  left: -5%;
  animation: float 8s ease-in-out infinite;
}

.hero::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 197, 249, 0.15) 0%, transparent 70%);
  bottom: 10%;
  right: -5%;
  animation: float 10s ease-in-out infinite reverse;
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 800px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--coral);
  margin-bottom: 24px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(232, 97, 77, 0.15);
}

.hero h1 {
  font-family: var(--font-heading);
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 800;
  line-height: 1.1;
  color: var(--coral-dark);
  margin-bottom: 20px;
  letter-spacing: -1px;
}

.hero-subtitle {
  font-size: clamp(1rem, 2vw, 1.3rem);
  color: var(--text-medium);
  margin-bottom: 40px;
  font-weight: 500;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.hero-tags {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 32px;
  flex-wrap: wrap;
}

.hero-tag {
  padding: 8px 20px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-medium);
  border: 1px solid rgba(242, 209, 204, 0.5);
  backdrop-filter: blur(10px);
}

/* Pixel decoration */
.pixel-decoration {
  position: absolute;
  z-index: 1;
  opacity: 0.4;
}

.pixel-grid-deco {
  display: grid;
  gap: 4px;
}

.pixel-cell {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  animation: pixelFade 3s ease-in-out infinite;
}

.pixel-deco-1 {
  top: 15%;
  left: 5%;
  grid-template-columns: repeat(4, 16px);
  transform: rotate(-12deg);
}

.pixel-deco-2 {
  bottom: 20%;
  right: 8%;
  grid-template-columns: repeat(3, 16px);
  transform: rotate(8deg);
}

.pixel-deco-3 {
  top: 40%;
  right: 3%;
  grid-template-columns: repeat(5, 16px);
  transform: rotate(-5deg);
}

/* ── How It Works Section ── */
.how-section {
  padding: 100px 40px;
  background: var(--white);
  position: relative;
}

.section-header {
  text-align: center;
  margin-bottom: 64px;
}

.section-header h2 {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  color: var(--coral-dark);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.steps-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px;
  max-width: 1100px;
  margin: 0 auto;
}

.step-card {
  text-align: center;
  padding: 40px 24px;
  background: var(--cream);
  border-radius: var(--radius-lg);
  position: relative;
  transition: all var(--duration-normal) var(--ease-bounce);
  border: 2px solid transparent;
}

.step-card:hover {
  transform: translateY(-8px);
  border-color: var(--blush);
  box-shadow: 0 12px 40px var(--shadow-soft);
}

.step-number {
  width: 56px;
  height: 56px;
  background: var(--coral);
  color: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.3rem;
  margin: 0 auto 20px;
  box-shadow: 0 4px 15px rgba(232, 97, 77, 0.3);
}

.step-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
  display: block;
}

.step-card h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-dark);
  margin-bottom: 8px;
}

.step-card p {
  color: var(--text-light);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Step connector arrows */
.step-card:not(:last-child)::after {
  content: '→';
  position: absolute;
  right: -24px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.5rem;
  color: var(--blush-deep);
  font-weight: 700;
}

/* ── Workspace Section ── */
.workspace-section {
  padding: 80px 40px 100px;
  background: var(--cream-dark);
  min-height: 80vh;
}

.workspace-header {
  text-align: center;
  margin-bottom: 48px;
}

.workspace-header h2 {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 3.5vw, 2.5rem);
  font-weight: 700;
  color: var(--coral-dark);
}

.workspace-grid {
  display: grid;
  grid-template-columns: 300px 1fr 300px;
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  min-height: 550px;
}

/* Upload Panel */
.upload-panel {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 4px 20px var(--shadow-soft);
  display: flex;
  flex-direction: column;
}

.panel-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--coral-dark);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.upload-zone {
  flex: 1;
  border: 3px dashed var(--blush);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-smooth);
  background: var(--cream);
  min-height: 200px;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--coral);
  background: rgba(232, 97, 77, 0.04);
  transform: scale(1.01);
}

.upload-zone.has-image {
  border-style: solid;
  border-color: var(--blush-deep);
  padding: 8px;
}

.upload-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  color: var(--blush-deep);
}

.upload-hint {
  font-size: 0.95rem;
  color: var(--text-medium);
  margin-bottom: 8px;
  font-weight: 600;
}

.upload-support {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 16px;
}

.upload-btn {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 24px;
  background: var(--coral);
  color: var(--white);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.upload-btn:hover {
  background: var(--coral-dark);
  transform: scale(1.05);
}

.upload-preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

/* Preview Panel (center) */
.preview-panel {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 4px 20px var(--shadow-soft);
  display: flex;
  flex-direction: column;
  position: relative;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.preview-tools {
  display: flex;
  gap: 6px;
}

.preview-canvas-container {
  flex: 1;
  position: relative;
  background: var(--cream);
  border-radius: var(--radius-md);
  overflow: hidden;
  min-height: 400px;
}

#preview-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

.preview-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-light);
}

.preview-empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* Control Panel (right side) */
.control-panel {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 4px 20px var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  max-height: 650px;
}

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

.control-label {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-medium);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.control-value {
  font-weight: 700;
  color: var(--coral);
  float: right;
}

/* Range Slider */
.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--cream-dark);
  border-radius: var(--radius-full);
  outline: none;
  transition: background var(--duration-fast);
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--coral);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(232, 97, 77, 0.4);
  transition: transform var(--duration-fast) var(--ease-bounce);
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Select */
.control-select {
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 10px 14px;
  border: 2px solid var(--cream-dark);
  border-radius: var(--radius-sm);
  background: var(--cream);
  color: var(--text-dark);
  cursor: pointer;
  transition: border-color var(--duration-fast);
  outline: none;
}

.control-select:focus {
  border-color: var(--coral);
}

/* Toggle */
.toggle-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--cream-dark);
  border-radius: var(--radius-full);
  transition: background var(--duration-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: var(--white);
  border-radius: 50%;
  transition: transform var(--duration-fast) var(--ease-bounce);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.toggle-switch input:checked+.toggle-slider {
  background: var(--coral);
}

.toggle-switch input:checked+.toggle-slider::before {
  transform: translateX(22px);
}

/* Palette Swatches */
.palette-container {
  max-height: 120px;
  overflow-y: auto;
  border-radius: var(--radius-sm);
  padding: 8px;
  background: var(--cream);
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}

.palette-swatch {
  aspect-ratio: 1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: transform var(--duration-fast);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.palette-swatch:hover {
  transform: scale(1.15);
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.swatch-label {
  font-size: 0.5rem;
  font-weight: 700;
}

.palette-free-msg {
  text-align: center;
  color: var(--text-light);
  font-size: 0.85rem;
  padding: 12px;
}

/* Pixelate button */
.pixelate-btn {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  padding: 14px;
  background: var(--coral);
  color: var(--white);
  border: none;
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-bounce);
  box-shadow: 0 4px 20px rgba(232, 97, 77, 0.3);
  width: 100%;
}

.pixelate-btn:hover {
  background: var(--coral-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(232, 97, 77, 0.4);
}

.pixelate-btn:disabled {
  background: var(--blush);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Export buttons */
.export-group {
  display: flex;
  gap: 8px;
}

.export-btn {
  flex: 1;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 10px 12px;
  border: 2px solid var(--coral);
  background: transparent;
  color: var(--coral);
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.export-btn:hover {
  background: var(--coral);
  color: var(--white);
}

.export-btn:disabled {
  border-color: var(--blush);
  color: var(--blush);
  cursor: not-allowed;
}

.export-btn:disabled:hover {
  background: transparent;
  color: var(--blush);
}

/* ── Color Legend Panel ── */
.legend-section {
  padding: 60px 40px 80px;
  background: var(--white);
  display: none;
}

.legend-section.visible {
  display: block;
}

.legend-table-container {
  max-width: 900px;
  margin: 0 auto;
  margin-top: 32px;
}

.legend-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 4px;
}

.legend-table th {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-light);
  padding: 8px 16px;
  text-align: left;
  letter-spacing: 0.5px;
}

.legend-table td {
  padding: 8px 16px;
  background: var(--cream);
  font-size: 0.9rem;
}

.legend-table tr td:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.legend-table tr td:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.legend-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-block;
  vertical-align: middle;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* ── Footer ── */
.footer {
  padding: 48px 40px;
  background: var(--coral-dark);
  color: var(--white);
  text-align: center;
}

.footer-content {
  max-width: 600px;
  margin: 0 auto;
}

.footer-logo {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.footer-logo span {
  opacity: 0.7;
}

.footer-text {
  font-size: 0.9rem;
  opacity: 0.8;
  margin-bottom: 4px;
}

.footer-made {
  font-size: 0.8rem;
  opacity: 0.6;
}

/* ── Animations ── */
@keyframes float {

  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-20px) scale(1.05);
  }
}

@keyframes pixelFade {

  0%,
  100% {
    opacity: 0.3;
  }

  50% {
    opacity: 0.8;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }

  50% {
    opacity: 1;
    transform: scale(1.05);
  }

  70% {
    transform: scale(0.95);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-40px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(40px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Scroll-triggered animations */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: all var(--duration-slow) var(--ease-smooth);
}

.animate-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

.hero-content {
  animation: fadeInUp 0.8s var(--ease-smooth) 0.2s both;
}

.step-card:nth-child(1) {
  animation: fadeInUp 0.6s var(--ease-smooth) 0.1s both;
}

.step-card:nth-child(2) {
  animation: fadeInUp 0.6s var(--ease-smooth) 0.25s both;
}

.step-card:nth-child(3) {
  animation: fadeInUp 0.6s var(--ease-smooth) 0.4s both;
}

.step-card:nth-child(4) {
  animation: fadeInUp 0.6s var(--ease-smooth) 0.55s both;
}

/* ── Loading Spinner ── */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--blush);
  border-top-color: var(--coral);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}

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

/* ── Mobile Menu ── */
.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 8px;
  background: none;
  border: none;
}

.nav-hamburger span {
  width: 24px;
  height: 2.5px;
  background: var(--coral-dark);
  border-radius: var(--radius-full);
  transition: all var(--duration-normal);
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .workspace-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .preview-canvas-container {
    min-height: 350px;
  }

  .control-panel {
    max-height: none;
  }

  .steps-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
  }

  .step-card::after {
    display: none;
  }
}

@media (max-width: 768px) {
  .nav {
    padding: 12px 20px;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(255, 248, 240, 0.97);
    backdrop-filter: blur(20px);
    flex-direction: column;
    padding: 20px;
    gap: 16px;
    border-bottom: 1px solid var(--blush);
  }

  .nav-links.open {
    display: flex;
  }

  .nav-hamburger {
    display: flex;
  }

  .hero {
    padding: 100px 20px 60px;
  }

  .hero h1 {
    font-size: clamp(2rem, 8vw, 3rem);
  }

  .how-section,
  .workspace-section {
    padding: 60px 20px;
  }

  .steps-container {
    grid-template-columns: 1fr;
    max-width: 400px;
  }

  .step-card::after {
    display: none;
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .preview-canvas-container {
    min-height: 300px;
  }

  .footer {
    padding: 32px 20px;
  }
}

/* ── Font Settings Modal ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  visibility: hidden;
  opacity: 0;
  transition: all var(--duration-normal) var(--ease-smooth);
}

.modal:not(.hidden) {
  visibility: visible;
  opacity: 1;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(42, 42, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: -1;
}

.modal-content {
  background: var(--cream);
  padding: 40px;
  border-radius: var(--radius-lg);
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  border: 3px dashed var(--coral);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  transform: translateY(20px);
  transition: transform var(--duration-normal) var(--ease-smooth);
}

.modal:not(.hidden) .modal-content {
  transform: translateY(0);
}

.close-modal {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
  transition: color var(--duration-fast);
}

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

.font-group {
  margin-bottom: 32px;
}

.font-group:last-child {
  margin-bottom: 0;
}

.font-group h3 {
  font-size: 1.2rem;
  margin-bottom: 16px;
  color: var(--coral);
  font-family: var(--font-heading);
}

.font-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.font-opt {
  padding: 12px;
  border: 2px solid var(--cream-dark);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--text-dark);
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.3s var(--ease-bounce);
  text-align: center;
}

.font-opt:hover {
  border-color: var(--coral-light);
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(232, 97, 77, 0.1);
}

.font-opt.active {
  border-color: var(--coral);
  background: var(--cream);
  box-shadow: 0 0 0 3px rgba(232, 97, 77, 0.15);
  font-weight: 600;
}