html, body {
  overflow-y: auto;
  overflow-x: hidden;
}

body {
  background: #000000;
  color: #fff;
  min-height: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

#gallery-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 14px 12px;
  background: #000000;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

#back-btn {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.85);
}

#back-btn .back-arrow {
  font-size: 15px;
  line-height: 1;
}

#back-btn:active {
  color: #fff;
}

#gallery-header h1 {
  font-family: 'Archivo-Medium', 'Archivo-Variable', sans-serif;
  font-size: 12px;
  font-weight: 400;
  margin-left: auto;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.03em;
  text-transform: lowercase;
}

#grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 4px;
}

@media (min-width: 700px) {
  #grid { grid-template-columns: repeat(3, 1fr); }
}

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

.cell {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #0a0a0a;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}

.cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  transition: transform 200ms ease;
}

.cell.swiping img {
  transition: none;
}

.cell.removing {
  transition: opacity 200ms ease, transform 200ms ease;
  opacity: 0;
  transform: scale(0.95);
}

.cell .del-btn {
  position: absolute;
  top: 2px;
  right: 4px;
  width: 22px;
  height: 22px;
  padding: 0;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.55);
  font-size: 30px;
  line-height: 0.5;
  font-weight: 10;
  z-index: 2;
}

.cell .del-btn:active {
  color: rgba(255, 255, 255, 0.95);
}

#empty-state {
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  padding: 80px 20px;
  font-size: 13px;
}

#viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.98);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
}

#viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

#viewer-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 14px;
  width: 36px;
  height: 36px;
  font-size: 26px;
  line-height: 36px;
  text-align: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

#viewer-meta {
  position: absolute;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.04em;
}

#confirm {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.confirm-card {
  background: #111;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.confirm-card p {
  font-size: 14px;
  margin-bottom: 16px;
  color: rgba(255, 255, 255, 0.9);
}

.confirm-actions {
  display: flex;
  gap: 8px;
}

.confirm-actions button {
  flex: 1;
  padding: 10px;
  font-size: 13px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

#confirm-ok {
  background: rgba(220, 60, 60, 0.85) !important;
}

#confirm-cancel:active { background: rgba(255, 255, 255, 0.15); }
#confirm-ok:active { background: rgba(220, 60, 60, 1) !important; }
