/* Stories (app/lib/stories.php + assets/js/stories.js): tray, profile ring, full-screen viewer and composer. */
:root {
  --st-ring-new: linear-gradient(45deg, #ffcf5c 0%, #ff8a3d 30%, #f0466e 62%, #a24bdc 100%);
  --st-ring-mgr: linear-gradient(135deg, #fbe8b0 0%, #d8a956 38%, #8f5f22 70%, #f3d58b 100%);
  --st-ring-seen: #d3cdc3;
}

/* ---------------- tray ---------------- */
.st-tray { margin: 0 0 16px; padding: 12px 10px 10px; border: 1px solid var(--line); border-radius: 20px; background: #fff; box-shadow: var(--shadow-xs); }
.st-tray-in { display: flex; gap: 12px; overflow-x: auto; padding: 2px 4px; scroll-snap-type: x proximity; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.st-tray-in::-webkit-scrollbar { display: none; }
.st-bub { position: relative; flex: none; width: 76px; display: flex; flex-direction: column; align-items: center; gap: 5px; scroll-snap-align: start; }
.st-bub-btn { display: block; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.st-bub-btn:focus-visible, .st-pring:focus-visible { outline: 3px solid var(--gold-3); outline-offset: 3px; }
.st-ring { display: grid; place-items: center; width: 72px; height: 72px; padding: 3px; border-radius: 50%; background: var(--st-ring-new); transition: transform .18s var(--ease); }
.st-bub-btn:active .st-ring { transform: scale(.94); }
.st-ring .avatar { width: 62px !important; height: 62px !important; font-size: 22px !important; box-shadow: 0 0 0 3px #fff; }
.st-bub.is-seen .st-ring { padding: 2px; background: var(--st-ring-seen); }
.st-bub.is-seen .st-ring .avatar { width: 64px !important; height: 64px !important; box-shadow: 0 0 0 3px #fff; }
.st-bub.is-mgr.is-new .st-ring { background: var(--st-ring-mgr); }
.st-bub.is-empty .st-ring { background: transparent; }
.st-bub.is-empty .st-ring .avatar { box-shadow: none; }
.st-name { max-width: 76px; overflow: hidden; color: var(--text); font-size: 12px; font-weight: 600; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.st-bub.is-seen .st-name { color: var(--muted); }
.st-bub.is-mgr .st-name { font-weight: 800; }
.st-plus { position: absolute; top: 50px; inset-inline-end: 1px; display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 2.5px solid #fff; border-radius: 50%;
  background: #1677ff; color: #fff; cursor: pointer; }
.st-plus .i { width: 13px; height: 13px; stroke-width: 3; }

/* ---------------- profile ring ---------------- */
.st-pring { display: inline-block; padding: 4px; border: 0; border-radius: 50%; background: var(--st-ring-new); line-height: 0; cursor: pointer; }
.st-pring.is-seen { background: var(--st-ring-seen); }
.st-pring.is-mgr.is-new { background: var(--st-ring-mgr); }
.st-pring .avatar { cursor: pointer; }

/* ---------------- viewer ---------------- */
html.stv-lock, html.stv-lock body { overflow: hidden !important; }
html.stv-lock .modal { z-index: 1300; }
.stv { position: fixed; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center; background: #0d0d0e; color: #fff; touch-action: none;
  overscroll-behavior: contain; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.stv-bg { position: absolute; inset: -60px; background-position: center; background-size: cover; filter: blur(46px) brightness(.42) saturate(1.2); transform: scale(1.1); opacity: .9; pointer-events: none; }
.stv-wrap { position: relative; display: flex; align-items: center; justify-content: center; perspective: 1400px; }
.stv-stage { position: relative; width: calc(min(92dvh, 940px) * 9 / 16); height: min(92dvh, 940px); max-width: 100vw; overflow: hidden; overflow: clip; border-radius: 14px; background: #000;
  container-type: inline-size; box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .8); transform-origin: center; backface-visibility: hidden; }
.stv-media { position: absolute; inset: 0; overflow: hidden; overflow: clip; }
.stv-media img, .stv-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.stv-media .stv-fill { object-fit: cover; filter: blur(26px) brightness(.62); transform: scale(1.18); }
.stv-media.is-cover .stv-main { object-fit: cover; }
.stv-shade { position: absolute; inset-inline: 0; z-index: 2; pointer-events: none; }
.stv-shade.is-top { top: 0; height: 120px; background: linear-gradient(rgba(0, 0, 0, .52), transparent); }
.stv-shade.is-bot { bottom: 0; height: 140px; background: linear-gradient(transparent, rgba(0, 0, 0, .55)); }
.stv-bars { position: absolute; top: 10px; inset-inline: 10px; z-index: 6; display: flex; gap: 3px; transition: opacity .2s; }
.stv-bar { flex: 1; height: 2.5px; overflow: hidden; border-radius: 3px; background: rgba(255, 255, 255, .38); }
.stv-bar > i { display: block; width: 0; height: 100%; border-radius: inherit; background: #fff; }
.stv-bar.is-done > i { width: 100%; }
.stv-head { position: absolute; top: 20px; inset-inline: 10px 6px; z-index: 6; display: flex; align-items: center; gap: 6px; transition: opacity .2s; }
.stv-who { display: flex; align-items: center; gap: 7px; min-width: 0; flex: 1; padding: 2px; overflow: hidden; color: #fff; text-decoration: none; }
.stv-who .avatar { flex: none; }
.stv-who .mgr-badge { margin: 0; }
.stv-who .avatar { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .85); }
.stv-who b { flex: 0 1 auto; min-width: 2.5em; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 4px rgba(0, 0, 0, .45); }
.stv-who .tick { flex: none; }
.stv-time { flex: none; font-size: 13px; opacity: .78; text-shadow: 0 1px 4px rgba(0, 0, 0, .45); }
.stv-all { flex: none; display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px; border-radius: 999px; background: rgba(255, 255, 255, .18); font-size: 11px; font-weight: 800; }
.stv-all .i { width: 12px; height: 12px; }
/* a narrow stage (phones): the seal without the «Manager» pill, the globe without its words */
@container (max-width: 439px) {
  .stv-who .mgr-pill, .stv-all-t { display: none; }
  .stv-all { padding: 3px; }
}
.stv-tools { display: flex; align-items: center; flex: none; }
.stv-btn { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: none; color: #fff; cursor: pointer; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .5)); }
.stv-btn:hover { background: rgba(255, 255, 255, .12); }
.stv-btn:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.stv-btn .i { width: 22px; height: 22px; }
.stv-tap { position: absolute; inset: 64px 0 76px; z-index: 3; cursor: pointer; }
.stv-cap { position: absolute; inset-inline: 7%; z-index: 2; transform: translateY(-50%); font-size: 6.6cqw; font-weight: 800; line-height: 1.38; text-align: center; white-space: pre-wrap;
  overflow-wrap: anywhere; pointer-events: none; }
.stv-cap span, .stc-cap span { padding: .08em .34em; border-radius: .28em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.stv-cap[data-s="plain"], .stc-cap[data-s="plain"] { text-shadow: 0 2px 8px rgba(0, 0, 0, .55), 0 0 2px rgba(0, 0, 0, .4); }
.stv-link { position: absolute; left: 50%; z-index: 4; display: inline-flex; align-items: center; gap: 6px; max-width: 82%; padding: .55em 1em; overflow: hidden; border-radius: 12px;
  background: #fff; box-shadow: 0 8px 22px -8px rgba(0, 0, 0, .55); color: #0a5bd8; font-size: 3.9cqw; font-weight: 800; text-decoration: none; text-overflow: ellipsis; white-space: nowrap;
  transform: translate(-50%, -50%); }
.stv-link .i { flex: none; width: 1.1em; height: 1.1em; }
.stv-foot { position: absolute; bottom: 0; inset-inline: 0; z-index: 6; display: flex; align-items: center; gap: 8px; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); transition: opacity .2s; }
.stv-reply { display: flex; flex: 1; align-items: center; gap: 6px; min-width: 0; }
.stv-input { flex: 1; min-width: 0; height: 44px; padding: 0 16px; border: 1.5px solid rgba(255, 255, 255, .78); border-radius: 999px; background: rgba(0, 0, 0, .12); color: #fff; font: inherit;
  font-size: 15px; outline: none; }
.stv-input::placeholder { color: rgba(255, 255, 255, .88); }
.stv-input:focus { border-color: #fff; background: rgba(0, 0, 0, .3); }
.stv-like.is-on { color: #ff3b5c; }
.stv-like.is-on .i { fill: currentColor; }
.stv-like.is-pop { animation: stv-pop .35s var(--ease); }
@keyframes stv-pop { 50% { transform: scale(1.35); } }
.stv-send { display: none; }
.stv.is-typing .stv-send { display: grid; }
.stv.is-typing .stv-like { display: none; }
.stv-dim { position: absolute; inset: 0; z-index: 5; background: rgba(0, 0, 0, .66); opacity: 0; pointer-events: none; transition: opacity .2s; }
.stv.is-replying .stv-dim { opacity: 1; pointer-events: auto; }
.stv-reacts { position: absolute; bottom: 86px; inset-inline: 0; z-index: 6; display: none; grid-template-columns: repeat(3, 1fr); gap: 18px 10px; padding: 0 12%; }
.stv.is-replying .stv-reacts { display: grid; }
.stv-react { padding: 0; border: 0; background: none; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; font-size: 40px; line-height: 1.1; cursor: pointer;
  transition: transform .15s; }
.stv-react:hover, .stv-react:focus-visible { transform: scale(1.18); outline: none; }
.stv-float { position: absolute; z-index: 9; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; font-size: 46px; pointer-events: none; animation: stv-float 1.1s ease-out forwards; }
@keyframes stv-float { from { opacity: 1; transform: translate(-50%, 0) scale(.6); } 40% { transform: translate(-50%, -60px) scale(1.25); } to { opacity: 0; transform: translate(-50%, -190px) scale(1); } }
.stv-owner { display: flex; flex: 1; align-items: center; justify-content: space-between; gap: 10px; }
.stv-views { display: inline-flex; align-items: center; gap: 7px; padding: 6px 4px; border: 0; background: none; color: #fff; font: inherit; font-size: 14px; font-weight: 800; cursor: pointer;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.stv-views .i { width: 20px; height: 20px; }
.stv-views small { opacity: .8; font-weight: 700; }
.stv-addbtn { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .16); color: #fff; font: inherit;
  font-size: 13.5px; font-weight: 800; cursor: pointer; }
.stv-guest { flex: 1; color: #fff; font-size: 14px; font-weight: 700; text-align: center; }
.stv-guest a { color: #fff; text-decoration: underline; }
.stv.is-holding .stv-head, .stv.is-holding .stv-foot, .stv.is-holding .stv-bars, .stv.is-holding .stv-shade { opacity: 0; }
.stv-spin { position: absolute; top: 50%; left: 50%; z-index: 4; width: 38px; height: 38px; margin: -19px 0 0 -19px; border: 3px solid rgba(255, 255, 255, .25); border-top-color: #fff; border-radius: 50%;
  animation: spin .9s linear infinite; pointer-events: none; }
.stv-hint { position: absolute; top: 70px; left: 50%; z-index: 6; padding: 6px 12px; border-radius: 999px; background: rgba(0, 0, 0, .55); font-size: 12.5px; font-weight: 700; transform: translateX(-50%);
  pointer-events: none; }
.stv-menu { position: absolute; top: 60px; inset-inline-end: 10px; z-index: 9; min-width: 170px; overflow: hidden; border-radius: 14px; background: #fff; box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .6); }
.stv-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 13px 16px; border: 0; background: none; color: var(--text); font: inherit; font-size: 14.5px; font-weight: 700;
  text-align: start; cursor: pointer; }
.stv-menu button + button { border-top: 1px solid var(--line); }
.stv-menu button:hover { background: var(--surface-2); }
.stv-menu .is-danger { color: var(--red); }
.stv-sheet { position: absolute; bottom: 0; inset-inline: 0; z-index: 10; display: flex; flex-direction: column; max-height: 62%; border-radius: 18px 18px 0 0; background: #fff; color: var(--text);
  transform: translateY(102%); transition: transform .25s var(--ease); }
.stv-sheet.is-open { transform: none; }
.stv-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.stv-sheet-head b { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; }
.stv-sheet-head .stv-btn { color: var(--text); filter: none; }
.stv-sheet-list { overflow-y: auto; padding: 6px 8px 14px; touch-action: pan-y; }
.stv-viewer-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; color: var(--text); text-decoration: none; }
.stv-viewer-row:hover { background: var(--surface-2); }
.st-viewer-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; color: var(--text); text-decoration: none; }
.st-viewer-row:hover { background: var(--surface-2); }
.st-viewer-id { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: 0 4px; min-width: 0; }
.st-viewer-id b { font-size: 14px; }
.st-viewer-id small { width: 100%; color: var(--muted-2); font-size: 12px; }
.st-viewer-like { color: #ff3b5c; font-size: 20px; }
.stv-empty { padding: 22px 12px; color: var(--muted); font-size: 14px; text-align: center; }
.stv-close, .stv-nav { position: absolute; z-index: 2; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; cursor: pointer; }
.stv-close { position: fixed; top: 16px; inset-inline-end: 18px; width: 44px; height: 44px; background: none; color: #fff; }
.stv-close .i { width: 30px; height: 30px; }
.stv-nav { top: 50%; width: 38px; height: 38px; margin-top: -19px; background: rgba(255, 255, 255, .88); color: #111; box-shadow: 0 6px 16px rgba(0, 0, 0, .35); }
.stv-nav[disabled] { opacity: 0; pointer-events: none; }
.stv-nav.is-prev { inset-inline-start: -56px; }
.stv-nav.is-next { inset-inline-end: -56px; }
.stv-nav .i { width: 20px; height: 20px; }
@media (max-width: 700px), (max-height: 520px) {
  .stv { background: #000; }
  .stv-bg, .stv-nav, .stv-close { display: none; }
  .stv-stage { width: 100vw; height: 100dvh; max-height: none; border-radius: 0; box-shadow: none; }
}
@media (min-width: 701px) and (min-height: 521px) { .stv-x-in { display: none; } }
@media (prefers-reduced-motion: reduce) { .stv-sheet, .stv-ring { transition: none; } .stv-float { animation-duration: .01s; } }

/* ---------------- composer ---------------- */
.stc { position: fixed; inset: 0; z-index: 1150; display: flex; align-items: center; justify-content: center; background: #0d0d0e; color: #fff; touch-action: none;
  overscroll-behavior: contain; }
.stc-stage { position: relative; width: calc(min(92dvh, 940px) * 9 / 16); height: min(92dvh, 940px); max-width: 100vw; overflow: hidden; overflow: clip; border-radius: 14px; background: #161618;
  container-type: inline-size; }
@media (max-width: 700px), (max-height: 520px) { .stc-stage { width: 100vw; height: 100dvh; border-radius: 0; } }
.stc-pick { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 28px 22px; text-align: center;
  background: radial-gradient(120% 70% at 50% 0%, #3a2c17 0%, #161618 60%); }
.stc-pick h2 { margin: 0 0 6px; color: #fff; font-size: 22px; }
.stc-pick p { max-width: 280px; margin: 6px 0 0; color: rgba(255, 255, 255, .72); font-size: 13.5px; line-height: 1.7; }
.stc-choice { display: flex; align-items: center; gap: 14px; width: 100%; max-width: 290px; padding: 15px 18px; border: 1px solid rgba(255, 255, 255, .16); border-radius: 16px;
  background: rgba(255, 255, 255, .07); color: #fff; font: inherit; font-size: 16px; font-weight: 800; text-align: start; cursor: pointer; transition: background .15s; }
.stc-choice:hover, .stc-choice:focus-visible { background: rgba(255, 255, 255, .13); outline: none; }
.stc-choice small { display: block; color: rgba(255, 255, 255, .62); font-size: 12.5px; font-weight: 600; }
.stc-choice-ico { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 13px; background: var(--st-ring-new); font-size: 18px; font-weight: 900; }
.stc-choice-ico .i { width: 22px; height: 22px; }
.stc-aud-note { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .1); color: #fff; font-size: 12.5px; font-weight: 700; }
.stc-canvas { position: absolute; inset: 0; overflow: hidden; }
.stc-canvas img, .stc-canvas video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.stc-canvas .stv-fill { object-fit: cover; filter: blur(26px) brightness(.62); transform: scale(1.18); }
.stc-canvas.is-cover .stv-main { object-fit: cover; }
.stc-textcard { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 10% 8%; }
.stc-text { width: 100%; max-height: 80%; overflow-y: auto; color: #fff; font-size: 8.4cqw; font-weight: 800; line-height: 1.32; text-align: center; white-space: pre-wrap; overflow-wrap: anywhere;
  outline: none; caret-color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, .18); }
.stc-text[data-f="1"] { font-weight: 400; letter-spacing: .01em; }
.stc-text[data-f="2"] { padding: .1em .3em; font-style: italic; }
.stc-text[data-a="start"] { text-align: start; }
.stc-text:empty::before { content: attr(data-ph); color: rgba(255, 255, 255, .55); }
.stc-cap { position: absolute; inset-inline: 7%; z-index: 3; min-height: 1.3em; transform: translateY(-50%); font-size: 6.6cqw; font-weight: 800; line-height: 1.38; text-align: center;
  white-space: pre-wrap; overflow-wrap: anywhere; outline: none; caret-color: #fff; cursor: text; touch-action: none; }
.stc-cap:empty::before { content: attr(data-ph); color: rgba(255, 255, 255, .6); text-shadow: 0 1px 6px rgba(0, 0, 0, .5); }
.stc-cap.is-drag { cursor: grabbing; }
.stc-link { position: absolute; left: 50%; z-index: 3; display: inline-flex; align-items: center; gap: 6px; max-width: 82%; padding: .55em 1em; overflow: hidden; border: 0; border-radius: 12px;
  background: #fff; color: #0a5bd8; font: inherit; font-size: 3.9cqw; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; transform: translate(-50%, -50%); cursor: grab; touch-action: none; }
.stc-link .i { flex: none; width: 1.1em; height: 1.1em; }
.stc-top { position: absolute; top: 12px; inset-inline: 12px; z-index: 6; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; pointer-events: none; }
.stc-top > * { pointer-events: auto; }
.stc-tools { display: flex; flex-direction: column; gap: 10px; }
.stc-tool { display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .42); color: #fff; font: inherit; font-size: 16px;
  font-weight: 900; cursor: pointer; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.stc-tool:hover, .stc-tool.is-on { background: rgba(255, 255, 255, .26); }
.stc-tool:focus-visible { outline: 2px solid #fff; }
.stc-tool .i { width: 20px; height: 20px; }
.stc-swatches { position: absolute; bottom: 82px; inset-inline: 0; z-index: 6; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; padding: 0 16px; }
.stc-swatch { width: 28px; height: 28px; padding: 0; border: 2.5px solid #fff; border-radius: 50%; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); cursor: pointer; }
.stc-swatch.is-on { transform: scale(1.22); }
.stc-swatch:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.stc-bottom { position: absolute; bottom: 0; inset-inline: 0; z-index: 6; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0, 0, 0, .6)); }
.stc-aud { display: inline-flex; align-items: center; gap: 6px; min-width: 0; color: #fff; font-size: 13px; font-weight: 700; }
.stc-share { display: inline-flex; flex: none; align-items: center; gap: 8px; height: 46px; padding: 0 22px; border: 0; border-radius: 999px; background: #fff; color: #111; font: inherit;
  font-size: 15px; font-weight: 900; cursor: pointer; }
.stc-share[disabled] { opacity: .55; cursor: default; }
.stc-share .i { width: 18px; height: 18px; }
html[dir="rtl"] .stc-share .i { transform: scaleX(-1); }
.stc-progress { position: absolute; top: 0; inset-inline: 0; z-index: 8; height: 3px; background: rgba(255, 255, 255, .15); }
.stc-progress > i { display: block; width: 0; height: 100%; background: var(--gold-2); transition: width .2s; }
.stc-err { position: absolute; top: 64px; inset-inline: 16px; z-index: 7; padding: 10px 14px; border-radius: 12px; background: rgba(207, 59, 51, .92); color: #fff; font-size: 13.5px; font-weight: 700; line-height: 1.6; }
.stc-sheet { position: absolute; inset: 0; z-index: 9; display: grid; place-items: center; padding: 18px; background: rgba(0, 0, 0, .62); }
.stc-sheet-in { width: 100%; max-width: 330px; padding: 18px; border-radius: 18px; background: #fff; color: var(--text); }
.stc-sheet-in h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 16px; }
.stc-sheet-in .field { margin-bottom: 10px; }
.stc-sheet-actions { display: flex; gap: 8px; margin-top: 12px; }
.stc-sheet-actions .btn { flex: 1; }
.stc-x { color: #fff; }
