* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: #222;
  background: #f7f7f9;
}

.progress-container {
  width: 100%;
  background-color: #f3f4f6;
  border-radius: 4px;
  margin: 8px 12px;
  overflow: hidden;
}

.progress-bar {
  height: 12px;
  background-color: #3b82f6;
  width: 0%;
  border-radius: 4px;
  transition: width 0.3s;
}

.upload-info {
  font-size: 0.8rem;
  color: #6b7280;
  margin: 4px 12px;
  display: flex;
  justify-content: space-between;
}

.topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  z-index: 10;
}
.brand { font-weight: 700; letter-spacing: 0.5px; display: inline-flex; align-items: center; }
.controls { display: flex; gap: 8px; }
.btn {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #111827;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover { background: #f3f4f6; }

.status {
  margin: 8px 12px 0;
  padding: 8px 12px;
  font-size: 0.9rem;
  color: #374151;
}
.status.info { color: #0ea5e9; }
.status.ok { color: #10b981; }
.status.warn { color: #d97706; }
.status.error { color: #ef4444; }

main { padding: 8px 8px 24px; margin-bottom: 60px; }
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  padding: 8px 4px;
}
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.card img {
  display: block;
  width: 100%;
  /*height: 160px;*/
  object-fit: cover;
  background: #f3f4f6;
}
.card figcaption {
  padding: 6px 8px;
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty {
  color: #6b7280;
  font-size: 0.95rem;
  padding: 16px;
}

.footer {
  text-align: center;
  color: #6b7280;
  font-size: 12px;
  padding: 16px 8px 24px;
}

.task-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 10px 16px;
  display: flex;
  justify-content: center;
  z-index: 100;
}

.upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #3b82f6;
  color: white;
  border: none;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.upload-btn:hover {
  background: #2563eb;
}

figure {
    margin: 5px !important;
}

/* Image Overlay Styles */
.image-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.image-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.overlay-content {
    position: relative;
    max-width: 95%;
    max-height: 95%;
    display: flex;
    justify-content: center;
}

#overlayImage {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

/* Slight blur for low-res thumb shown before medium loads */
#overlayImage.low-res {
    filter: blur(6px);
    transition: filter 0.2s ease;
}

/* Overlay footer with uploader + download */
.overlay-footer {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    backdrop-filter: blur(4px);
    border-radius: 8px;
}

.uploader { display: flex; align-items: center; gap: 10px; }
.uploader-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: #111827;
}
.uploader-meta { line-height: 1.1; }
.uploader-label { font-size: 11px; opacity: 0.8; }
.uploader-nickname { font-weight: 600; font-size: 14px; }

.download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #10b981;
    color: #fff;
    border: none;
}
.download-btn:hover { background: #059669; }
.download-btn.downloaded { background: #16a34a; }
.download-btn.downloaded i::before { content: "\f00c"; } /* fa-check */

/* Downloaded badge on thumb cards */
.card { position: relative; }
.card .dl-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(16,185,129,0.95);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
}

.close-btn {
    position: absolute;
    top: -40px;
    right: 0;
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
}

.delete-btn {
    position: absolute;
    top: -40px;
    left: 0;
    background: transparent;
    border: none;
    color: #fca5a5;
    font-size: 22px;
    cursor: pointer;
    padding: 8px;
}

.delete-btn:hover { color: #ef4444; }

/* Delete dialog */
.delete-dialog {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1100;
}
.delete-dialog.active { display: flex; }
.delete-dialog-content {
    background: #fff;
    width: min(680px, 92%);
    max-height: 85vh;
    overflow: auto;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    padding: 16px 18px;
}
.delete-dialog-content h3 {
    margin: 6px 0 12px 0;
}
.delete-dialog-content label {
    display: block;
    margin: 8px 0;
    font-size: 0.95rem;
}
.delete-dialog-actions {
    margin-top: 14px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.btn.danger { border-color: #ef4444; color: #ef4444; }
.btn.danger:hover { background: #fee2e2; }

body.overlay-active {
    overflow: hidden;
}

/* Brand and QR styles */
.brand .sep { margin: 0 8px; color: #9ca3af; }
.brand .album-title { font-weight: 600; color: #111827; }
.icon-btn {
  border: none;
  background: transparent;
  color: #111827;
  margin-left: 10px;
  font-size: 18px;
  cursor: pointer;
}
.icon-btn:hover { color: #2563eb; }

/* QR Modal */
.qr-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}
.qr-modal.active { display: flex; }
.qr-modal-content {
  position: relative;
  background: #fff;
  width: min(420px, 92%);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  padding: 16px 18px 20px;
  text-align: center;
}
.qr-modal-content .close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  color: #111827;
}
.qr-code { margin: 12px auto; width: 256px; height: 256px; }
.qr-link a { word-break: break-all; color: #2563eb; text-decoration: none; }
.qr-link a:hover { text-decoration: underline; }

/* Video thumb play badge */
.card .thumb-link { position: relative; display: block; }
.card .play-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  backdrop-filter: blur(2px);
}
.card.video img {
  filter: saturate(0.9) brightness(0.9);
}

/* Overlay video */
#overlayVideo {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
}

/* Hamburger menu dropdown */
.topbar .controls { position: relative; }
.menu-panel {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  min-width: 220px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  padding: 6px;
  display: none;
  z-index: 20;
}
.menu-panel.open { display: block; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: #111827;
  text-decoration: none;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.menu-item i { width: 18px; }
.menu-item:hover { background: #f3f4f6; }
