/* APSNY STORIES V1 */
.stories-v1-shell{
  width:100%;
  border-bottom:1px solid #eadfd6;
  background:#fff;
}

.stories-v1-shell[hidden]{
  display:none!important;
}

.stories-v1-inner{
  width:min(1220px,calc(100% - 36px));
  min-height:94px;
  margin:0 auto;
  display:flex;
  gap:10px;
  align-items:center;
  overflow:hidden;
}

.stories-v1-list{
  min-width:0;
  display:flex;
  gap:10px;
  align-items:flex-start;
  overflow-x:auto;
  padding:10px 0;
  scrollbar-width:none;
}

.stories-v1-list::-webkit-scrollbar{display:none}

.stories-v1-add,
.stories-v1-avatar{
  width:76px;
  flex:0 0 76px;
  display:grid;
  justify-items:center;
  gap:5px;
  padding:0;
  border:0;
  background:transparent;
  color:#4d4038;
  cursor:pointer;
}

.stories-v1-avatar small{
  width:74px;
  overflow:hidden;
  color:#5f5148;
  font-size:9px;
  font-weight:750;
  text-align:center;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.stories-v1-add-circle,
.stories-v1-ring{
  width:66px;
  height:66px;
  display:grid;
  place-items:center;
  border-radius:50%;
}

.stories-v1-add-circle{
  border:1px dashed #9f8e82;
  background:#f8f3ee;
  color:#17492a;
  font-size:28px;
  font-weight:400;
}

.stories-v1-ring{
  padding:3px;
  background:#d9cec5;
}

.stories-v1-avatar.unseen .stories-v1-ring{
  background:linear-gradient(145deg,#17492a,#7a4a2d,#d69a60);
}

.stories-v1-photo{
  width:60px;
  height:60px;
  overflow:hidden;
  display:grid;
  place-items:center;
  border:3px solid #fff;
  border-radius:50%;
  background:#eee5dd;
  color:#51443b;
  font:700 21px Georgia,serif;
}

.stories-v1-photo img{
  width:100%;
  height:100%;
  object-fit:cover;
}

/* Viewer */
html.stories-open,
html.stories-open body{
  overflow:hidden;
}

.stories-viewer-v1{
  position:fixed;
  inset:0;
  z-index:5000;
  display:grid;
  place-items:center;
}

.stories-viewer-v1[hidden]{display:none!important}

.stories-viewer-backdrop{
  position:absolute;
  inset:0;
  background:rgba(12,10,9,.93);
  backdrop-filter:blur(8px);
}

.stories-viewer-stage{
  position:relative;
  z-index:1;
  width:min(430px,100vw);
  height:min(92vh,820px);
  overflow:hidden;
  border-radius:18px;
  background:#111;
  box-shadow:0 20px 80px rgba(0,0,0,.45);
  touch-action:pan-y;
  user-select:none;
}

.stories-viewer-progress{
  position:absolute;
  z-index:12;
  top:max(9px,env(safe-area-inset-top));
  left:10px;
  right:10px;
  display:flex;
  gap:4px;
  pointer-events:none;
}

.stories-progress-track{
  height:4px;
  flex:1;
  overflow:hidden;
  border-radius:999px;
  background:rgba(255,255,255,.30);
  box-shadow:0 1px 3px rgba(0,0,0,.22);
}

.stories-progress-track i{
  height:100%;
  display:block;
  border-radius:inherit;
  background:#fff;
  will-change:width;
}

.stories-viewer-head{
  position:absolute;
  z-index:7;
  top:20px;
  left:12px;
  right:12px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  color:#fff;
}

.stories-viewer-publisher{
  min-width:0;
  display:flex;
  align-items:center;
  gap:9px;
}

.stories-viewer-avatar{
  width:38px;
  height:38px;
  flex:0 0 38px;
  overflow:hidden;
  display:grid;
  place-items:center;
  border:2px solid rgba(255,255,255,.88);
  border-radius:50%;
  background:#66574d;
  font:700 15px Georgia,serif;
}

.stories-viewer-avatar img{
  width:100%;
  height:100%;
  object-fit:cover;
}

.stories-viewer-publisher>div:last-child{
  min-width:0;
  display:grid;
  gap:1px;
}

.stories-viewer-title{
  max-width:235px;
  overflow:hidden;
  font-size:11px;
  text-overflow:ellipsis;
  white-space:nowrap;
  text-shadow:0 1px 4px rgba(0,0,0,.45);
}

.stories-viewer-age{
  color:rgba(255,255,255,.72);
  font-size:8px;
}

.stories-viewer-head-actions{
  display:flex;
  gap:5px;
}

.stories-viewer-head-actions button{
  width:34px;
  height:34px;
  border:0;
  border-radius:50%;
  background:rgba(0,0,0,.28);
  color:#fff;
  font-size:17px;
  cursor:pointer;
}

.stories-viewer-media{
  width:100%;
  height:100%;
  display:grid;
  place-items:center;
  background:#111;
}

.stories-viewer-media img,
.stories-viewer-media video{
  width:100%;
  height:100%;
  display:block;
  object-fit:cover;
}

.stories-viewer-zone{
  position:absolute;
  z-index:4;
  top:72px;
  bottom:80px;
  width:34%;
  border:0;
  background:transparent;
}

.stories-viewer-zone.prev{left:0}
.stories-viewer-zone.next{right:0}

.stories-viewer-bottom{
  position:absolute;
  z-index:6;
  left:0;
  right:0;
  bottom:0;
  display:grid;
  gap:9px;
  padding:64px 16px 16px;
  background:linear-gradient(transparent,rgba(0,0,0,.72));
  pointer-events:none;
}

.stories-viewer-caption{
  max-height:100px;
  overflow:auto;
  color:#fff;
  font-size:12px;
  line-height:1.45;
  text-shadow:0 1px 4px rgba(0,0,0,.45);
  pointer-events:auto;
}

.stories-viewer-cta{
  width:max-content;
  max-width:100%;
  min-height:38px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:8px 13px;
  border:1px solid rgba(255,255,255,.55);
  border-radius:999px;
  background:rgba(255,255,255,.9);
  color:#211813;
  font-size:10px;
  font-weight:850;
  text-decoration:none;
  pointer-events:auto;
}

@media(max-width:600px){
  .stories-v1-inner{
    width:100%;
    padding-left:8px;
  }

  .stories-viewer-stage{
    width:100vw;
    height:100dvh;
    border-radius:0;
  }
}


/* STORIES VIEWER V4
   Exact 9:16 stage, full-media contain, and reserved UI safe areas. */
.stories-viewer-stage{
  --story-top-safe:84px;
  --story-bottom-safe:78px;

  width:min(430px,calc(92dvh * 9 / 16),100vw);
  height:auto;
  aspect-ratio:9/16;
  max-height:92dvh;
  border-radius:18px;
  background:#111;
}

.stories-viewer-stage::before{
  content:"";
  position:absolute;
  z-index:5;
  inset:0 0 auto 0;
  height:var(--story-top-safe);
  background:linear-gradient(rgba(0,0,0,.54),rgba(0,0,0,0));
  pointer-events:none;
}

.stories-viewer-progress{
  top:calc(env(safe-area-inset-top,0px) + 10px);
  left:10px;
  right:10px;
}

.stories-progress-track{
  height:4px;
}

.stories-viewer-head{
  top:calc(env(safe-area-inset-top,0px) + 25px);
}

.stories-viewer-media{
  position:relative;
  overflow:hidden;
  width:100%;
  height:100%;
  background:#111;
}

.stories-viewer-media .stories-viewer-bg{
  position:absolute;
  z-index:0;
  inset:-8%;
  width:116%;
  height:116%;
  object-fit:cover !important;
  filter:blur(26px) brightness(.56) saturate(1.08);
  transform:scale(1.04);
}

.stories-viewer-media .stories-viewer-foreground{
  position:absolute;
  z-index:2;
  inset:0;
  width:100%;
  height:100%;
  object-fit:contain !important;
  background:transparent;
}

.stories-viewer-media .stories-viewer-video{
  position:absolute;
  z-index:2;
  inset:0;
  width:100%;
  height:100%;
  object-fit:contain !important;
  background:#111;
}

.stories-viewer-zone{
  top:var(--story-top-safe);
  bottom:var(--story-bottom-safe);
}

.stories-viewer-content-bottom{
  position:absolute;
  z-index:8;
  left:0;
  right:0;
  bottom:calc(var(--story-bottom-safe) + env(safe-area-inset-bottom,0px));
  display:grid;
  gap:8px;
  padding:54px 16px 10px;
  background:linear-gradient(transparent,rgba(0,0,0,.52));
  pointer-events:none;
}

.stories-viewer-caption{
  max-height:84px;
  overflow:auto;
  color:#fff;
  font-size:12px;
  line-height:1.45;
  text-shadow:0 1px 4px rgba(0,0,0,.45);
  pointer-events:auto;
}

.stories-viewer-cta{
  width:max-content;
  max-width:100%;
  min-height:38px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:8px 13px;
  border:1px solid rgba(255,255,255,.55);
  border-radius:999px;
  background:rgba(255,255,255,.92);
  color:#211813;
  font-size:10px;
  font-weight:850;
  text-decoration:none;
  pointer-events:auto;
}

.stories-viewer-bottom-safe{
  position:absolute;
  z-index:7;
  left:0;
  right:0;
  bottom:0;
  height:calc(var(--story-bottom-safe) + env(safe-area-inset-bottom,0px));
  background:linear-gradient(transparent,rgba(0,0,0,.62));
  pointer-events:none;
}

/* Old V3 bottom is not used by V4 JS. */
.stories-viewer-bottom{
  display:none !important;
}

@media(max-width:600px){
  .stories-viewer-v1{
    background:#080706;
  }

  .stories-viewer-stage{
    width:min(100vw,calc(100dvh * 9 / 16));
    height:auto;
    max-height:100dvh;
    aspect-ratio:9/16;
    border-radius:0;
  }
}


/* STORIES V5 — sound control */
.stories-viewer-sound{
  display:grid;
  place-items:center;
  font-size:14px !important;
  line-height:1;
}
.stories-viewer-sound[hidden]{
  display:none !important;
}


/* STORY STICKERS VIEWER V8.1 */
.stories-viewer-overlays{
  position:absolute;
  z-index:6;
  inset:0;
  pointer-events:none;
}

.stories-viewer-sticker{
  position:absolute;
  left:calc(var(--sticker-left) * 1%);
  top:calc(var(--sticker-top) * 1%);
  transform:
    translate(-50%,-50%)
    scale(var(--sticker-scale))
    rotate(var(--sticker-rotation));
  transform-origin:center center;
  pointer-events:none;
}

.stories-sticker-visual{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:5px;
  min-height:34px;
  padding:7px 10px;
  border:1px solid rgba(255,255,255,.7);
  border-radius:999px;
  background:rgba(17,14,12,.66);
  color:#fff;
  box-shadow:0 4px 16px rgba(0,0,0,.25);
  font-size:12px;
  font-weight:900;
  line-height:1;
  white-space:nowrap;
  text-shadow:0 1px 4px rgba(0,0,0,.28);
  backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);
}

.stories-sticker-visual.emoji-only{
  min-width:42px;
  min-height:42px;
  padding:6px;
  border:0;
  background:rgba(255,255,255,.12);
  font-size:26px;
}
