/* Story viewer: views UI, list panel, delete confirm above Zuck */

#zuck-modal-content .story-viewer {
  position: relative;
}

/* Physical devices: avoid clipping position:fixed UI under overflow:hidden */
#zuck-modal-content .story-viewer.viewing {
  overflow: visible !important;
  isolation: isolate;
}

/* Story header: username + time, left-aligned */
#zuck-modal-content .story-viewer .head .left {
  text-align: start;
}

#zuck-modal-content .story-viewer .head .left .info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 2px;
  min-width: 0;
  text-align: start;
}

#zuck-modal-content .story-viewer .head .left .info > * {
  display: block;
  width: auto !important;
  max-width: 100%;
  text-align: start;
  line-height: 1.25;
}

#zuck-modal-content .story-viewer .head .left .info .name {
  font-weight: 400;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#zuck-modal-content .story-viewer .head .left .info .time {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  align-self: flex-start;
}

/* Never show duplicate time in .right */
#zuck-modal-content .story-viewer .head .right .time {
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  position: absolute !important;
  pointer-events: none !important;
}

/* ── Desktop header ── */
@media (min-width: 769px) {
  #zuck-modal-content .story-viewer .head {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    line-height: 1.2;
    height: auto;
    min-height: 56px;
    box-sizing: border-box;
  }

  #zuck-modal-content .story-viewer .head .left {
    float: none !important;
    display: flex;
    flex-direction: row;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
  }

  #zuck-modal-content .story-viewer .head .left .item-preview {
    flex-shrink: 0;
  }

  #zuck-modal-content .story-viewer .head .right {
    float: none !important;
    display: flex;
    flex-direction: row;
    align-items: center;
    flex: 0 0 auto;
    line-height: 1;
  }

  #zuck-modal-content .story-viewer .head .sngine-story-delete {
    align-self: center;
  }

  #zuck-modal-content .story-viewer .head .right .close {
    align-self: center;
  }
}

/* ── Mobile: immersive full-viewport (Instagram-style) ── */
@media (max-width: 768px) {

  /* Use dvh so browser chrome (address bar, nav bar) is excluded */
  #zuck-modal {
    min-height: 100dvh;
    height: 100dvh;
    max-height: 100dvh;
    background: #000 !important;
  }

  #zuck-modal-content,
  #zuck-modal-content .story-viewer,
  #zuck-modal-content .story-viewer > .slides,
  #zuck-modal-content .story-viewer > .slides > .item {
    min-height: 100dvh;
    height: 100dvh;
    max-height: 100dvh;
    background: #000;
  }

  /* Story image/video: full width, letterboxed, never cropped */
  #zuck-modal-content .story-viewer .slides .item > .media,
  #zuck-modal-content .story-viewer .slides .item > img.media,
  #zuck-modal-content .story-viewer .slides .item > video.media {
    width: 100% !important;
    height: 100% !important;
    min-height: 100dvh !important;
    max-height: none !important;
    object-fit: contain !important;
    object-position: center center;
    background: #000;
  }

  /* Header: below progress bar */
  #zuck-modal-content .story-viewer .head {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    line-height: 1.2;
    height: auto;
    min-height: 56px;
    padding-top: 22px;
    padding-bottom: 6px;
    box-sizing: border-box;
  }

  #zuck-modal-content .story-viewer .head .left {
    float: none !important;
    display: flex;
    flex-direction: row;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    max-width: calc(100% - 120px);
    margin: 0;
  }

  #zuck-modal-content .story-viewer .head .left .item-preview {
    flex-shrink: 0;
    align-self: center;
  }

  /* Mobile: "username • time" on one line */
  #zuck-modal-content .story-viewer .head .left .info {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: baseline;
    gap: 0;
    flex: 1 1 auto;
    min-width: 0;
    overflow: visible;
    visibility: visible;
  }

  #zuck-modal-content .story-viewer .head .left .info > * {
    display: block;
    width: auto !important;
    max-width: none;
    line-height: 1.25;
    visibility: visible;
  }

  #zuck-modal-content .story-viewer .head .left .info .name {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #fff;
    opacity: 1;
  }

  #zuck-modal-content .story-viewer .head .left .info .time {
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 400;
    color: #fff;
    opacity: 0.8;
    align-self: baseline;
    white-space: nowrap;
    visibility: visible !important;
    display: block !important;
    -webkit-text-fill-color: #fff;
  }

  #zuck-modal-content .story-viewer .head .left .info .time::before {
    content: "\00a0\2022\00a0";
    font-weight: 400;
  }

  #zuck-modal-content .story-viewer .head .right {
    float: none !important;
    display: flex;
    flex-direction: row;
    align-items: center;
    flex: 0 0 auto;
    line-height: 1;
    margin: 0;
  }

  #zuck-modal-content .story-viewer .head .sngine-story-delete {
    padding: 4px 8px;
    margin: 0 4px 0 0;
    align-self: center;
  }

  #zuck-modal-content .story-viewer .head .right .close {
    align-self: center;
  }
}

/* ── Delete confirmation modal above Zuck (z-index: 100000) ── */
body.sngine-story-delete-confirm.modal-open #modal.modal {
  z-index: 999999 !important;
}

body.sngine-story-delete-confirm.modal-open .modal-backdrop {
  z-index: 999998 !important;
}

body.sngine-story-delete-confirm #modal .modal-dialog {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  margin: 0 !important;
  max-width: min(500px, calc(100vw - 2rem));
}

/* ── Views UI root ── */
.sngine-story-views-ui {
  position: static;
  pointer-events: none;
}

/* ── Pills: fixed to viewport bottom-left on the active viewer ── */
#zuck-modal .sngine-story-views-zero-pill,
#zuck-modal .sngine-story-viewers-pill {
  position: fixed;
  left: 16px;
  right: auto;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  z-index: 200100;
  will-change: transform;
}

#zuck-modal .sngine-story-views-panel {
  position: fixed;
  left: 16px;
  right: auto;
  bottom: calc(124px + env(safe-area-inset-bottom, 0px));
  transform: translateZ(0) translateY(12px);
  -webkit-transform: translateZ(0) translateY(12px);
  z-index: 200101;
  will-change: transform;
}

/* RTL */
#zuck-modal.rtl .sngine-story-views-zero-pill,
#zuck-modal.rtl .sngine-story-viewers-pill {
  left: auto;
  right: 16px;
}

#zuck-modal.rtl .sngine-story-views-panel {
  left: auto;
  right: 16px;
}

/* ── Zero views pill ── */
.sngine-story-views-zero-pill {
  display: none;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  opacity: 0.8;
  pointer-events: none;
  cursor: default;
  max-width: min(420px, calc(100vw - 32px));
  box-sizing: border-box;
  user-select: none;
}

.sngine-story-views-zero-icon {
  flex-shrink: 0;
  font-size: 1.05rem;
  line-height: 1;
}

.sngine-story-views-zero-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Viewers pill ── */
.sngine-story-viewers-pill {
  display: none;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  pointer-events: auto;
  cursor: pointer;
  max-width: min(420px, calc(100vw - 32px));
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

.sngine-story-viewers-avatars {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  flex-shrink: 0;
}

.sngine-story-viewer-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
  margin-left: -8px;
  flex-shrink: 0;
}

.sngine-story-viewer-avatar:last-child {
  margin-left: 0;
}

.sngine-story-viewers-count {
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Expanded viewers panel ── */
.sngine-story-views-panel {
  width: min(320px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  pointer-events: none;
  opacity: 0;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.sngine-story-views-panel.is-open {
  pointer-events: auto;
  opacity: 1;
  transform: translateZ(0) translateY(0) !important;
  -webkit-transform: translateZ(0) translateY(0) !important;
}

.sngine-story-views-panel-inner {
  max-height: 300px;
  overflow-y: auto;
  padding: 10px;
  -webkit-overflow-scrolling: touch;
}

.sngine-story-viewer-list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 10px;
  color: #fff;
}

.sngine-story-viewer-list-row:last-of-type {
  margin-bottom: 0;
}

.sngine-story-viewer-list-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.35);
}

.sngine-story-viewer-list-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sngine-story-viewer-verified-badge {
  flex-shrink: 0;
  color: #5fb3ff;
  font-size: 15px;
  line-height: 1;
}

.sngine-story-viewer-list-more {
  padding: 10px 8px 4px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.9;
  color: #fff;
}

/* ── Delete button ── */
.sngine-story-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #fff;
  padding: 4px 10px;
  margin: 0 2px 0 0;
  cursor: pointer;
  opacity: 0.92;
  line-height: 1;
  pointer-events: auto;
  font-size: 16px;
}

.sngine-story-delete:hover,
.sngine-story-delete:focus {
  opacity: 1;
  outline: none;
}

.sngine-story-error-toast {
  min-width: 220px;
}