:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --primary: #3b82f6;
  --success: #10b981;
  --error: #ef4444;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji';
  color: var(--text);
  background: var(--bg);
}

.header { max-width: 800px; margin: 24px auto 8px; padding: 0 16px; }
.title { margin: 0 0 8px; font-size: 28px; font-weight: 700; }
.subtitle { margin: 0; color: #475569; }

.container {
  max-width: 800px;
  /* Use padding-bottom instead of margin-bottom to avoid margin-collapsing
     so content can scroll above the fixed sticky footer. */
  margin: 16px auto;
  padding: 0 16px 140px;
  /* Account for iOS/Android safe areas and ensure extra room for actions */
  padding-bottom: calc(140px + env(safe-area-inset-bottom));
}

.dropzone {
  position: relative;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: 14px;
  padding: 32px;
  text-align: center;
  transition: border-color .2s ease, box-shadow .2s ease;
  outline: none;
  cursor: pointer;
}
.dropzone:focus, .dropzone.dragover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .2);
}
.file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 1; }
.dz-inner { position: relative; z-index: 2; }
.dz-title { margin: 8px 0 4px; font-weight: 600; }
.dz-sub { margin: 0 0 12px; color: #64748b; }

.btn-alt {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
}
.btn-alt:hover { border-color: #cbd5e1; }

.helper { margin-top: 8px; font-size: 12px; color: #64748b; }

.files {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.file-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.file-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.06); border-color: #dbe3ee; }
.file-card.success::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--success);
  font-weight: 700;
  font-size: 48px;
  background: rgba(255,255,255,0.75);
}

.file-card.fade-out { animation: fadeOut .5s ease forwards; }
@keyframes fadeOut { to { opacity: 0; transform: scale(0.98); } }
.thumb { width: 100%; height: 120px; object-fit: cover; border-radius: 8px; background: #f1f5f9; }
.name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { font-size: 12px; color: #64748b; }
.actions { display: flex; gap: 8px; }
.btn-remove { background: transparent; border: none; color: #ef4444; cursor: pointer; font-size: 12px; }
.btn-remove:hover { text-decoration: underline; }
.btn-remove:disabled { opacity: .45; cursor: not-allowed; text-decoration: none; }

.progress {
  height: 6px;
  background: #eef2f7;
  border-radius: 999px;
  overflow: hidden;
}
.progress.hidden { display: none; }
.bar { height: 100%; width: 0%; background: var(--primary); transition: width .2s ease; }

.sticky {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,.9);
  border-top: 1px solid var(--border);
  backdrop-filter: saturate(1.2) blur(6px);
}
.sticky-content { max-width: 800px; margin: 0 auto; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; }

.btn-primary {
  border: none; background: var(--primary); color: #fff; font-weight: 600; padding: 10px 16px; border-radius: 10px; cursor: pointer;
}
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.toast { position: fixed; right: 16px; bottom: 72px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; box-shadow: 0 10px 30px rgba(0,0,0,.06); opacity: 0; transform: translateY(10px); transition: all .25s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { border-color: rgba(16,185,129,.4); }
.toast.err { border-color: rgba(239,68,68,.4); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 14px; border: 1px solid var(--border); max-width: 520px; width: 100%; padding: 22px; text-align: center; }
.modal h2 { margin: 0 0 8px; }
.modal p { margin: 0 0 16px; color: #475569; font-size: 15px; }

@media (max-width: 768px) {
  .title { font-size: 22px; }
  .thumb { height: 100px; }
  .sticky-content { padding: 10px 12px; }
  .btn-alt { padding: 14px 18px; }
}
