* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  color: #1a1a1a;
  background: linear-gradient(135deg, #667aea 0%, #764ba2 100%);
  min-height: 100vh;
}

.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
}

header {
  text-align: center;
  color: rgb(255, 255, 255);
  margin-bottom: 32px;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 0 8px 0;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

header p {
  font-size: 1.1rem;
  margin: 0;
  opacity: 0.95;
}

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.controls-panel {
  background: #ffffff;
  padding: 24px;
  overflow-y: auto;
  max-height: calc(100vh - 200px);
  border-right: 1px solid #e0e0e0;
}

.control-section {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 2px solid #e0e0e0;
}

.control-section:last-child {
  border-bottom: none;
}

.control-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 16px 0;
  color: #436b33;
}

.collapsible-header {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 24px;
  transition: color 0.2s;
}

.collapsible-header:hover {
  color: #5c8f47;
}

.collapsible-header::after {
  content: '▼';
  position: absolute;
  right: 0;
  font-size: 0.8rem;
  transition: transform 0.3s;
}

.collapsible-header.collapsed::after {
  transform: rotate(-90deg);
}

.collapsible-content {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  max-height: 2000px;
  opacity: 1;
}

.collapsible-content.collapsed {
  max-height: 0;
  opacity: 0;
}

.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: #555;
}

.input-group input[type='text'],
.input-group textarea,
.input-group select {
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.95rem;
}

.input-group select {
  cursor: pointer;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: white;
}

.input-group input[type='text']:focus,
.input-group textarea:focus {
  outline: none;
}

.input-group textarea {
  resize: vertical;
  min-height: 80px;
}

input[type='file'] {
  width: 100%;
  padding: 10px;
  border: 2px dashed #667eea;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 0.9rem;
  margin-bottom: 12px;
  transition: all 0.2s;
}

input[type='file']:hover {
  border-color: #764ba2;
  background: #f8f9fa;
}

.slider-control {
  margin-bottom: 16px;
}

.slider-control label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: #555;
}

.slider-control span {
  color: #667eea;
  font-weight: 600;
}

input[type='range'] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #e0e0e0;
  outline: none;
  -webkit-appearance: none;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #667eea;
  cursor: pointer;
  transition: all 0.2s;
}

input[type='range']::-webkit-slider-thumb:hover {
  background: #764ba2;
  transform: scale(1.2);
}

input[type='range']::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #667eea;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

input[type='range']::-moz-range-thumb:hover {
  background: #764ba2;
  transform: scale(1.2);
}

.checkbox-control {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}

.checkbox-control input[type='checkbox'] {
  width: 20px;
  height: 20px;
  margin-right: 10px;
  cursor: pointer;
}

.checkbox-control label {
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  color: #555;
}

.color-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.color-control label {
  font-size: 0.9rem;
  font-weight: 500;
  color: #555;
}

.color-control input[type='color'] {
  width: 60px;
  height: 36px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
}

.primary-btn,
.secondary-btn {
  width: 100%;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 8px;
}

.primary-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

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

.secondary-btn {
  background: white;
  color: #667eea;
  border: 2px solid #667eea;
}

.secondary-btn:hover {
  background: #667eea;
  color: white;
}

.scenes-list {
  margin-bottom: 16px;
  max-height: 400px;
  overflow-y: auto;
}

.scene-item {
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  transition: all 0.2s;
}

.scene-item:hover {
  border-color: #667eea;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.scene-item.selected {
  border-color: #667eea;
  background: #f0f4ff;
}

.scene-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.scene-title {
  font-weight: 600;
  color: #667eea;
  cursor: pointer;
  flex: 1;
}

.scene-actions {
  display: flex;
  gap: 4px;
}

.scene-btn {
  padding: 4px 8px;
  border: none;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
  border: 1px solid #e0e0e0;
}

.scene-btn:hover {
  background: #f8f9fa;
}

.scene-btn.delete {
  background: #ff4757;
  color: white;
  border-color: #ff4757;
}

.scene-btn.delete:hover {
  background: #ee5a6f;
}

.scene-details {
  font-size: 0.85rem;
  color: #666;
  padding: 8px;
  background: #f8f9fa;
  border-radius: 4px;
  margin-top: 8px;
}

.scene-field {
  margin-bottom: 8px;
}

.scene-field label {
  display: inline-block;
  font-weight: 500;
  margin-bottom: 4px;
  margin-right: 8px;
  font-size: 0.85rem;
}

.scene-field input[type="color"] {
  width: 50px;
  height: 30px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  cursor: pointer;
  margin-right: 15px;
}

.scene-field input[type="text"],
.scene-field textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: inherit;
}

.scene-field textarea {
  resize: vertical;
  min-height: 60px;
}

.scene-field select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  font-size: 0.85rem;
  background: white;
  cursor: pointer;
}

.frames-list {
  margin-bottom: 16px;
  max-height: 300px;
  overflow-y: auto;
}

.frame-item {
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
}

.frame-item:hover {
  border-color: #667eea;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.frame-item.selected {
  border-color: #667eea;
  background: #f0f4ff;
}

.frame-preview {
  width: 60px;
  height: 45px;
  border-radius: 4px;
  object-fit: cover;
  background: #f8f9fa;
}

.frame-info {
  flex: 1;
  font-size: 0.85rem;
}

.frame-info strong {
  display: block;
  color: #667eea;
  margin-bottom: 2px;
}

.frame-actions {
  display: flex;
  gap: 4px;
}

.frame-btn {
  padding: 4px 8px;
  border: none;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.frame-btn.delete {
  background: #ff4757;
  color: white;
}

.frame-btn.delete:hover {
  background: #ee5a6f;
}

.font-info {
  margin-bottom: 12px;
  padding: 8px;
  background: #fff;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
}

.font-info small {
  color: #666;
  font-size: 0.85rem;
}

.export-status {
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  text-align: center;
  min-height: 20px;
}

.export-status.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.export-status.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.export-status.processing {
  background: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

.canvas-area {
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
}

.canvas-wrapper {
  border: 3px solid #e0e0e0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  background: #f8f9fa;
}

#previewCanvas {
  display: block;
  max-width: 100%;
  height: auto;
  background: #2c3e50;
}

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

  .controls-panel {
    max-height: none;
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
  }
}
