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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a1a; color: #e0e0e0;
  display: flex; flex-direction: column; align-items: center;
  min-height: 100vh; padding: 24px;
}

h1 {
  font-size: 20px; font-weight: 500; letter-spacing: 0.05em;
  margin-bottom: 20px; color: #fff;
}

/* ── Two-panel layout ── */
.layout {
  width: 100%; max-width: 1400px;
  display: flex; flex-direction: column; gap: 24px;
}

.panel { width: 100%; }

@media (min-width: 900px) {
  .layout {
    flex-direction: row;
    align-items: flex-start;
  }
  .panel-left {
    flex: 1;
    min-width: 0;
  }
  .panel-right {
    flex: 2;
    min-width: 0;
  }
}

/* ── Controls ── */
.controls {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  margin-bottom: 16px;
}

select, button {
  font-family: inherit; font-size: 14px;
  padding: 8px 14px; border-radius: 6px; border: 1px solid #444;
  background: #2a2a2a; color: #e0e0e0; cursor: pointer;
}

select { flex: 1; min-width: 0; max-width: 400px; }

select:hover, button:hover { border-color: #666; }

button.primary {
  background: #2563eb; border-color: #2563eb;
  color: #fff; font-weight: 600;
}
button.primary:hover { background: #1d4ed8; }
button:disabled { opacity: 0.4; cursor: default; }

/* ── Drop zone ── */
.drop-zone {
  width: 100%;
  border: 2px dashed #444; border-radius: 12px;
  padding: 32px 16px; text-align: center; color: #888;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 16px; cursor: pointer;
}
.drop-zone.drag-over {
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.08);
}
.drop-zone p { margin-bottom: 6px; }
.drop-zone .hint { font-size: 13px; color: #666; }

/* ── Thumbnails ── */
.thumbs-header {
  display: flex; justify-content: flex-end; margin-bottom: 8px;
}
.clear-all {
  font-size: 12px; padding: 4px 10px;
  background: #333; border: 1px solid #555; color: #ccc;
  border-radius: 4px; cursor: pointer;
}
.clear-all:hover { background: #ef4444; border-color: #ef4444; color: #fff; }

.thumbs {
  columns: 3;
  column-gap: 8px;
}
.thumb-wrap {
  position: relative; border-radius: 6px; overflow: hidden;
  border: 2px solid #333; background: #222;
  cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
  user-select: none;
  break-inside: avoid;
  margin-bottom: 8px;
  display: inline-block;
  width: 100%;
}
.thumb-wrap:hover { border-color: #555; }
.thumb-wrap.selected {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.4);
}
.thumb-wrap img {
  display: block; width: 100%; height: auto;
  pointer-events: none;
}
.thumb-wrap .remove {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.6); color: #fff;
  border: none; padding: 0; margin: 0;
  font-size: 13px; font-weight: 400;
  line-height: 20px; text-align: center;
  cursor: pointer; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.15s;
}
.thumb-wrap:hover .remove { opacity: 1; }
.thumb-wrap .remove:hover { background: #ef4444; }
.thumb-wrap .slot-badge {
  position: absolute; bottom: 4px; left: 4px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #2563eb; color: #fff;
  font-size: 11px; font-weight: 700;
  line-height: 20px; text-align: center;
  pointer-events: none;
}

/* ── Preview ── */
.preview-container {
  width: 100%;
  display: flex; justify-content: center;
}
#preview {
  max-width: 100%; max-height: 75vh;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  display: none;
}

/* ── Status ── */
.status {
  font-size: 13px; color: #888; min-height: 20px;
  margin-bottom: 12px;
}
.status.error { color: #ef4444; }

/* ── Hidden file input ── */
#fileInput { display: none; }
