:root {
  --bg: #0e0f13;
  --panel: #16181f;
  --panel-2: #1c1f28;
  --border: #2a2e3a;
  --text: #e7e9ee;
  --muted: #8b90a0;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.15);
  --gap: 10px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Toolbar */
.toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--text);
}

.controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.control input[type="range"] {
  accent-color: var(--accent);
}

#colsValue {
  width: 1.2em;
  text-align: center;
  color: var(--text);
}

.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: #232735;
  border-color: #3a3f4f;
}

/* Stage */
.stage {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.side {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 12px;
  gap: 12px;
}

.divider {
  flex: 0 0 1px;
  background: var(--border);
}

/* Label */
.label-wrap {
  flex: 0 0 auto;
  height: 18vh;
  min-height: 70px;
  max-height: 220px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  overflow: hidden;
}

.label {
  width: 100%;
  text-align: center;
  font-weight: 800;
  line-height: 1.05;
  outline: none;
  white-space: nowrap;
  overflow: hidden;
  /* font-size is set dynamically by JS */
}

.label:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

/* Dropzone */
.dropzone {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 12px;
  overflow: auto;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone.has-images {
  cursor: default;
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), 1fr);
  gap: var(--gap);
  padding: var(--gap);
}

.empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  pointer-events: none;
  text-align: center;
  padding: 16px;
}

.dropzone.has-images .empty-hint { display: none; }

.empty-icon {
  font-size: 34px;
  opacity: 0.6;
}

/* Image cells */
.cell {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.cell img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.cell .remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 14px;
  line-height: 22px;
  text-align: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.cell:hover .remove { opacity: 1; }

.cell .name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  font-size: 11px;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  padding: 12px 6px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.15s;
}

.cell:hover .name { opacity: 1; }

@media (max-width: 720px) {
  .stage { flex-direction: column; }
  .divider { display: none; }
}
