/* === EDIT MODE === */
.edit-bar[hidden] { display: none !important; }

.edit-bar {
  position: sticky;
  top: 79px;
  z-index: 11;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;

  padding: 10px 12px;
  margin: 0 12px 12px 12px;

  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(20,20,24,0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.edit-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* ✅ LIGHT MODE overrides for Edit Bar */
@media (prefers-color-scheme: light) {
  .edit-bar {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.12);
    color: #111;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
  }

  .edit-status {
    color: #111;
    opacity: 0.75;
  }

  .edit-bar button {
    background: rgba(0, 0, 0, 0.06);
    color: #111;
    border: 1px solid rgba(0, 0, 0, 0.12);
  }

  .edit-bar button:hover {
    background: rgba(0, 0, 0, 0.10);
  }

  .edit-bar .btn-primary {
    background: rgba(255,215,120,0.95);
    color: #111;
    border: 0;
  }
}

.edit-status {
  flex: 1 1 auto;
  min-width: 160px;
  font-size: 12px;
  opacity: 0.9;
}
.edit-caps {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
  margin-left: 6px;
}

.cap-pill {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  background: rgba(255,255,255,0.20);
  border: 1px solid rgba(0,0,0,0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

@media (prefers-color-scheme: dark) {
  .cap-pill {
    background: rgba(15,16,18,0.55);
    border: 1px solid rgba(255,255,255,0.10);
  }
}

.cap-ico { font-size: 13px; }
.cap-txt { opacity: 0.95; }

/* SVG icon sizing for the top counters (avoid giant icons on mobile) */
.cap-ico-svg {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.edit-wrap[hidden] { display: none !important; }

.edit-wrap {
  --edit-cols: 3;
  padding: 0 12px 110px 12px;
}

/* Bottom action bar (phone-first, edit mode) */
.edit-bottom-bar[hidden] { display: none !important; }

.edit-bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1150;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;

  padding: 10px 10px calc(10px + env(safe-area-inset-bottom)) 10px;

  background: rgba(20,20,24,0.82);
  border-top: 1px solid rgba(255,255,255,0.14);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

@media (prefers-color-scheme: light) {
  .edit-bottom-bar {
    background: rgba(255,255,255,0.92);
    border-top: 1px solid rgba(0,0,0,0.12);
  }
}

body.selection-mode .edit-bottom-bar { display: none !important; }

.bottom-action {
  flex: 1 1 0;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 6px 6px;
  border-radius: 12px;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;

  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.bottom-action:active {
  background: rgba(255,255,255,0.10);
}
@media (prefers-color-scheme: light) {
  .bottom-action:active { background: rgba(0,0,0,0.06); }
}

.bottom-ico {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bottom-ico svg,
.cap-ico-svg svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bottom-label {
  font-size: 11px;
  line-height: 1;
  opacity: 0.92;
  white-space: nowrap;
}

.bottom-primary {
  flex: 1.15 1 0;
  padding-top: 8px;
  padding-bottom: 8px;
  border-radius: 12px;
  background: rgba(240, 205, 120, 0.92);
  color: rgba(0,0,0,0.88);
  border: 1px solid rgba(0,0,0,0.10);
}

.bottom-primary:active {
  background: rgba(240, 205, 120, 0.78);
}

@media (prefers-color-scheme: dark) {
  .bottom-primary {
    border: 1px solid rgba(255,255,255,0.12);
  }
}

.edit-section { margin-top: 10px; }

.edit-section-title { font-size: 13px; opacity: 0.85; margin: 8px 2px; }

.edit-grid {
  display: grid;
  grid-template-columns: repeat(var(--edit-cols), minmax(0, 1fr));
  gap: 10px;
}

/* ✅ IMPORTANT: allow page scroll in edit mode tiles. */
.tile {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  user-select: none;
  touch-action: pan-y;
}

.tile img,
.tile video {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

.tile video { background: #000; }

.tile-actions {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.tile-actions button {
  pointer-events: auto;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.35);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.tile-actions button:hover { background: rgba(0,0,0,0.5); }

.drag-handle {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;

  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.35);
  color: #fff;

  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;

  cursor: pointer;
  -webkit-tap-highlight-color: transparent;

  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.edit-wrap.reorder-armed .drag-handle {
  background: rgba(255,215,120,0.30);
  border-color: rgba(255,215,120,0.55);
  color: #111;
}

.tile img,
.tile video {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

.tile-badge {
  pointer-events: none;
  z-index: 6;
  position: absolute;
  bottom: 8px;
  left: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.16);
  opacity: 0.95;
}

.tile-badge.READY { background: rgba(10,122,47,0.45); }
.tile-badge.PROCESSING { background: rgba(138,90,0,0.50); }
.tile-badge.UPLOADING { background: rgba(11,92,173,0.50); }
.tile-badge.FAILED { background: rgba(176,0,32,0.55); }

.tile-ghost { opacity: 0.35; }
.tile-drag { cursor: grab; }

/* === MULTI-SELECT (EDIT MODE) === */
.select-bar[hidden] { display: none !important; }

.select-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  padding:
    10px
    max(12px, env(safe-area-inset-right))
    calc(10px + env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));

  border-top: 1px solid rgba(255,255,255,0.14);
  background: rgba(20,20,24,0.80);
  backdrop-filter: blur(10px);
}

@media (prefers-color-scheme: light) {
  .select-bar {
    background: rgba(255,255,255,0.95);
    border-top: 1px solid rgba(0,0,0,0.12);
  }
}

.select-left {
  display: flex;
  gap: 10px;
  align-items: center;
}

body.selection-mode .edit-wrap {
  padding-bottom: calc(18px + 74px + env(safe-area-inset-bottom));
}

body.selection-mode .drag-handle {
  opacity: 0;
  pointer-events: none;
}

.tile .select-overlay {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  pointer-events: none;
  display: none;
}

.tile.is-selected .select-overlay {
  display: block;
  background: rgba(255,215,120,0.18);
  border: 2px solid rgba(255,215,120,0.70);
  box-shadow: 0 6px 22px rgba(0,0,0,0.28);
}

.tile .select-check {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
  color: #111;
  background: rgba(255,215,120,0.95);
  border: 1px solid rgba(0,0,0,0.18);
}

/* ===== Edit grid: keep tiles square (no stretching) ===== */
.edit-grid .tile {
  aspect-ratio: 1 / 1;
}

.edit-grid .tile img,
.edit-grid .tile video,
.edit-grid .tile .tile-placeholder {
  width: 100%;
  height: 100%;
}

.edit-grid .tile img,
.edit-grid .tile video {
  object-fit: cover;
}

.edit-grid .tile img,
.edit-grid .tile video {
  height: 100%;
}

.edit-grid .tile .tile-placeholder {
  position: absolute;
  inset: 0;
}

.edit-grid .tile .tile-placeholder {
  display: grid;
  place-items: center;
  font-size: 12px;
  opacity: 0.8;
}

/* ===== Dense-grid controls ===== */
.tile-more {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 7;

  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.38);
  color: #fff;

  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.tile-more svg { display: block; }

#editWrap[data-cols="4"] .tile-actions,
#editWrap[data-cols="5"] .tile-actions,
#editWrap[data-cols="6"] .tile-actions,
#editWrap[data-cols="4"] .drag-handle,
#editWrap[data-cols="5"] .drag-handle,
#editWrap[data-cols="6"] .drag-handle,
#editWrap[data-cols="4"] .tile-badge,
#editWrap[data-cols="5"] .tile-badge,
#editWrap[data-cols="6"] .tile-badge {
  display: none !important;
}

#editWrap[data-cols="4"] .tile-more,
#editWrap[data-cols="5"] .tile-more,
#editWrap[data-cols="6"] .tile-more {
  display: none !important;
}

/* ===== Action sheet ===== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 99999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.sheet {
  width: min(520px, 100%);
  background: rgba(18,18,20,0.98);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.35);
}

.sheet-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.sheet-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: #fff;
  border-radius: 12px;
  padding: 12px 10px;
  display: grid;
  place-items: center;
  gap: 8px;
}

.sheet-btn .sheet-ico svg {
  width: 22px;
  height: 22px;
}

.sheet-btn.danger {
  border-color: rgba(255,120,120,0.35);
}

.sheet-btn.is-on {
  background: rgba(255,215,120,0.18);
  border-color: rgba(255,215,120,0.35);
}

.sheet-close {
  margin-top: 10px;
  width: 100%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: #fff;
  border-radius: 12px;
  padding: 12px 10px;
}
