/* ── Reset & Variables ─────────────────────────────────────────────────────── */

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

:root {
  --bg:           #09090b;
  --surface:      #18181b;
  --surface-2:    #27272a;
  --border:       #3f3f46;
  --border-hover: #71717a;
  --accent:       #6366f1;
  --accent-hover: #818cf8;
  --accent-muted: rgba(99, 102, 241, 0.12);
  --accent-ring:  rgba(99, 102, 241, 0.4);
  --text:         #fafafa;
  --text-muted:   #a1a1aa;
  --text-subtle:  #71717a;
  --success:      #22c55e;
  --success-muted:rgba(34, 197, 94, 0.12);
  --error:        #f87171;
  --error-muted:  rgba(248, 113, 113, 0.12);
  --radius:       8px;
  --radius-lg:    12px;
  --radius-xl:    16px;
  --ease:         cubic-bezier(0.16, 1, 0.3, 1);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Layout ────────────────────────────────────────────────────────────────── */

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 20px 80px;
}

/* ── Header ────────────────────────────────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 36px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  background: var(--accent-muted);
  color: var(--accent-hover);
  flex-shrink: 0;
}

.header-text h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.subtitle {
  color: var(--text-subtle);
  font-size: 13px;
  margin-top: 2px;
}

/* ── Drop Zone ─────────────────────────────────────────────────────────────── */

.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  padding: 52px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  outline: none;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.dropzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-muted);
  border-style: solid;
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.dz-icon { color: var(--text-subtle); }
.dropzone:hover .dz-icon,
.dropzone:focus-visible .dz-icon,
.dropzone.drag-over .dz-icon { color: var(--accent-hover); }

.dz-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  margin-top: 4px;
}

.dz-hint { color: var(--text-muted); }

.browse-label {
  color: var(--accent-hover);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  pointer-events: all;
}

.browse-label:hover { color: var(--text); }

.dz-types {
  font-size: 12px;
  color: var(--text-subtle);
  margin-top: 4px;
}

/* ── File Section ──────────────────────────────────────────────────────────── */

.file-section {
  margin-top: 20px;
  animation: fadeUp 0.2s var(--ease) both;
}

.file-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.file-count {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Thumbnails ────────────────────────────────────────────────────────────── */

.thumbnails {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.thumb {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface-2);
  aspect-ratio: 1;
  animation: fadeUp 0.18s var(--ease) both;
}

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

.thumb-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, transparent 55%);
}

.thumb-name {
  position: absolute;
  bottom: 6px;
  left: 7px;
  right: 28px;
  font-size: 10px;
  color: #e4e4e7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thumb-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.6);
  color: #d4d4d8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.1s, background 0.1s;
  font-size: 14px;
  line-height: 1;
}

.thumb:hover .thumb-remove { opacity: 1; }
.thumb-remove:hover { background: rgba(0,0,0,0.85); color: white; }

/* ── Controls ──────────────────────────────────────────────────────────────── */

.controls {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fadeUp 0.2s var(--ease) both;
}

.mode-toggle {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}

.mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.mode-btn:hover { color: var(--text); }

.mode-btn.active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, box-shadow 0.12s, transform 0.1s;
  letter-spacing: 0.01em;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.btn-primary:active { transform: scale(0.98); }

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-subtle);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}

.btn-ghost:hover { color: var(--text); background: var(--surface-2); }

.btn-sm { padding: 4px 8px; font-size: 12px; }

/* ── Spinner ───────────────────────────────────────────────────────────────── */

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

.spinner { animation: spin 0.7s linear infinite; }

.hidden { display: none !important; }

/* ── Downloads ─────────────────────────────────────────────────────────────── */

.downloads {
  margin-top: 20px;
  animation: fadeUp 0.22s var(--ease) both;
}

.downloads-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--success);
  margin-bottom: 12px;
}

.downloads-note {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-subtle);
  font-weight: 400;
}

.download-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.download-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  animation: fadeUp 0.18s var(--ease) both;
}

.download-item-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--success-muted);
  color: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.download-item-info {
  flex: 1;
  min-width: 0;
}

.download-item-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.download-item-meta {
  font-size: 11px;
  color: var(--text-subtle);
  margin-top: 2px;
}

.download-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}

.download-btn:hover {
  background: var(--border);
  border-color: var(--border-hover);
}

.download-btn.downloaded {
  color: var(--text-subtle);
  cursor: default;
  pointer-events: none;
}

/* ── Error Banner ──────────────────────────────────────────────────────────── */

.error-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(248, 113, 113, 0.3);
  background: var(--error-muted);
  color: var(--error);
  font-size: 13px;
  animation: fadeUp 0.18s var(--ease) both;
}

/* ── Animations ────────────────────────────────────────────────────────────── */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .container { padding: 28px 16px 60px; }
  .dropzone { padding: 36px 16px; }
  .thumbnails { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .download-item { flex-wrap: wrap; }
  .download-btn { width: 100%; justify-content: center; }
}
