:root {
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #334155;
  --text-light: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-hover: #0284c7;
  --border-color: #334155;
}

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

body {
  font-family: "Poppins", sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-light);
  min-height: 100vh;
  padding: 24px;
}

.meme-studio-container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.studio-header {
  text-align: center;
}

.studio-header h1 {
  font-size: 1.8rem;
  color: var(--accent);
}

.studio-header p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.studio-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
}

@media (max-width: 850px) {
  .studio-workspace {
    grid-template-columns: 1fr;
  }
}

.controls-card,
.preview-card,
.presets-section {
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
}

.controls-card h2,
.preview-card h2,
.presets-section h2 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: var(--accent);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.form-group input[type="text"],
.form-group input[type="file"] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-light);
  padding: 10px;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
}

.form-group input[type="text"]:focus,
.form-group input[type="file"]:focus {
  border-color: var(--accent);
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(70px, 0.75fr) minmax(
      70px,
      0.75fr
    );
  gap: 12px;
  align-items: end;
}

.flex-1 {
  min-width: 0;
}

.form-row .form-group {
  margin-bottom: 14px;
}

.form-row input[type="range"] {
  width: 100%;
}

.form-row input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 3px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.btn {
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 6px;
  border: none;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #0f172a;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: white;
}

.btn-secondary {
  background: #6366f1;
  color: white;
}

.btn-secondary:hover {
  background: #4f46e5;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
}

.btn-outline:hover {
  background: rgba(56, 189, 248, 0.1);
}

.canvas-wrapper {
  width: 100%;
  min-height: 300px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}

#memeCanvas {
  max-width: 100%;
  max-height: 600px;
  height: auto;
  display: block;
}

.presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.preset-card {
  background: var(--bg-input);
  border-radius: 6px;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.preset-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
}

.preset-info strong,
.preset-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

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

/* Error Container */
.error-container {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 8px;
  padding: 10px 12px;
  color: #ef4444;
  font-size: 0.8rem;
  margin-top: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.4;
}

.error-container .error-icon {
  flex-shrink: 0;
}

@media (max-width: 600px) {
  body {
    padding: 14px;
  }

  .meme-studio-container {
    gap: 16px;
  }

  .controls-card,
  .preview-card,
  .presets-section {
    padding: 16px;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

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

  .canvas-wrapper {
    min-height: 220px;
  }
}

@media (min-width: 601px) and (max-width: 950px) {
  .actions-grid {
    grid-template-columns: 1fr;
  }
}
