/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0a0a0f;
  --surface:   #111118;
  --surface2:  #18181f;
  --border:    #2a2a38;
  --border2:   #3a3a52;
  --text:      #e8e8f0;
  --muted:     #6b6b85;
  --accent:    #5b8af0;
  --accent2:   #8b5cf6;
  --success:   #34d399;
  --danger:    #f87171;
  --warning:   #fbbf24;

  --glow:      0 0 40px rgba(91,138,240,0.15);
  --radius:    12px;
  --radius-lg: 20px;
}

html { font-size: 16px; }

body {
  font-family: 'Syne', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  cursor: default;
}

/* ── Background Grid ────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(91,138,240,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(91,138,240,0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  top: -30%;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 600px;
  background: radial-gradient(ellipse, rgba(91,138,240,0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ─────────────────────────────────────────────────── */
.wrapper {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ── Header ─────────────────────────────────────────────────── */
header {
  padding: 48px 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  margin-bottom: 48px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 20px rgba(91,138,240,0.3);
}

.logo-text {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo-text span { color: var(--accent); }

.header-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 100px;
  letter-spacing: 0.5px;
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
}

.header-badge:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Drop Zone ──────────────────────────────────────────────── */
.drop-zone {
  position: relative;
  border: 2px dashed var(--border2);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 64px 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s, transform 0.2s;
  margin-bottom: 32px;
  overflow: hidden;
}

.drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(91,138,240,0.08), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--surface2);
  transform: scale(1.005);
}

.drop-zone:hover::before,
.drop-zone.dragover::before { opacity: 1; }

.drop-zone.dragover {
  border-color: var(--accent2);
  box-shadow: var(--glow);
}

.drop-icon {
  font-size: 52px;
  margin-bottom: 16px;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(91,138,240,0.3));
  transition: transform 0.3s;
}

.drop-zone:hover .drop-icon,
.drop-zone.dragover .drop-icon { transform: translateY(-4px) scale(1.1); }

.drop-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}

.drop-sub {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.drop-sub strong { color: var(--text); }

.btn-pick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: 100px;
  color: white;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 14px;
  padding: 12px 28px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(91,138,240,0.35);
}

.btn-pick:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 8px 30px rgba(91,138,240,0.45);
}

.btn-pick:active { transform: scale(0.97); }

.drop-formats {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.fmt-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 100px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.fmt-tag.video-tag {
  color: #a78bfa;
  border-color: rgba(167,139,250,0.3);
  background: rgba(167,139,250,0.06);
}

.drop-limit {
  font-size: 11px;
  color: var(--muted);
  margin-left: 4px;
}

#fileInput { display: none; }

/* ── Progress ───────────────────────────────────────────────── */
.progress-wrap {
  display: none;
  margin-bottom: 32px;
}

.progress-wrap.active { display: block; }

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 10px;
}

.progress-label { color: var(--muted); }

.progress-pct {
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
  font-weight: 500;
}

.progress-bar {
  height: 4px;
  background: var(--surface2);
  border-radius: 100px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 100px;
  transition: width 0.3s ease;
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 0 8px rgba(255,255,255,0.6);
}

/* ── Toast ──────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 100px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
  opacity: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}

#toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

#toast.success { border-color: var(--success); color: var(--success); }
#toast.error   { border-color: var(--danger);  color: var(--danger); }

/* ── Gallery ────────────────────────────────────────────────── */
.gallery-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}

.gallery-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.gallery-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--muted);
}

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

/* ── Cards ──────────────────────────────────────────────────── */
.img-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  animation: cardIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes cardIn {
  from { opacity: 0; transform: scale(0.85) translateY(10px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.img-card:hover {
  border-color: var(--border2);
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
}

.img-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  background: var(--surface2);
  cursor: pointer;
}

.video-thumb-wrap {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  overflow: hidden;
}

.video-thumb-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.video-play-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.35);
  transition: background 0.2s;
}

.video-thumb-wrap:hover .video-play-badge { background: rgba(0,0,0,0.5); }

.video-play-badge svg {
  width: 40px;
  height: 40px;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.6));
}

.media-type-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 100px;
  backdrop-filter: blur(6px);
  background: rgba(10,10,15,0.7);
  border: 1px solid rgba(255,255,255,0.08);
}

.media-type-badge.image { color: var(--accent); }
.media-type-badge.video { color: #a78bfa; }

.img-card-body { padding: 12px; }

.img-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.img-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 12px;
}

.img-actions {
  display: flex;
  gap: 6px;
}

.btn-copy, .btn-del, .btn-open {
  flex: 1;
  border: none;
  border-radius: 7px;
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 11px;
  padding: 7px 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn-copy { background: rgba(91,138,240,0.12); color: var(--accent); }
.btn-copy:hover { background: rgba(91,138,240,0.22); }

.btn-open { background: rgba(52,211,153,0.10); color: var(--success); }
.btn-open:hover { background: rgba(52,211,153,0.20); }

.btn-del  { background: rgba(248,113,113,0.08); color: var(--danger); flex: 0; padding: 7px 10px; }
.btn-del:hover  { background: rgba(248,113,113,0.18); }

.btn-copy:active, .btn-del:active, .btn-open:active { transform: scale(0.95); }

/* ── Upload overlay ─────────────────────────────────────────── */
.uploading-badge {
  position: absolute;
  inset: 0;
  background: rgba(10,10,15,0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  backdrop-filter: blur(4px);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid rgba(91,138,240,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 0;
  color: var(--muted);
  font-size: 14px;
  display: none;
}

.empty-state.visible { display: block; }
.empty-icon { font-size: 36px; margin-bottom: 12px; opacity: 0.4; }

/* ── Confirm Dialog ─────────────────────────────────────────── */
.confirm-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 60;
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.confirm-bg.open { display: flex; }

.confirm-box {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  max-width: 360px;
  width: 100%;
  animation: modalIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
  text-align: center;
}

.confirm-icon { font-size: 32px; margin-bottom: 12px; }
.confirm-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.confirm-msg { color: var(--muted); font-size: 13px; margin-bottom: 24px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 10px; }

.btn-confirm-cancel {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 10px;
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.btn-confirm-cancel:hover { color: var(--text); border-color: var(--border2); }

.btn-confirm-ok {
  flex: 1;
  background: rgba(248,113,113,0.12);
  border: 1px solid rgba(248,113,113,0.3);
  color: var(--danger);
  border-radius: 8px;
  padding: 10px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-confirm-ok:hover { background: rgba(248,113,113,0.22); }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 50;
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-bg.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  max-width: 700px;
  width: 100%;
  overflow: hidden;
  animation: modalIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

.modal-media-wrap {
  width: 100%;
  background: var(--bg);
  max-height: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.modal-media-wrap img  { width: 100%; max-height: 480px; object-fit: contain; }
.modal-media-wrap video { width: 100%; max-height: 480px; outline: none; }

.modal-footer {
  padding: 16px 20px;
  display: flex;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--border);
}

.modal-url {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-close {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 14px;
  font-size: 14px;
  transition: color 0.15s;
}

.modal-close:hover { color: var(--text); }

/* ── Footer ─────────────────────────────────────────────────── */
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  margin-top: 64px;
  padding: 24px 0;
}

.footer-left {
  font-size: 12px;
  color: var(--muted);
}

.footer-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-link:hover { color: var(--accent); }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 100px; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 600px) {
  header { padding: 28px 0 24px; }
  .header-badge { display: none; }
  .drop-zone { padding: 40px 20px; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
}