.sp-stories{
  --sp-thumb-size:72px;
  --sp-thumb-spacing:12px;
  --sp-bg: rgba(0,0,0,0.65);
  --sp-caption-bg: rgba(220,220,220,0.70);
  --sp-caption-text: #111111;
  --sp-progress: rgba(255,255,255,0.85);
  --sp-caption-space: 92px;
}

.sp-stories-track{
  display:flex;
  align-items:flex-start;
  gap: var(--sp-thumb-spacing);
  overflow-x:auto;
  padding: 6px 2px;
}
.sp-story{
  border:0;
  background:transparent;
  padding:0;
  cursor:pointer;
  display:inline-flex;
  flex-direction:column;
  align-items:center;
  gap:6px;
  min-width: calc(var(--sp-thumb-size) + 2px);
}
.sp-thumb{
  width: var(--sp-thumb-size);
  height: var(--sp-thumb-size);
  border-radius: 999px;
  overflow:hidden;
  border: 2px solid rgba(255, 0, 120, 0.75);
  display:flex;
  align-items:center;
  justify-content:center;
  box-sizing:border-box;
}
.sp-thumb img{ width:100%; height:100%; object-fit:cover; display:block; }
.sp-thumb-fallback{
  background: rgba(0,0,0,0.08);
  border-color: rgba(0,0,0,0.12);
  color:#111;
  font-weight:700;
}
.sp-title{
  font-size:12px;
  line-height:1.1;
  max-width: calc(var(--sp-thumb-size) + 18px);
  text-align:center;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  color: var(--sp-caption-text);
}
.sp-thumb-add{
  border-style:dashed;
  border-color: rgba(0,0,0,0.18);
  background: rgba(0,0,0,0.05);
}
.sp-plus{ font-size: 34px; line-height: 1; color:#111; }

/* Viewer */
.sp-viewer{
  position:fixed;
  inset:0;
  display:none;
  z-index:99999;
  background: var(--sp-bg);
}
.sp-viewer.is-open{ display:flex; flex-direction:column; }
.sp-topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 10px 12px;
  color:#fff;
}
.sp-top-actions{ display:flex; align-items:center; gap:10px; }

.sp-close, .sp-delbtn{
  border:0;
  background: rgba(255,255,255,0.10);
  color:#fff;
  border-radius: 10px;
  width:40px;
  height:40px;
  cursor:pointer;
  font-size:20px;
  line-height:40px;
  display:none;
  align-items:center;
  justify-content:center;
}
.sp-close{ display:inline-flex; font-size:22px; }
.sp-delbtn.is-show{ display:inline-flex; }

.sp-progress{
  display:flex;
  gap:6px;
  padding: 0 12px 10px 12px;
}
.sp-progress > span{
  flex:1;
  height:3px;
  background: rgba(255,255,255,0.18);
  border-radius:999px;
  overflow:hidden;
}
.sp-progress > span > i{
  display:block;
  height:100%;
  width:0%;
  background: var(--sp-progress);
}

.sp-stage{
  position:relative;
  flex:1;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  box-sizing:border-box;
  padding-bottom: 0;
}
.sp-media{
  width:100%;
  height: 100%;
  display:flex;
  align-items:center;
  justify-content:center;
}
.sp-media img, .sp-media video{
  width:auto;
  height:auto;
  max-width: 92vw;
  max-height: calc(92vh - 120px);
  object-fit:contain;
  display:block;
}

.sp-caption{
  flex:1;
  font-size: 14px;
  line-height: 1.25;
}
.sp-caption-overlay{
  flex:0 0 auto;
  margin: 0 12px 12px 12px;
  display:none;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--sp-caption-bg);
  color: var(--sp-caption-text);
  box-sizing:border-box;
}

.sp-link{
  flex:0 0 auto;
  padding: 8px 10px;
  border-radius: 12px;
  text-decoration:none;
  background: rgba(0,0,0,0.08);
  color: inherit;
  font-size: 13px;
}

/* Upload modal */
.sp-upload-modal{ position:fixed; inset:0; z-index:100000; display:none; }
.sp-upload-modal.is-open{ display:block; }
.sp-upload-backdrop{ position:absolute; inset:0; background: rgba(0,0,0,0.55); }
.sp-upload-panel{ position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); width:min(720px, 92vw); max-height: 85vh; overflow:auto; background:#fff; border-radius:14px; padding:14px; box-shadow: 0 12px 40px rgba(0,0,0,0.35); }
.sp-upload-panel h3{ margin:0 0 10px 0; }
.sp-upload-row{ display:flex; gap:12px; padding:10px 0; border-top:1px solid #eee; }
.sp-upload-row:first-of-type{ border-top:0; }
.sp-upload-thumb{ width:72px; height:72px; border-radius:12px; background:#f2f2f2; display:flex; align-items:center; justify-content:center; overflow:hidden; flex:0 0 auto; }
.sp-upload-thumb img{ width:100%; height:100%; object-fit:cover; display:block; }
.sp-upload-fields{ flex:1; }
.sp-upload-fields label{ display:block; font-size:12px; margin:0 0 4px 0; color:#333; }
.sp-upload-fields textarea{ width:100%; min-height:60px; resize: both; }
.sp-upload-fields input[type='text']{ width:100%; }
.sp-upload-actions{ display:flex; justify-content:flex-end; gap:10px; margin-top:12px; }
.sp-btn{ border:0; padding:10px 14px; border-radius:10px; cursor:pointer; }
.sp-btn.primary{ background:#111; color:#fff; }
.sp-btn.ghost{ background:#eee; color:#111; }
.sp-upload-small{ font-size:12px; color:#666; margin-top:6px; }

@media (max-width: 600px){
  .sp-stories{ --sp-caption-space: 96px; }
  .sp-media img, .sp-media video{ max-width: 94vw; max-height: calc(94vh - 130px); }
}

.sp-audio{ border:0; background: rgba(255,255,255,0.10); color:#fff; border-radius:10px; width:40px; height:40px; cursor:pointer; font-size:18px; line-height:40px; display:inline-flex; align-items:center; justify-content:center; }

.sp-play{ border:0; background: rgba(255,255,255,0.10); color:#fff; border-radius:10px; width:40px; height:40px; cursor:pointer; font-size:18px; line-height:40px; display:inline-flex; align-items:center; justify-content:center; }


@media (max-width: 820px){
  /* iOS/Safari sometimes overlays big native controls even when controls=false */
  .sp-media video::-webkit-media-controls,
  .sp-media video::-webkit-media-controls-panel,
  .sp-media video::-webkit-media-controls-enclosure,
  .sp-media video::-webkit-media-controls-overlay-enclosure,
  .sp-media video::-webkit-media-controls-play-button,
  .sp-media video::-webkit-media-controls-start-playback-button,
  .sp-media video::-webkit-media-controls-timeline,
  .sp-media video::-webkit-media-controls-current-time-display,
  .sp-media video::-webkit-media-controls-time-remaining-display,
  .sp-media video::-webkit-media-controls-mute-button,
  .sp-media video::-webkit-media-controls-fullscreen-button,
  .sp-media video::-webkit-media-controls-volume-slider{
    display:none !important;
    -webkit-appearance:none !important;
  }
}

@media (max-width: 820px){ .sp-media video{ pointer-events:none !important; } }

/* v0.1.20 - suppress video controls */
.sp-viewer video{ pointer-events:none; }
.sp-viewer video::-webkit-media-controls{ display:none !important; }
.sp-viewer video::-webkit-media-controls-enclosure{ display:none !important; }
.sp-viewer video::-webkit-media-controls-panel{ display:none !important; }
.sp-viewer video::-webkit-media-controls-play-button{ display:none !important; }
.sp-viewer video::-webkit-media-controls-start-playback-button{ display:none !important; }
.sp-audio,.sp-play{ display:none !important; }

/* v0.1.21 - avatar thumbnails */
.sp-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}


/* Social (likes/comments) */
.sp-social-row{
  display:flex;
  gap:10px;
  align-items:center;
  margin-top:6px;
}
.sp-like-btn,
.sp-comment-btn{
  appearance:none;
  background:rgba(0,0,0,.35);
  color:#fff;
  border:1px solid rgba(255,255,255,.25);
  padding:6px 10px;
  font-size:14px;
  line-height:1;
  cursor:pointer;
  border-radius:0;
}
.sp-like-btn.is-liked{
  border-color: rgba(255,255,255,.5);
}
.sp-like-count,
.sp-comment-count{
  font-weight:600;
}

.sp-comments{
  margin-top:8px;
  max-height:160px;
  overflow:auto;
  background:rgba(0,0,0,.35);
  border:1px solid rgba(255,255,255,.15);
  padding:8px;
  border-radius:0;
}
.sp-comment-item{
  display:flex;
  gap:6px;
  align-items:flex-start;
  margin:0 0 6px 0;
  font-size:13px;
}
.sp-comment-author{
  font-weight:700;
}
.sp-comment-empty{
  font-size:13px;
  opacity:.85;
}
.sp-comment-form{
  display:flex;
  gap:8px;
  align-items:flex-end;
  margin-top:8px;
}
.sp-comment-input{
  flex:1;
  width:100%;
  min-height:44px;
  resize:vertical;
  border-radius:0;
}
.sp-comment-send{
  appearance:none;
  background:rgba(0,0,0,.35);
  color:#fff;
  border:1px solid rgba(255,255,255,.25);
  padding:6px 10px;
  cursor:pointer;
  border-radius:0;
}
.sp-comment-login{
  font-size:13px;
  opacity:.9;
}

/* ================= Upload modal — theme/event field ================= */
.sp-upload-theme-row{
  margin: 10px 0 14px;
  padding: 10px 12px;
  background: #f7f7f7;
  border-radius: 8px;
}
.sp-upload-theme-row label{
  display:block;
  font-size:12px;
  font-weight:700;
  margin-bottom:4px;
}
.sp-upload-theme-row input.sp-up-theme{
  width:100%;
  box-sizing:border-box;
  padding:8px 10px;
  border:1px solid #ddd;
  border-radius:6px;
  font-size:14px;
}
.sp-upload-theme-hint{
  font-size:11px;
  color:#888;
  margin-top:4px;
}

/* ================= Wide loop mode ================= */
.sp-wide-story{
  --sp-wide-accent: #ffcc00;
  width: 100%;
  margin: 0 0 16px;
}
.sp-wide-slab{
  position: relative;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  aspect-ratio: 9 / 16; /* sensible default until the real clip's dimensions are known */
  overflow: hidden;
  border-radius: 4px;
  background: #0a0a0c;
  cursor: pointer;
}
.sp-wide-media{
  position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  background:#000;
  cursor: pointer;
}
.sp-wide-media img,
.sp-wide-media video{
  width:100%;
  height:100%;
  object-fit: contain;
  background:#000;
}
.sp-wide-media iframe{
  width:100%;
  height:100%;
  border:0;
  background:#000;
}
.sp-wide-theme{
  position:absolute; top:0; left:0;
  display:flex; align-items:center; gap:7px;
  background: var(--sp-wide-accent);
  padding: 7px 14px 7px 12px;
  border-bottom-right-radius: 6px;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.35);
  width: fit-content;
  max-width: 90%;
}
.sp-wide-dot{
  width:7px; height:7px; border-radius:50%;
  background: #000;
  opacity: 0.85;
  animation: sp-wide-blink 1.4s ease-in-out infinite;
  flex-shrink:0;
}
@keyframes sp-wide-blink{ 0%,100%{opacity:0.85;} 50%{opacity:0.25;} }
.sp-wide-theme-text{
  font-size: 13px;
  font-weight: 700;
  color: #000;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sp-wide-meta{
  position:absolute; bottom:0; left:0; right:0;
  padding: 8px 14px;
  background: linear-gradient(0deg, rgba(0,0,0,0.75), rgba(0,0,0,0));
  display:flex; justify-content:space-between; align-items:center;
  pointer-events: none;
}
.sp-wide-count{
  font-size: 11px;
  color: #eee;
}
.sp-wide-dots{ display:flex; gap:8px; pointer-events: auto; }
.sp-wide-queue{
  display:flex;
  gap:8px;
  margin-top:8px;
  overflow-x:auto;
}
.sp-wide-queue-item{
  flex-shrink:0;
  width:44px; height:44px;
  border-radius:50%;
  padding:0;
  border: 2px solid transparent;
  background:#eee;
  overflow:hidden;
  cursor:pointer;
}
.sp-wide-queue-item.is-active{
  border-color: var(--sp-wide-accent);
}
.sp-wide-queue-item img{
  width:100%; height:100%; object-fit:cover; display:block;
}
.sp-wide-queue-fallback{
  display:flex; align-items:center; justify-content:center;
  width:100%; height:100%;
  font-size:15px; font-weight:700; color:#666;
}
.sp-wide-link-badge{
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 0 12px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 20px;
  text-decoration: none;
  white-space: nowrap;
}
.sp-wide-views{
  background: rgba(0,0,0,0.5);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 0 10px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  white-space: nowrap;
}
.sp-wide-link-arrow{
  flex-shrink: 0;
  display: block;
}

/* ================= Wide loop inline controls ================= */
.sp-wide-edge{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  appearance: none;
  border: 0;
  background: rgba(0,0,0,0.35);
  color: #fff;
  width: 32px;
  height: 44px;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3;
}
.sp-wide-edge:hover{ background: rgba(0,0,0,0.6); }
.sp-wide-prev{ left: 0; border-radius: 0 6px 6px 0; }
.sp-wide-next{ right: 0; border-radius: 6px 0 0 6px; }

.sp-wide-corner-ctrls{
  position: absolute;
  bottom: 38px;
  left: 12px;
  right: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  z-index: 3;
}
.sp-wide-ctrl{
  appearance: none;
  border: 0;
  background: rgba(0,0,0,0.5);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.sp-wide-ctrl:hover{ background: rgba(0,0,0,0.75); }
.sp-wide-ctrl.sp-wide-audio{
  animation: sp-wide-audio-pulse 2.2s ease-in-out infinite;
}
.sp-wide-ctrl.sp-wide-audio:hover{
  animation: none;
}
@keyframes sp-wide-audio-pulse{
  0%, 100%{ box-shadow: 0 0 0 0 rgba(255,255,255,0.0); }
  50%{ box-shadow: 0 0 0 6px rgba(255,255,255,0.15); }
}

/* Keep the meta bar (count/dots) clear of other overlays */
.sp-wide-meta{ z-index: 2; }
.sp-wide-dots{ gap: 8px; }
.sp-wide-dot-btn{
  appearance: none;
  border: 0;
  padding: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  cursor: pointer;
}
.sp-wide-dot-btn.on{ background: var(--sp-wide-accent); }
.sp-wide-dot-btn:hover{ background: rgba(255,255,255,0.6); }
.sp-wide-dot-btn.on:hover{ background: var(--sp-wide-accent); }

/* ================= Upload spinner overlay ================= */
.sp-upload-spinner{
  position: fixed;
  inset: 0;
  z-index: 100001;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
}
.sp-upload-spinner.is-open{ display: flex; }
.sp-upload-spinner-inner{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: #fff;
}
.sp-spin{
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  animation: sp-spin-rotate 0.8s linear infinite;
}
@keyframes sp-spin-rotate{
  to{ transform: rotate(360deg); }
}
.sp-upload-spinner-text{
  font-size: 14px;
  font-weight: 600;
}
