/* ========== GENERAL ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #0007B6;
  --primary-dark: #0005A0;
  --secondary: #10b981;
  --text-dark: #111827;
  --text-light: #6b7280;
  --border: #e5e7eb;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #0007B6 0%, #0007B6 100%);
  min-height: 100vh;
  color: var(--text-dark);
  line-height: 1.6;
}

/* ========== ANIMATIONS ========== */
@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
  60% { transform: translateY(-5px); }
}

@keyframes floatIdle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes floatHover {
  0%, 100% { transform: translateY(-6px) scale(1.03); }
  50% { transform: translateY(-8px) scale(1.04); }
}

/* ========== BACKGROUND IMAGE ========== */
body.index-page,
body.editor-page {
  background-image: url('images/background2.webp');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  background-repeat: no-repeat;
}

/* ========== HEADER WITH CENTERED TITLE ========== */
header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 1rem 2rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-centered {
  display: grid !important;
  grid-template-columns: 200px 1fr 200px;
}

.logo-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  font-size: 2rem;
  color: var(--primary);
}

.logo-left img {
  width: 70px;
  height: 70px;
  border-radius: 10px;
  object-fit: cover;
}

.logo-left span {
  display: inline-block;
  font-weight: 800;
  background: linear-gradient(270deg, #0007B6, #667eea, #764ba2, #0007B6);
  background-size: 400% 400%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 3s ease infinite;
  text-shadow: 0 0 10px rgba(0, 20, 255, 0.25);
  letter-spacing: 1px;
  transition: transform 0.3s ease, filter 0.3s ease;
}

.logo-left span:hover {
  transform: scale(1.05);
  filter: brightness(1.3);
}

header nav {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

header nav a {
  color: var(--text-dark);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s;
  padding: 0.5rem 1rem;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  top: 0.8px;
  font-size: 1.1rem;
  text-decoration: none;
  transition: color 0.3s ease;
}

.back-btn:hover {
  color: var(--primary) !important;
}

/* ========== GRADIENT ANIMATED BUTTON ========== */
.gradient-animate {
  background: linear-gradient(270deg, #0007B6, #667eea, #764ba2, #0007B6);
  background-size: 400% 400%;
  color: white !important;
  padding: 1rem 2rem;
  border-radius: 25px;
  animation: gradientShift 3s ease infinite;
  transition: transform 0.3s;
  font-size: 1.2rem;
}

.gradient-animate:hover {
  transform: translateY(-2px) scale(1.05);
}

/* ========== HERO ========== */
.hero {
  text-align: center;
  padding: 2rem 2rem 1.5rem;
  color: rgb(255, 255, 255);
}

.hero h1 {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  text-shadow: 2px 2px 8px rgba(0,0,0,0.5);
}

.hero p {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  opacity: 0.95;
  text-shadow: 1px 1px 4px rgba(0,0,0,0.5);
}

.cta {
  font-size: 1.1rem;
  font-weight: 600;
  animation: bounce 2s infinite;
}

/* ========== GALLERY ========== */
.gallery {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  background: white;
  border-radius: 20px;
  box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
}

.gallery h2 {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 2rem;
  color: var(--text-dark);
}

.templates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
}

.templates a {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 14px;
  overflow: hidden;
  transition: all 0.4s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  padding: 0;
  border: none;
  animation: floatIdle 6s ease-in-out infinite;
}

.templates a:hover {
  transform: translateY(-6px) scale(1.03);
  background: linear-gradient(270deg, #0007B6, #667eea, #764ba2, #0007B6);
  background-size: 400% 400%;
  animation: gradientShift 3s ease infinite, floatHover 1.2s ease-in-out infinite;
  box-shadow: 0 0 20px rgba(0, 123, 255, 0.4), 0 0 40px rgba(118, 75, 162, 0.3);
}

.templates img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
  transition: transform 0.4s ease, filter 0.4s ease;
}

.templates a:hover img {
  filter: brightness(1.1);
  transform: scale(1.05);
}

/* Пропорції шаблонів */
.template.square {
  aspect-ratio: 1 / 1;
}

.template.wide {
  aspect-ratio: 16 / 9;
}

.template.vertical {
  aspect-ratio: 3 / 4;
}

/* ========== UPLOAD BOX ========== */
.upload-template {
  background: linear-gradient(270deg, #0007B6, #667eea, #764ba2, #0007B6);
  background-size: 400% 400%;
  animation: gradientShift 3s ease infinite;
  border-radius: 20px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 20px rgba(0, 50, 255, 0.25);
  backdrop-filter: blur(8px);
  color: white;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
  padding: 1rem;
}

.upload-template:hover {
  transform: translateY(-5px) scale(1.03);
  box-shadow: 0 0 25px rgba(0, 120, 255, 0.6);
}

.upload-icon {
  font-size: 3rem;
  color: #FFD54F;
  filter: drop-shadow(0 0 10px rgba(255, 213, 79, 0.8));
  margin-bottom: 0.5rem;
  transition: transform 0.3s ease;
}

.upload-template:hover .upload-icon {
  transform: translateY(-4px) scale(1.1);
}

.upload-text {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.4;
  color: #fff;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
}

/* ========== FOOTER ========== */
.footer-enhanced {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  margin-top: 5rem;
  border-radius: 0 0 20px 20px;
  box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.05);
}

.footer-content {
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.footer-subtitle {
  font-size: 1.25rem;
  font-weight: 600;
  background: linear-gradient(135deg, #1DA1F2, #764ba2, #ff7e5f, #1DA1F2);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 12px rgba(29,161,242,0.3);
  letter-spacing: 1px;
  margin-bottom: 1.2rem;
  animation: gradientShift 6s ease infinite;
}

.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.footer-copyright {
  font-size: 1.05rem;
  font-weight: 600;
  background: linear-gradient(135deg, #1DA1F2, #764ba2, #ff7e5f, #1DA1F2);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 15px rgba(118,75,162,0.35);
  letter-spacing: 0.5px;
  margin-top: 1rem;
  animation: gradientShift 7s linear infinite;
}

/* ========== TWITTER TAGS ========== */
.twitter-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 200px;
  height: 50px;
  border-radius: 40px;
  font-weight: 600;
  font-size: 1.1rem;
  color: rgb(0, 0, 0);
  text-decoration: none;
  background: linear-gradient(135deg, rgba(0, 153, 255, 0.3), rgba(255, 255, 255, 0.05));
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(15px);
  box-shadow: 0 4px 25px rgba(0, 153, 255, 0.25);
  transition: all 0.3s ease;
  padding: 0;
}

.twitter-tag:hover {
  transform: translateY(-3px) scale(1.05);
  background: linear-gradient(135deg, rgba(0,153,255,0.85), rgba(0,255,200,0.55));
  box-shadow: 0 0 25px rgba(0,200,255,0.8), 0 0 50px rgba(0,150,255,0.6);
  border-color: rgba(255,255,255,0.4);
}

.twitter-tag.blue:hover {
  background: linear-gradient(135deg, rgba(0,180,255,0.9), rgba(0,255,255,0.6));
  box-shadow: 0 0 25px rgba(0,200,255,0.8);
}

.twitter-tag.purple:hover {
  background: linear-gradient(135deg, rgba(150,80,255,0.9), rgba(255,100,255,0.6));
  box-shadow: 0 0 25px rgba(200,100,255,0.8);
}

.twitter-tag.orange:hover {
  background: linear-gradient(135deg, rgba(255,100,70,0.9), rgba(255,200,100,0.7));
  box-shadow: 0 0 25px rgba(255,150,100,0.8);
}

/* ========== EDITOR ========== */
.editor-container {
  display: flex;
  gap: 2rem;
  max-width: 1400px;
  margin: 2rem auto;
  padding: 2rem;
  background: white;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.editor-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#memeCanvas {
  border: 3px solid var(--border);
  border-radius: 12px;
  cursor: crosshair;
  max-width: 100%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* ========== CONTROL PANELS ========== */
.editor-right-compact {
  width: 350px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  padding-right: 8px;
}

.control-panel,
.control-panel-compact {
  background: #f9fafb;
  padding: 1rem;
  border-radius: 12px;
  border: 2px solid var(--border);
}

.control-panel h3,
.control-panel-compact h3 {
  margin-bottom: 0.75rem;
  color: var(--primary);
  font-size: 1rem;
}

.control-panel-tips {
  background: #fef3c7;
  padding: 1rem;
  border-radius: 12px;
  border: 2px solid #fbbf24;
}

.control-panel-tips h3 {
  color: #92400e;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.control-panel-tips ul {
  padding-left: 1.2rem;
  color: #78350f;
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 0;
}

.control-panel-tips ul li {
  margin-bottom: 0.25rem;
}

.control-group-compact {
  margin-bottom: 0.5rem;
}

.control-group-compact label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
  font-size: 0.85rem;
}

.control-group-compact input,
.control-group-compact select,
.control-group-compact textarea {
  width: 100%;
  padding: 0.5rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
}

.control-group-compact textarea {
  resize: vertical;
  min-height: 60px;
}

.control-group-compact input[type="color"] {
  height: 40px;
  cursor: pointer;
}

.control-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.checkbox-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* ========== CUSTOM OCTOPUS SLIDER ========== */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: linear-gradient(100deg, #0007B6 0%, #667eea 100%);
  border-radius: 10px;
  outline: none;
  cursor: pointer;
  margin: 8px 0;
  transition: background 0.3s ease;
}

input[type="range"]:hover {
  background: linear-gradient(90deg, #667eea 0%, #0007B6 100%);
}

input[type="range"].active {
  background: linear-gradient(90deg, #764ba2 0%, #0007B6 100%);
}

/* Chrome / Edge / Safari */
input[type="range"]::-webkit-slider-runnable-track {
  width: calc(100% + 32px);
  margin-left: -16px;
  margin-right: -16px;
  height: 8px;
  border-radius: 10px;
  background: transparent;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 40px;
  height: 40px;
  background: url('images/octopus.png') center/contain no-repeat;
  border: none;
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 4px 8px rgba(0, 7, 182, 0.4);
  transition: transform 0.2s ease;
  margin-top: -16px;
}

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

input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(1.05);
  cursor: grabbing;
}

/* Firefox */
input[type="range"]::-moz-range-track {
  width: 100%;
  height: 8px;
  border-radius: 10px;
  background: linear-gradient(90deg, #0007B6 0%, #667eea 100%);
}

input[type="range"]::-moz-range-thumb {
  width: 40px;
  height: 40px;
  background: url('images/octopus.png') center/contain no-repeat;
  border: none;
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 4px 8px rgba(0, 7, 182, 0.4);
  transition: transform 0.2s ease;
}

input[type="range"]::-moz-range-progress {
  background: linear-gradient(90deg, #0007B6 0%, #667eea 100%);
  border-radius: 10px;
}

/* IE/Edge legacy */
input[type="range"]::-ms-track {
  width: 100%;
  height: 8px;
  background: transparent;
  border-color: transparent;
  color: transparent;
}

input[type="range"]::-ms-thumb {
  width: 40px;
  height: 40px;
  background: url('images/octopus.png') center/contain no-repeat;
  border: none;
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 4px 8px rgba(0, 7, 182, 0.4);
}

/* ========== BUTTONS ========== */
.btn {
  padding: 0.9rem 2rem;
  border: none;
  border-radius: 40px;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: all 0.35s ease;
  backdrop-filter: blur(20px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  border: 1px solid rgba(255,255,255,0.25);
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #7c3aed 100%);
  box-shadow: 0 4px 20px rgba(59,130,246,0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #5a8bff 0%, #a45bff 100%);
  box-shadow: 0 0 25px rgba(110,100,255,0.8);
  transform: translateY(-3px) scale(1.03);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
  box-shadow: 0 4px 20px rgba(16,185,129,0.35);
}

.btn-success:hover {
  background: linear-gradient(135deg, #00ffb2 0%, #0ed182 100%);
  box-shadow: 0 0 25px rgba(0,255,180,0.8);
  transform: translateY(-3px) scale(1.03);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #f87171 100%);
  box-shadow: 0 4px 20px rgba(239,68,68,0.35);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #ff6b6b 0%, #ff8787 100%);
  box-shadow: 0 0 25px rgba(255,100,100,0.8);
  transform: translateY(-3px) scale(1.03);
}

.btn-group {
  display: flex;
  gap: 0.5rem;
}

.btn-full {
  width: 100%;
}

/* ========== TEXT LIST ========== */
#textsList {
  overflow-y: auto;
}

.text-item {
  background: white;
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.3s;
}

.text-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 7, 182, 0.2);
}

.text-item.active {
  border-color: var(--primary);
  background: #f0f4ff;
}

.text-preview {
  font-weight: 500;
  color: var(--text-dark);
  word-break: break-word;
  font-size: 0.9rem;
}

/* ========== TITLE CENTER ========== */
.title-center {
  text-align: center;
  font-weight: 900;
  font-size: 2.5rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  background: linear-gradient(270deg, #0007B6, #667eea, #764ba2, #0007B6);
  background-size: 400% 400%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 3s ease infinite;
}

/* ========== TOAST ========== */
#toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #ef4444;
  color: white;
  padding: 1rem 2rem;
  border-radius: 10px;
  font-size: 1.2rem;
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 9999;
  pointer-events: none;
}

.toast-show {
  opacity: 1;
  pointer-events: auto;
}

.toast-hidden {
  opacity: 0;
  pointer-events: none;
}
/* ========== NEON BUTTON (ONLY FOR "SOON") ========== */
.neon-button {
  background: linear-gradient(135deg, #0007B6, #667eea);
  color: white !important;
  padding: 0.9rem 2rem;
  border-radius: 50px;
  border: none;
  transition: all 0.3s ease;
  font-size: 1.1rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
}

.neon-button:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 4px 15px rgba(0, 7, 182, 0.3);
}

/* ========== SOON PAGE ========== */
.soon-page {
  background: linear-gradient(135deg, #ffffff, #dff3ff, #a8ccff, #6aa8ff);
  background-size: 300% 300%;
  animation: blueFlow 5s ease infinite;
  color: #000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  text-align: center;
  font-family: 'Segoe UI', sans-serif;
}

.soon-container {
  text-align: center;
}

/* Робимо відео більшим і красивим */
.soon-container video {
  width: 400px; /* змінюй під розмір */
  max-width: 90vw;
  border-radius: 16px;
  margin: 1.2rem 0;
  box-shadow: 0 0 20px rgba(0, 120, 255, 0.4);
}

/* Градієнт для заголовка */
.soon-page h1 {
  font-size: 2.8rem;
  margin-bottom: 1rem;
  background: linear-gradient(90deg, #007bff, #00aaff, #0055ff);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradientShift 6s ease infinite;
}

.soon-page p {
  font-size: 1.25rem;
  opacity: 0.9;
  color: #1a1a1a;
}

/* Анімація руху фону */
@keyframes blueFlow {
  0% { background-position: 0% 0%; }
  50% { background-position: 100% 100%; }
  100% { background-position: 0% 0%; }
}

@keyframes dots {
  0%, 20% { content: ""; }
  40% { content: "."; }
  60% { content: ".."; }
  80%, 100% { content: "..."; }
}

.loading-text {
  font-size: 1.2rem;
  font-weight: 500;
  color: #222;
}

.dots::after {
  content: "";
  animation: dots 1.5s steps(4, end) infinite;
}

/* ========== ІДЕАЛЬНА МОБІЛЬНА АДАПТАЦІЯ ========== */

/* Приховуємо мобільні елементи на ПК */
#mobileControlsToggle,
.mobile-controls-header {
  display: none;
}

/* ПЛАНШЕТИ ТА ВЕЛИКІ ТЕЛЕФОНИ (до 1024px) */
@media (max-width: 1024px) {
  
  /* === ГОЛОВНА СТОРІНКА === */
  .hero h1 { 
    font-size: 2rem; 
    padding: 0 1rem;
  }
  
  .hero p { 
    font-size: 1rem; 
    padding: 0 1rem;
  }
  
  .gallery { 
    padding: 1rem; 
    border-radius: 16px;
    margin: 1rem;
  }
  
  .templates { 
    grid-template-columns: repeat(2, 1fr) !important; 
    gap: 1rem;
  }
  
  .upload-template { 
    padding: 1.5rem; 
  }
  
  .upload-icon { 
    font-size: 3rem; 
  }

  /* === РЕДАКТОР - МОБІЛЬНИЙ РЕЖИМ === */
  .editor-container {
    flex-direction: column;
    padding: 0.5rem;
    margin: 0.5rem;
    gap: 0;
    position: relative;
  }

  .editor-left {
    width: 100%;
    padding: 0;
    position: relative;
  }

  /* Канвас - на весь екран */
  #memeCanvas {
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    border-radius: 12px;
    margin: 0 auto;
    display: block;
  }

  /* Кнопки Download/Share - зверху канвасу */
  .editor-left .btn-group {
    position: static !important;
    margin: 1rem 0 !important;
    width: 100% !important;
    display: flex;
    gap: 0.5rem;
    transform: none !important;
    background: none !important;
    padding: 0 !important;
  }

  .editor-left .btn-group .btn {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }

  /* === МОБІЛЬНА ПАНЕЛЬ РЕДАГУВАННЯ === */
  
  /* Кнопка відкриття панелі */
  #mobileControlsToggle {
    display: block;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #0007B6, #667eea);
    color: white;
    padding: 1rem 2.5rem;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 0 10px 30px rgba(0, 7, 182, 0.5);
    z-index: 2000;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
  }

  #mobileControlsToggle:active {
    transform: translateX(-50%) scale(0.95);
  }

  /* Панель редагування - висувається знизу */
  .editor-right-compact {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 75vh;
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.3);
    z-index: 3000;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    padding: 1.5rem 1rem;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* Відкрита панель */
  .editor-right-compact.open {
    transform: translateY(0);
  }

  /* Хедер мобільної панелі */
  .mobile-controls-header {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 1rem;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
  }

  .mobile-controls-header h3 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--primary);
    font-weight: 700;
  }

  #closeMobileControls {
    background: #f3f4f6;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 2rem;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
  }

  #closeMobileControls:active {
    background: #e5e7eb;
    transform: scale(0.9);
  }

  /* Контент панелі */
  .control-panel,
  .control-panel-compact {
    margin-bottom: 1rem;
  }

  .control-group-compact {
    margin-bottom: 0.75rem;
  }

  .control-group-compact label {
    font-size: 0.95rem;
    font-weight: 600;
  }

  .control-group-compact input,
  .control-group-compact select,
  .control-group-compact textarea {
    padding: 0.75rem;
    font-size: 1rem;
    border-radius: 10px;
  }

  /* Слайдери - більші для зручності */
  input[type="range"] {
    height: 12px;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 50px;
    height: 50px;
    margin-top: -19px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 50px;
    height: 50px;
  }
}

/* СЕРЕДНІ ТЕЛЕФОНИ (до 768px) */
@media (max-width: 768px) {
  
  /* === ХЕДЕР === */
  header {
    grid-template-columns: 1fr !important;
    text-align: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }

  .header-centered {
    grid-template-columns: 1fr !important;
  }

  .logo-left {
    justify-content: center;
    font-size: 1.5rem;
    gap: 0.5rem;
  }

  .logo-left img {
    width: 50px;
    height: 50px;
  }

  .logo-left span {
    font-size: 1.3rem;
  }

  .title-center {
    font-size: 1.4rem !important;
    line-height: 1.3;
    letter-spacing: 1px;
    text-align: center;
    margin: 0;
  }

  header nav {
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  header nav a {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
  }

  .gradient-animate,
  .neon-button {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
  }

  .back-btn {
    font-size: 0.9rem;
  }

  /* === ФУТЕР === */
  .footer-content {
    padding: 1.5rem 1rem;
  }

  .footer-links {
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
  }

  .twitter-tag {
    width: 100%;
    max-width: 280px;
    font-size: 1rem;
    height: 48px;
  }

  .footer-subtitle {
    font-size: 1.1rem;
  }

  .footer-copyright {
    font-size: 0.95rem;
  }

  /* === ГАЛЕРЕЯ === */
  .templates {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem;
  }

  .gallery h2 {
    font-size: 1.5rem;
  }
}

/* МАЛІ ТЕЛЕФОНИ (до 480px) */
@media (max-width: 480px) {
  
  /* === ХЕДЕР - КОМПАКТНИЙ === */
  header {
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
  }

  .logo-left {
    gap: 0.4rem;
  }

  .logo-left img {
    width: 40px;
    height: 40px;
  }

  .logo-left span {
    font-size: 1.1rem;
    letter-spacing: 0.5px;
  }

  .title-center {
    font-size: 1rem !important;
    letter-spacing: 0.5px;
    line-height: 1.2;
  }

  header nav {
    gap: 0.4rem;
  }

  header nav a {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 20px;
  }

  .gradient-animate,
  .neon-button {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
  }

  .back-btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }

  /* === ГОЛОВНА === */
  .hero h1 {
    font-size: 1.75rem;
  }

  .hero p {
    font-size: 0.95rem;
  }

  .cta {
    font-size: 1rem;
  }

  .gallery {
    padding: 0.75rem;
    margin: 0.5rem;
  }

  .gallery h2 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
  }

  .templates {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem;
  }

  .upload-icon {
    font-size: 2.5rem;
  }

  .upload-text {
    font-size: 0.95rem;
  }

  /* === РЕДАКТОР === */
  .editor-container {
    padding: 0.25rem;
    margin: 0.25rem;
  }

  #mobileControlsToggle {
    padding: 0.85rem 2rem;
    font-size: 1rem;
    bottom: 15px;
  }

  .mobile-controls-header h3 {
    font-size: 1.2rem;
  }

  #closeMobileControls {
    width: 36px;
    height: 36px;
    font-size: 1.75rem;
  }

  .control-group-compact label {
    font-size: 0.9rem;
  }

  .control-group-compact input,
  .control-group-compact select,
  .control-group-compact textarea {
    font-size: 0.95rem;
    padding: 0.65rem;
  }

  .btn {
    padding: 0.7rem 1.2rem;
    font-size: 0.9rem;
  }

  /* === ФУТЕР === */
  .footer-content {
    padding: 1.25rem 0.75rem;
  }

  .footer-subtitle {
    font-size: 1rem;
    margin-bottom: 0.75rem;
  }

  .twitter-tag {
    max-width: 260px;
    font-size: 0.95rem;
    height: 44px;
  }

  .footer-copyright {
    font-size: 0.85rem;
    margin-top: 0.75rem;
  }
}

/* ДУЖЕ МАЛІ ЕКРАНИ (до 360px) */
@media (max-width: 360px) {
  
  .logo-left img {
    width: 36px;
    height: 36px;
  }

  .logo-left span {
    font-size: 1rem;
  }

  .title-center {
    font-size: 0.9rem !important;
  }

  header nav a {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .gallery h2 {
    font-size: 1.2rem;
  }

  #mobileControlsToggle {
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
  }
}

/* Z-INDEX FIX - щоб кнопка була над усім */
@media (max-width: 1024px) {
  #mobileControlsToggle {
    z-index: 2000 !important;
  }

  .editor-right-compact {
    z-index: 3000 !important;
  }

  .editor-right-compact.open {
    z-index: 3000 !important;
  }

  canvas#memeCanvas {
    position: relative;
    z-index: 1;
  }

  footer {
    position: relative;
    z-index: 0;
  }

  header {
    z-index: 100;
  }
}

/* ЛАНДШАФТНА ОРІЄНТАЦІЯ НА МОБІЛЬНИХ */
@media (max-width: 1024px) and (orientation: landscape) {
  .editor-right-compact {
    max-height: 85vh;
  }

  #memeCanvas {
    max-height: 60vh;
  }
}

/* SMOOTH SCROLLING ДЛЯ МОБІЛЬНОЇ ПАНЕЛІ */
.editor-right-compact {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* PREVENT BOUNCE SCROLL */
.editor-right-compact.open {
  overscroll-behavior: contain;
}