.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 22px 16px calc(40px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.head { display: flex; align-items: center; gap: 14px; padding: 6px 4px; }
.pad { padding: 18px; }
.label { display: block; font-weight: 600; margin-bottom: 8px; }
.small { font-size: 13px; }
.muted.small { margin: 8px 0 0; }

.picker { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.btn.big { padding: 18px; font-size: 17px; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.thumb {
  width: 52px; height: 52px; border-radius: 10px; object-fit: cover;
  background: #f3ede6; flex: none;
}
.meta { flex: 1; min-width: 0; }
.fname { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.state { font-size: 13px; margin-top: 3px; display: flex; align-items: center; gap: 6px; }
.state.uploading { color: var(--warn); }
.state.success { color: var(--ok); }
.state.failed { color: var(--err); }

.bar { height: 5px; background: #f1ece6; border-radius: 999px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; width: 0; background: var(--grad); transition: width 0.2s ease; }

.retry {
  appearance: none; border: 1.5px solid var(--err); color: var(--err);
  background: #fff; border-radius: 999px; padding: 7px 14px; font-weight: 600;
  font-size: 13px; cursor: pointer; flex: none;
}
.spin { width: 14px; height: 14px; border: 2px solid #e9c98a; border-top-color: var(--warn);
  border-radius: 50%; display: inline-block; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.foot { margin-top: 8px; }

/* --- Landing gallery ----------------------------------------------------- */
/* Leave room at the bottom so the FAB never covers the last row of tiles. */
.wrap { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

.counts {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 14px; color: var(--muted); margin: 2px 0 4px;
}
.counts strong { color: var(--ink); }
.counts .dot { opacity: 0.5; }

/* Two JS-balanced columns of mixed-height tiles. */
.gallery { display: flex; gap: 10px; align-items: flex-start; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }

.tile {
  appearance: none; border: none; padding: 0; margin: 0; cursor: pointer;
  display: block; width: 100%; border-radius: 14px; overflow: hidden;
  background: #f3ede6; position: relative; box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile:active { transform: scale(0.985); }
.tile .play {
  position: absolute; inset: 0; margin: auto; width: 46px; height: 46px;
  display: grid; place-items: center; border-radius: 50%; color: #fff;
  background: rgba(0, 0, 0, 0.42); font-size: 16px; padding-left: 3px;
  backdrop-filter: blur(2px);
}

.empty { padding: 48px 16px; }
.end { padding: 16px 0 4px; }
.sentinel { height: 1px; }

/* --- Floating upload button ---------------------------------------------- */
.fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 30; padding: 16px 28px; font-size: 16px;
  box-shadow: 0 8px 28px rgba(242, 101, 34, 0.35);
}
.fab:active { transform: translateX(-50%) translateY(1px); }

/* --- Upload sheet -------------------------------------------------------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(42, 33, 24, 0.45);
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-width: 560px; margin: 0 auto;
  background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(42, 33, 24, 0.18);
  max-height: 88vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
  transform: translateY(100%); transition: transform 0.25s ease;
}
.sheet.open { transform: translateY(0); }
.sheet-grip { width: 40px; height: 4px; border-radius: 999px; background: var(--line); margin: 2px auto 4px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-close {
  appearance: none; border: none; background: transparent; color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 4px 8px;
}

/* --- Lightbox ------------------------------------------------------------ */
.lightbox {
  position: fixed; inset: 0; z-index: 60; background: rgba(20, 14, 8, 0.92);
  display: flex; align-items: center; justify-content: center;
}
.lb-stage { max-width: 100vw; max-height: 100vh; display: grid; place-items: center; padding: 16px; }
.lb-stage img, .lb-stage video {
  max-width: 96vw; max-height: 86vh; border-radius: 12px; object-fit: contain;
}
.lb-close {
  position: fixed; top: calc(12px + env(safe-area-inset-top)); right: 14px;
  appearance: none; border: none; background: rgba(255, 255, 255, 0.14);
  color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 18px;
  cursor: pointer; z-index: 61;
}
.lb-nav {
  position: fixed; top: 50%; transform: translateY(-50%);
  appearance: none; border: none; background: rgba(255, 255, 255, 0.14);
  color: #fff; width: 44px; height: 44px; border-radius: 50%; font-size: 26px;
  line-height: 1; cursor: pointer; z-index: 61;
}
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
.lb-name {
  position: fixed; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom));
  text-align: center; color: #f3ede6; font-size: 13px;
}
