body { 
  margin: 0; 
  font-family: sans-serif; 
  background: #121212; 
  color: #eee; 
}

.topbar {
  display: flex; 
  justify-content: space-around; 
  align-items: center;
  background: #1f1f1f; 
  padding: 0.5rem; 
  position: sticky; 
  top: 0; 
  z-index: 100;
}

.btn { 
  font-size: 1.5rem; 
  background: transparent; 
  border: none; 
  color: #eee;
  padding: 0.5rem; 
  border-radius: 12px; 
  cursor: pointer; 
}

.btn.active, 
.btn:hover { 
  background: #333; 
}

.section { 
  display: none; 
  padding: 1rem; 
}

.section.active { 
  display: block; 
}

.scroll-x { 
  display: flex; 
  overflow-x: auto; 
  gap: 0.5rem; 
  padding: 0.5rem 0; 
}

.folder, 
.image {
  flex: 0 0 auto; 
  width: 80px; 
  height: 80px; 
  border-radius: 12px;
  display: flex; 
  align-items: center; 
  justify-content: center;
  text-align: center; 
  font-size: 0.8rem; 
  cursor: pointer;
}

.folder { 
  background: #2a2a4a; 
  color: #ccc; 
}

.image { 
  background: #333; 
  overflow: hidden; 
  border: 2px solid transparent; 
}

.image img { 
  width: 100%; 
  height: 100%; 
  object-fit: cover; 
  border-radius: 12px; 
}

.image.selected { 
  border-color: #6cf; 
}

.breadcrumb { 
  margin-bottom: 0.5rem; 
}

.breadcrumb span { 
  cursor: pointer; 
  color: #6cf; 
  margin-right: 0.25rem; 
}

.breadcrumb span::after { 
  content: ' /'; 
}

.breadcrumb span:last-child::after { 
  content: ''; 
}

#preview { 
  margin-top: 1rem; 
  text-align: center; 
}

#preview img { 
  max-width: 90%; 
  max-height: 200px; 
  border-radius: 12px; 
  border: 2px solid #6cf; 
  background: #000; 
  cursor: pointer; 
}

/* Overlay */
#overlay {
  display: none; 
  position: fixed; 
  inset: 0;
  background: rgba(0,0,0,0.95); 
  color: #fff; 
  z-index: 200;
  padding: 1rem; 
  overflow: hidden;
}

#overlayContent { 
  margin-top: 2.5rem; 
  text-align: center; 
  height: calc(100% - 3rem); 
  display: flex; 
  flex-direction: column; 
}

#overlayClose {
  position: absolute; 
  top: 0.5rem; 
  right: 0.5rem;
  font-size: 1.5rem; 
  background: #333; 
  border: none; 
  border-radius: 8px;
  color: #eee; 
  cursor: pointer; 
  padding: 0.25rem 0.5rem;
}

/* Tabs */
#groupTabs {
  display: flex; 
  justify-content: center; 
  gap: 0.5rem; 
  margin-bottom: 0.5rem;
}

#groupTabs button {
  background: #333; 
  border: none; 
  color: #eee;
  padding: 0.25rem 0.75rem; 
  border-radius: 6px; 
  cursor: pointer;
}

#groupTabs button.active { 
  background: #6cf; 
  color: #000; 
}

#pickedImages {
  display: flex; 
  gap: 0.5rem; 
  margin-bottom: 0.5rem;
  flex-wrap: wrap; 
  justify-content: center;
}

.pickedTile { 
  position: relative; 
  display: inline-block; 
}

.pickedTile canvas {
  border: 2px solid #6cf; 
  border-radius: 8px; 
  background: #000;
}

.pickedTile span {
  position: absolute; 
  bottom: -14px; 
  left: 50%; 
  transform: translateX(-50%);
  font-size: 10px; 
  color: #fff; 
  background: rgba(0,0,0,0.6);
  padding: 1px 4px; 
  border-radius: 4px;
}

.removeBtn {
  position: absolute; 
  top: -8px; 
  right: -8px;
  background: #f33; 
  color: #fff; 
  border: none; 
  border-radius: 50%;
  font-size: 0.8rem; 
  cursor: pointer; 
  width: 18px; 
  height: 18px;
  line-height: 16px; 
  padding: 0;
}

#tileViewport {
  flex: 1; 
  overflow: auto; 
  border: 2px solid #444; 
  background: #000;
}

#tileContainer { 
  position: relative; 
  display: inline-block; 
}

#tileContainer img {
  display: block; 
  border-radius: 12px; 
  border: 2px solid #6cf;
}

.grid-cell {
  position: absolute;
  border: 1px solid rgba(255,255,255,0.3);
  box-sizing: border-box;
  cursor: pointer;
  font-size: 10px;
  color: #fff;
}

.grid-cell span {
  position: absolute; 
  top: 2px; 
  left: 2px;
  background: rgba(0,0,0,0.5);
  padding: 0 2px;
  border-radius: 3px;
  font-size: 9px;
}

.grid-cell:hover { 
  background: rgba(255,255,255,0.1); 
}