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

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #0f1117;
  color: #e2e8f0;
  min-height: 100vh;
}

header {
  background: #1a1d27;
  border-bottom: 1px solid #2d3148;
  padding: 1.5rem 2rem;
  text-align: center;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

header p { color: #94a3b8; margin-top: 0.25rem; font-size: 0.9rem; }

main { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; }

/* Upload */
.upload-section { margin-bottom: 3rem; }

.drop-zone {
  border: 2px dashed #3d4266;
  border-radius: 1rem;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: #6366f1;
  background: rgba(99,102,241,0.05);
}

.drop-icon { font-size: 3rem; display: block; margin-bottom: 0.75rem; }

.drop-zone p { color: #94a3b8; }
.or { margin: 0.75rem 0; font-size: 0.85rem; }

.btn-upload {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.6rem 1.5rem;
  background: #6366f1;
  color: #fff;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.btn-upload:hover { background: #4f52d1; }

.upload-status {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 0.5rem;
  text-align: center;
  font-size: 0.9rem;
}

.upload-status.success { background: rgba(34,197,94,0.1); color: #4ade80; border: 1px solid rgba(34,197,94,0.2); }
.upload-status.error   { background: rgba(239,68,68,0.1);  color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.upload-status.loading { background: rgba(99,102,241,0.1); color: #a5b4fc; border: 1px solid rgba(99,102,241,0.2); }

/* Progress bar */
.progress-bar-wrap { background: #2d3148; border-radius: 99px; height: 6px; margin-top: 0.75rem; overflow: hidden; }
.progress-bar      { height: 100%; background: #6366f1; border-radius: 99px; transition: width 0.2s; }

/* Gallery */
.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.gallery-header h2 { font-size: 1.25rem; }

.btn-refresh {
  background: transparent;
  border: 1px solid #3d4266;
  color: #94a3b8;
  padding: 0.4rem 0.9rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: border-color 0.2s, color 0.2s;
}

.btn-refresh:hover { border-color: #6366f1; color: #a5b4fc; }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 0.75rem;
  overflow: hidden;
  cursor: pointer;
  background: #1a1d27;
  border: 1px solid #2d3148;
  transition: transform 0.2s, box-shadow 0.2s;
}

.gallery-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-item .item-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: flex-end;
  padding: 0.75rem;
}

.gallery-item:hover .item-overlay { opacity: 1; }

.item-name {
  font-size: 0.78rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.loading { color: #94a3b8; text-align: center; padding: 3rem; grid-column: 1/-1; }
.empty   { color: #64748b; text-align: center; padding: 3rem; grid-column: 1/-1; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  z-index: 1;
  background: #1a1d27;
  border: 1px solid #2d3148;
  border-radius: 1rem;
  overflow: hidden;
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(0,0,0,0.6);
  border: none;
  color: #fff;
  font-size: 1.5rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.modal-content img {
  width: 100%;
  max-height: 65vh;
  object-fit: contain;
  background: #0f1117;
}

.modal-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  flex-wrap: wrap;
}

#modalName {
  flex: 1;
  font-size: 0.9rem;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-copy, .btn-delete {
  padding: 0.45rem 1rem;
  border-radius: 0.5rem;
  border: none;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-copy   { background: #6366f1; color: #fff; }
.btn-copy:hover { background: #4f52d1; }

.btn-delete { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.btn-delete:hover { background: rgba(239,68,68,0.3); }
