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

.hidden { display: none !important; }
.row-buttons { margin-top: 16px; display: flex; gap: 10px; }
.error-text { color: var(--error); }

.picker-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.picker-tile {
  background: #f1f5f9;
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.picker-tile:active {
  background: #e2e8f0;
  transform: scale(0.97);
  border-color: var(--primary);
}
.picker-icon { font-size: 2rem; line-height: 1; }
.picker-label { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.picker-sub { font-size: 0.75rem; color: var(--muted); }

.drop-zone-mini {
  margin-top: 14px;
  padding: 14px;
  text-align: center;
  border: 2px dashed var(--border);
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--muted);
  transition: all 0.15s;
}
.drop-zone-mini.dragover {
  border-color: var(--primary);
  background: #eef2ff;
  color: var(--primary);
}

.hint-card { padding: 14px 18px; background: #fffbeb; border: 1px solid #fde68a; }
.hint-card details { font-size: 0.85rem; color: #78350f; }
.hint-card summary { cursor: pointer; font-weight: 600; }
.hint-card p { margin-top: 8px; line-height: 1.6; }
.hint-card strong { color: var(--primary); }

@media (min-width: 480px) {
  .picker-grid { grid-template-columns: repeat(4, 1fr); }
}

.header-actions { display: flex; align-items: center; gap: 12px; }
.header-btn {
  background: rgba(255,255,255,0.2);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.header-btn:active { background: rgba(255,255,255,0.35); }

.action-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
  z-index: 200;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.action-bar-info { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 0.9rem; }
.action-bar-info .header-btn { background: var(--bg); color: var(--text); }
.action-bar-buttons { display: flex; gap: 8px; }
.action-bar-buttons .header-btn { background: var(--bg); color: var(--text); }

.btn-danger {
  background: var(--error);
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: 99px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-danger:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-danger:active:not(:disabled) { transform: scale(0.96); }

body.selecting { padding-bottom: 80px; }

.select-check {
  position: absolute;
  top: 6px; right: 6px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,0.85);
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  border: 2px solid rgba(0,0,0,0.3);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
body.selecting .select-check { opacity: 1; }
.photo-item.selected .select-check {
  background: var(--primary);
  border-color: white;
  color: white;
}
.photo-item.selected {
  outline: 3px solid var(--primary);
  outline-offset: -3px;
}
.photo-item.selected img,
.photo-item.selected video { opacity: 0.7; }

:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --success: #16a34a;
  --error: #dc2626;
  --warning: #d97706;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
}

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

.header {
  background: var(--primary);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header h1 { font-size: 1.1rem; font-weight: 700; }
.header a { color: white; text-decoration: none; font-size: 0.9rem; opacity: 0.9; }
.header a:hover { opacity: 1; }

.container { max-width: 600px; margin: 0 auto; padding: 20px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  margin-bottom: 16px;
}

/* Upload zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background: #eef2ff;
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.drop-zone .icon { font-size: 3rem; margin-bottom: 12px; }
.drop-zone .label { font-size: 1rem; color: var(--muted); }
.drop-zone .hint { font-size: 0.8rem; color: var(--muted); margin-top: 6px; }

/* Preview grid */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.preview-item {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
  position: relative;
}

.preview-item img,
.preview-item video {
  width: 100%; height: 100%;
  object-fit: cover;
}

.media-type-badge {
  position: absolute;
  bottom: 4px; left: 4px;
  background: rgba(0,0,0,0.65);
  color: white;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 99px;
  pointer-events: none;
}

.preview-size {
  position: absolute;
  bottom: 4px; right: 4px;
  background: rgba(0,0,0,0.65);
  color: white;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
}

.preview-progress {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.95rem;
  background: rgba(0,0,0,0.45);
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.preview-item .remove-btn {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 22px; height: 22px;
  font-size: 12px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

.preview-count {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 10px;
}

/* Progress */
.progress-wrap { margin-top: 16px; }
.progress-bar-bg {
  background: var(--border);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width 0.3s;
  width: 0%;
}
.progress-text { font-size: 0.85rem; color: var(--muted); margin-top: 6px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 48px;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; width: 100%; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: #eef2ff; }

/* Status messages */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-top: 12px;
}
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* Result list */
.result-list { list-style: none; }
.result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.result-item:last-child { border-bottom: none; }
.result-item .file-icon { font-size: 1.2rem; flex-shrink: 0; }
.result-item .file-info { flex: 1; min-width: 0; }
.result-item .file-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-item .file-date { color: var(--muted); font-size: 0.8rem; }
.result-item .badge {
  background: #dcfce7;
  color: #166534;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.75rem;
  white-space: nowrap;
}

.result-del-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--error);
  width: 32px; height: 32px;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.result-del-btn:hover:not(:disabled) { background: #fee2e2; border-color: var(--error); }
.result-del-btn:active:not(:disabled) { transform: scale(0.92); }
.result-del-btn:disabled { opacity: 0.5; cursor: default; }

/* Gallery */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-bar select {
  flex: 1;
  min-width: 90px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--card);
  color: var(--text);
}

.date-group { margin-bottom: 20px; }
.date-group-header {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.photo-item {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--border);
  cursor: pointer;
  position: relative;
}

.photo-item img,
.photo-item video {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
}

.photo-item video { pointer-events: none; }

.photo-item:hover img { transform: scale(1.05); }

.photo-item .new-badge {
  position: absolute;
  top: 4px; left: 4px;
  background: var(--primary);
  color: white;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 99px;
  font-weight: 700;
}

/* Stats bar */
.stats-bar {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  gap: 20px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}
.stats-bar .stat-val { font-weight: 700; color: var(--primary); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.modal-overlay.open { display: flex; }
.modal-img { max-width: 95vw; max-height: 80vh; object-fit: contain; border-radius: 8px; }
.modal-info { color: white; margin-top: 12px; font-size: 0.85rem; text-align: center; }
.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-delete {
  position: absolute;
  bottom: 24px;
  background: var(--error);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 99px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.modal-delete:active { transform: scale(0.96); }

@media (min-width: 480px) {
  .preview-grid, .photo-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 640px) {
  .photo-grid { grid-template-columns: repeat(5, 1fr); }
}
