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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #2d2d2d;
  color: #e0e0e0;
  min-height: 100vh;
  overflow-x: hidden;
}

header {
  background: linear-gradient(135deg, #4caf50, #2e7d32);
  padding: 10px 24px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

header h1 {
  font-size: 24px;
  color: white;
  text-shadow: 2px 2px 0 #1b5e20;
  letter-spacing: 1px;
}

/* ===== SPLIT LAYOUT ===== */
.split-container {
  display: flex;
  height: calc(100vh - 50px);
  overflow: hidden;
}

.panel {
  flex: 1;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  padding: 8px 16px;
  text-align: center;
  flex-shrink: 0;
}

.panel-title {
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.skin-title { color: #ff9800; }
.texture-title { color: #4caf50; }

.panel-body {
  flex: 1;
  display: flex;
  gap: 8px;
  padding: 0 8px 8px;
  overflow-y: auto;
  overflow-x: hidden;
}

.panel-tools {
  width: 160px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.panel-sidebar {
  width: 200px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.panel-sidebar h3 {
  font-size: 13px;
  color: #81c784;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ===== DIVIDER ===== */
.split-divider {
  width: 8px;
  background: #383838;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.split-divider:hover {
  background: #4caf50;
}

.divider-handle {
  width: 4px;
  height: 40px;
  background: #666;
  border-radius: 2px;
}

.split-divider:hover .divider-handle {
  background: white;
}

/* ===== TOOLS ===== */
.tool-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: 2px solid #555;
  border-radius: 8px;
  background: #444;
  color: #ddd;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
  min-height: 40px;
}

.tool-btn:hover {
  background: #505050;
  border-color: #81c784;
}

.tool-btn.active {
  background: #2e7d32;
  border-color: #4caf50;
  color: white;
}

.tool-icon {
  font-size: 20px;
}

/* ===== COLORS ===== */
.color-section-mini {
  background: #383838;
  border-radius: 8px;
  padding: 8px;
}

.current-color-display {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.current-color-box {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 2px solid #666;
}

#current-color-label {
  font-family: monospace;
  font-size: 12px;
}

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

.color-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 3px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
  min-width: 18px;
  min-height: 18px;
}

.color-swatch:hover {
  transform: scale(1.15);
  border-color: white;
}

.color-swatch.active {
  border-color: #ffeb3b;
  transform: scale(1.1);
}

#custom-color {
  width: 100%;
  height: 24px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: #444;
}

/* ===== SIZE BUTTONS ===== */
.size-section {
  background: #383838;
  border-radius: 8px;
  padding: 8px;
}

.size-buttons {
  display: flex;
  gap: 6px;
}

.size-btn {
  flex: 1;
  padding: 6px;
  border: 2px solid #555;
  border-radius: 6px;
  background: #444;
  color: #ddd;
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
  transition: all 0.15s;
}

.size-btn:hover { background: #505050; }
.size-btn.active {
  background: #2e7d32;
  border-color: #4caf50;
  color: white;
}

/* ===== CANVAS ===== */
.canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 512px;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  background: repeating-conic-gradient(#666 0% 25%, #555 0% 50%) 0 0 / 32px 32px;
}

.canvas-wrapper canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

#grid-canvas {
  pointer-events: none;
}

.canvas-wrapper[data-tool="pencil"] { cursor: crosshair; }
.canvas-wrapper[data-tool="eraser"] { cursor: cell; }
.canvas-wrapper[data-tool="fill"] { cursor: pointer; }
.canvas-wrapper[data-tool="picker"] { cursor: copy; }

/* ===== EDITOR CONTROLS ===== */
.editor-controls {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.control-btn {
  padding: 5px 10px;
  border: 2px solid #555;
  border-radius: 6px;
  background: #444;
  color: #ddd;
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
  transition: all 0.15s;
}

.control-btn:hover {
  background: #505050;
  border-color: #81c784;
}

.control-btn-danger { border-color: #c62828; color: #ff8a80; }
.control-btn-danger:hover { background: #c62828; border-color: #e53935; color: white; }

.drag-hint {
  font-size: 11px;
  color: #888;
  text-align: center;
  font-style: italic;
}

.grid-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  cursor: pointer;
}

.grid-toggle input { cursor: pointer; }

.mirror-toggle:has(input:checked) {
  color: #4caf50;
  font-weight: bold;
}

/* ===== TEMPLATES ===== */
.template-section {
  background: #383838;
  border-radius: 8px;
  padding: 8px;
}

.template-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}

.template-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.template-item:hover {
  background: #505050;
  border-color: #81c784;
}

.template-item canvas {
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
  border-radius: 3px;
}

.template-item span {
  font-size: 10px;
  text-align: center;
  color: #bbb;
}

/* ===== PREVIEW ===== */
.preview-section {
  background: #383838;
  border-radius: 8px;
  padding: 8px;
}

#preview-canvas {
  width: 100%;
  image-rendering: pixelated;
  border-radius: 4px;
  background: repeating-conic-gradient(#666 0% 25%, #555 0% 50%) 0 0 / 16px 16px;
}

/* ===== PACK SECTION ===== */
.pack-section {
  background: #383838;
  border-radius: 8px;
  padding: 8px;
}

#pack-name {
  width: 100%;
  padding: 6px 8px;
  border: 2px solid #555;
  border-radius: 4px;
  background: #444;
  color: #e0e0e0;
  font-size: 13px;
  margin-bottom: 6px;
}

#pack-name:focus {
  outline: none;
  border-color: #4caf50;
}

.texture-target {
  margin: 6px 0;
}

.texture-target label {
  display: block;
  font-size: 12px;
  color: #ccc;
  margin-bottom: 3px;
  font-weight: bold;
}

.texture-target select {
  width: 100%;
  padding: 6px 8px;
  border: 2px solid #555;
  border-radius: 4px;
  background: #444;
  color: #e0e0e0;
  font-size: 13px;
}

.texture-target select:focus {
  outline: none;
  border-color: #4caf50;
}

.pack-empty {
  font-size: 11px;
  color: #888;
  text-align: center;
  padding: 8px 4px;
  font-style: italic;
}

.pack-textures {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 32px;
  padding: 4px;
  background: #2d2d2d;
  border-radius: 4px;
  margin-bottom: 6px;
}

.pack-texture-item {
  position: relative;
  width: 32px;
  height: 32px;
}

.pack-texture-item canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  border-radius: 3px;
  border: 2px solid #555;
  cursor: pointer;
}

.pack-texture-item canvas:hover { border-color: #4caf50; }

.pack-texture-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e53935;
  color: white;
  border: none;
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.action-btn {
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 6px;
  background: #4caf50;
  color: white;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 4px;
}

.action-btn:hover { background: #388e3c; }

.download-btn {
  background: #ff9800;
  font-size: 15px;
  padding: 10px;
}

.download-btn:hover { background: #f57c00; }

/* ===== SKIN GALLERY ===== */
.panel-skins {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.skin-controls {
  display: flex;
  gap: 6px;
  padding: 6px 12px;
  flex-shrink: 0;
}

.skin-controls input,
.skin-controls select {
  flex: 1;
  padding: 6px 10px;
  border: 2px solid #555;
  border-radius: 6px;
  background: #444;
  color: #e0e0e0;
  font-size: 13px;
}

.skin-controls input:focus,
.skin-controls select:focus {
  outline: none;
  border-color: #ff9800;
}

.skin-stats {
  text-align: center;
  padding: 4px;
  font-size: 11px;
  color: #888;
  flex-shrink: 0;
}

.skin-stats span {
  color: #ff9800;
  font-weight: bold;
}

.skin-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  padding: 8px 12px;
  overflow-y: auto;
  align-content: start;
}

.skin-card {
  background: #383838;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

.skin-card:hover {
  transform: translateY(-2px);
  border-color: #ff9800;
}

.skin-card-preview {
  width: 100%;
  aspect-ratio: 3/4;
  background: linear-gradient(180deg, #2d2d2d, #383838);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.skin-card-preview img {
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.skin-card-info {
  padding: 6px 8px;
}

.skin-card-info h4 {
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.skin-card-category {
  display: inline-block;
  padding: 1px 5px;
  background: #2d2d2d;
  border-radius: 3px;
  font-size: 9px;
  color: #ff9800;
  margin-bottom: 4px;
}

.skin-card-download {
  display: block;
  width: 100%;
  padding: 5px;
  background: #ff9800;
  color: #1a1a2e;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  font-size: 11px;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.skin-card-download:hover {
  background: #f57c00;
}

.skin-no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
  color: #666;
  font-size: 14px;
}

.skin-help-bottom {
  flex-shrink: 0;
  padding: 8px 12px;
  border-top: 1px solid #444;
}

.skin-help-bottom h3 {
  font-size: 12px;
  color: #ff9800;
  margin-bottom: 4px;
}

.skin-help-bottom p {
  font-size: 11px;
  color: #999;
  line-height: 1.5;
  margin-bottom: 1px;
}

.skin-help-bottom strong {
  color: #ff9800;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: #2d2d2d; border-radius: 3px; }
::-webkit-scrollbar-thumb { background: #555; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #777; }

/* ===== FEATURED PACKS ===== */
.featured-packs {
  max-width: 1200px;
  margin: 16px auto 0;
  padding: 0 16px 24px;
}

.featured-packs h2 {
  font-size: 16px;
  color: #ff9800;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.pack-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #383838;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.pack-card-info h3 { font-size: 14px; color: #e0e0e0; margin-bottom: 2px; }
.pack-card-info p { font-size: 12px; color: #aaa; line-height: 1.4; }

.pack-download-btn {
  flex-shrink: 0;
  padding: 8px 20px;
  border-radius: 6px;
  background: #ff9800;
  color: white;
  font-size: 14px;
  font-weight: bold;
  text-decoration: none;
  transition: background 0.15s;
  margin-left: 16px;
}

.pack-download-btn:hover { background: #f57c00; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .split-container {
    flex-direction: column;
    height: auto;
  }
  .split-divider {
    width: 100%;
    height: 8px;
    cursor: row-resize;
  }
  .divider-handle {
    width: 40px;
    height: 4px;
  }
  .panel-body {
    flex-direction: column;
  }
  .panel-tools {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .panel-sidebar {
    width: 100%;
  }
}
