.rl-story-studio { position:fixed; inset:0; z-index:280; margin:0; border:0; padding:0; width:100%; max-width:none; height:100dvh; max-height:none; color:var(--text-primary); background:var(--surface); letter-spacing:0; }
.rl-story-studio::backdrop { background:var(--overlay); }
.rl-story-shell { position:relative; width:min(100%,560px); height:100%; margin:auto; overflow:hidden; display:grid; grid-template-rows:minmax(0,1fr); }
.rl-story-stage { position:absolute; inset:0; margin:auto; width:min(100%,56.25dvh); height:min(100dvh,177.777778vw); overflow:hidden; touch-action:none; container-type:size; background:var(--media-scrim); }
.rl-story-source { position:absolute; inset:0; height:100%; width:100%; object-fit:cover; transform-origin:center; pointer-events:none; }
.rl-story-vignette { position:absolute; inset:0; pointer-events:none; background:radial-gradient(ellipse at center,transparent 30%,rgba(0,0,0,var(--vignette,0)) 100%); }
.rl-story-head { position:absolute; inset:0 0 auto; z-index:40; display:flex; align-items:center; justify-content:space-between; gap:8px; padding:calc(8px + env(safe-area-inset-top,0px)) 12px 8px; background:linear-gradient(var(--surface),transparent); pointer-events:none; }
.rl-story-head>* { pointer-events:auto; }
.rl-story-studio button { display:inline-grid; place-items:center; min-width:48px; min-height:48px; border:0; color:var(--text-primary); background:var(--surface); border-radius:8px; padding:10px; cursor:pointer; font-size:14px; }
.rl-story-studio button:disabled { opacity:.4; cursor:default; }
.rl-story-studio button svg { width:24px; height:24px; }
.rl-story-studio button:focus-visible,.rl-story-stage:focus-visible { outline:2px solid var(--media-bg); outline-offset:-3px; }
.rl-story-studio [hidden] { display:none!important; }
.rl-story-foot { position:absolute; z-index:40; inset:auto 0 0; display:flex; justify-content:space-between; align-items:center; gap:16px; padding:16px 18px calc(16px + env(safe-area-inset-bottom,0px)); background:linear-gradient(transparent,var(--surface)); }
.rl-story-studio .rl-story-shutter { width:82px; height:82px; min-width:82px; padding:7px; border-radius:50%; background:conic-gradient(var(--primary-strong) calc(var(--progress,0)*1turn),var(--surface) 0); touch-action:none; }
.rl-story-shutter span { width:100%; height:100%; border:4px solid var(--border-soft); border-radius:50%; background:var(--surface); transition:transform .12s,background .12s; }
.rl-story-shutter.is-recording span { background:var(--primary-strong); transform:scale(.68); border-radius:6px; color:var(--button-primary-text); }
.rl-story-studio .rl-story-publish { background:var(--primary-strong); padding-inline:20px; color:var(--button-primary-text); }
.rl-story-tools { position:absolute; z-index:40; right:12px; top:calc(76px + env(safe-area-inset-top,0px)); display:grid; gap:10px; }
.rl-story-filter-name { position:absolute; z-index:40; bottom:calc(116px + env(safe-area-inset-bottom,0px)); left:50%; transform:translateX(-50%); transition:opacity .2s; opacity:0; pointer-events:none; }
.rl-story-filter-name.is-visible { opacity:1; pointer-events:auto; }
.rl-story-status { position:absolute; z-index:45; left:16px; right:16px; bottom:calc(175px + env(safe-area-inset-bottom,0px)); text-align:center; font-size:14px; text-shadow:0 2px 5px var(--shadow-color); pointer-events:none; }
.rl-story-object-layer { position:absolute; inset:0; pointer-events:none; }
.rl-story-object { position:absolute; font-weight:700; line-height:1.15; white-space:pre-wrap; overflow-wrap:anywhere; padding:8px; text-shadow:0 2px 6px var(--shadow-color); user-select:none; touch-action:none; pointer-events:auto; border:1px solid transparent; }
.rl-story-object.is-selected { border:1px dashed var(--input-border); }
.rl-story-object[contenteditable="plaintext-only"] { min-height:1.5em; user-select:text; touch-action:manipulation; outline:none; }
.rl-story-guide { position:absolute; background:var(--primary-strong); pointer-events:none; z-index:35; color:var(--button-primary-text); }
.rl-story-guide.vertical { width:1px; top:5%; bottom:5%; }
.rl-story-guide.horizontal { height:1px; left:5%; right:5%; }
.rl-story-angle { position:absolute; z-index:40; top:18%; left:50%; transform:translateX(-50%); padding:6px 10px; background:var(--surface); border-radius:6px; }
.rl-story-edit-panel { position:absolute; z-index:50; inset:auto 8px calc(108px + env(safe-area-inset-bottom,0px)); padding:12px; background:var(--surface); border:1px solid var(--border-soft); border-radius:8px; display:grid; gap:10px; max-height:50dvh; overflow:auto; }
.rl-story-edit-panel textarea { min-height:80px; resize:none; width:100%; background:transparent; color:var(--text-primary); border:0; font-size:20px; }
.rl-story-edit-row { display:flex; flex-wrap:wrap; gap:6px; align-items:center; }
.rl-story-edit-panel select { max-width:130px; background:var(--input-bg); color:var(--text-primary); min-height:44px; }
.rl-story-edit-panel input[type=color] { width:48px; height:48px; padding:4px; }
.rl-story-edit-panel input[type=range] { min-width:90px; flex:1; accent-color:var(--primary); }
.rl-story-studio .rl-story-object-actions { position:absolute; z-index:45; display:flex; gap:8px; transform:translate(-50%,0); }
.rl-story-studio .rl-story-sound { position:absolute; right:12px; top:calc(132px + env(safe-area-inset-top,0px)); z-index:40; }
.rl-story-view-object-layer { position:absolute; inset:0; container-type:size; pointer-events:none; z-index:3; }
.rl-story-view-object-layer .rl-story-object { pointer-events:none; }
.rl-story-view-object-layer { z-index:4; }
.rl-story-view-object-layer .collaboration-mention { pointer-events:auto; font:inherit; color:inherit; text-decoration:underline; }
.rl-story-object-layer>.collaboration-suggestions { position:absolute; z-index:110; left:5%; right:5%; top:60%; pointer-events:auto; }
/* Size the entire portrait, not its intrinsic media; safe areas live outside it. */
.social-story-viewer {
  --story-width: min(calc(100dvw - max(8px, var(--safe-left, 0px)) - max(8px, var(--safe-right, 0px))), calc((100dvh - max(8px, var(--safe-top, 0px)) - max(8px, var(--safe-bottom, 0px))) * 9 / 16));
  overflow:hidden;
}
.social-story-viewer .social-story-frame {
  width:var(--story-width); height:calc(var(--story-width) * 16 / 9);
  min-width:0; min-height:0; aspect-ratio:9 / 16; container-type:inline-size;
}
.social-story-viewer .social-story-media { position:absolute; inset:0; min-block-size:0; }
.social-story-viewer .social-story-media :is(img,video) { object-fit:cover; }
.social-story-viewer .social-story-progress { top:10px; gap:5px; padding:4px; border-radius:6px; background:var(--media-scrim); }
.social-story-viewer .social-story-progress span { height:5px; min-width:0; border-radius:3px; background:var(--media-bg); box-shadow:0 1px 3px var(--media-scrim); }
.social-story-viewer .social-story-progress span.done { background:var(--media-bg); }
.social-story-viewer .social-story-progress span.active::after { display:none; }
.social-story-viewer .social-story-top { top:26px; gap:4px; }
.social-story-viewer .social-story-author { flex:1; min-width:0; }
.social-story-viewer .social-story-author > span:last-child { min-width:0; }
.social-story-viewer .social-story-top > button:not(.social-story-author) { flex:0 0 auto; padding:4px; font-size:14px; }
.social-story-viewer .social-story-overlay { padding:12px; max-height:calc(100% - 100px); overflow:auto; overflow-wrap:anywhere; }
.social-story-viewer .rl-story-interactions { min-width:0; }
.social-story-viewer .rl-story-interactions form { min-width:0; }
.social-story-viewer .rl-story-interactions input { width:0; }
.social-story-viewer .rl-story-interactions button { padding:6px; border:1px solid var(--media-bg); border-radius:6px; background:var(--media-scrim); color:var(--media-text); }
.social-story-viewer .rl-story-interactions form button { min-width:44px; flex:0 0 44px; }
.social-story-viewer .rl-story-interactions svg { width:22px; height:22px; }
@container (max-width:300px) {
  .social-story-top { flex-wrap:wrap; padding:4px; }
  .social-story-viewer .rl-story-reactions { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); }
  .social-story-viewer .social-story-overlay { padding:6px; }
}
.social-story-viewer .social-story-top>button { min-width:44px; min-height:44px; }
.social-story-viewer .social-story-top>button svg { width:22px; height:22px; }
.rl-story-interactions { display:grid; gap:8px; width:100%; pointer-events:auto; }
.rl-story-reactions { display:flex; justify-content:space-between; gap:4px; }
.rl-story-reactions button { min-width:44px; min-height:44px; background:var(--surface); border:0; font-size:22px; border-radius:6px; }
.rl-story-interactions form { display:flex; gap:8px; }
.rl-story-interactions input { min-width:0; flex:1; min-height:48px; background:var(--input-bg); color:var(--text-primary); border:1px solid var(--input-border); border-radius:8px; padding:10px; }
.rl-story-interactions button { min-height:44px; color:var(--text-primary); }
.rl-story-reply-card { display:flex; gap:10px; align-items:center; text-align:left; width:100%; padding:8px; background:var(--surface); border:1px solid var(--border-soft); color:var(--text-primary); border-radius:8px; }
.rl-story-reply-card :is(img,video) { width:48px; height:74px; object-fit:cover; border-radius:4px; }
.rl-story-reply-card small { display:block; }
.rl-story-reply-card.is-expired { opacity:.6; }
.rl-story-insights { color:var(--text-primary); background:var(--surface); border:1px solid var(--border-soft); border-radius:8px; width:min(440px,calc(100% - 24px)); max-height:75dvh; padding:18px; }
.rl-story-insights::backdrop { background:var(--overlay); }
.rl-story-insights header { display:flex; justify-content:space-between; align-items:center; }
.rl-story-insights button { min-height:44px; min-width:44px; }
.rl-story-insights ul { padding:0; list-style:none; }
.rl-story-insights li { padding:10px 0; border-bottom:1px solid var(--border-soft); overflow-wrap:anywhere; }
.social-story-viewer .rl-story-open-chat { display:flex; justify-content:space-between; align-items:center; width:100%; padding:10px 12px; min-height:48px; border-color:var(--media-bg); }
.social-story-viewer .rl-story-comments { display:flex; align-items:center; justify-content:center; gap:8px; min-height:44px; padding:8px 12px; background:var(--media-scrim); color:var(--media-text); border:1px solid var(--media-bg); border-radius:6px; }
.rl-story-comments svg { width:22px; height:22px; }
.social-comments-backdrop.diet-floating.is-story-comments { z-index:300; }
.chat-story-draft { grid-column:1 / -1; flex:0 0 100%; display:flex; align-items:center; gap:10px; width:100%; min-width:0; padding:8px; border-bottom:1px solid var(--border-soft); }
.chat-story-draft :is(img,video) { width:40px; height:64px; object-fit:cover; border-radius:4px; }
.chat-story-draft span { flex:1; min-width:0; font-size:13px; }
.chat-story-draft button { width:44px; height:44px; flex:none; }
.chat-story-draft svg { width:20px; height:20px; }
.chat-compose:has(.chat-story-draft) { flex-wrap:wrap; }
.chat-compose:has(.chat-story-draft) [hidden] { display:none!important; }
@media(prefers-reduced-motion:reduce) { .rl-story-studio * { transition:none!important; animation:none!important; } }
.social-story-viewer .rl-story-interactions { display:flex; align-items:center; gap:4px; }
.social-story-viewer .rl-story-icon, .social-story-viewer .rl-story-interactions .rl-story-icon, .rl-story-insights .rl-story-icon { display:inline-flex; align-items:center; justify-content:center; width:44px; height:44px; min-width:44px; min-height:44px; flex:0 0 44px; padding:10px; border:0; border-radius:6px; background:transparent; color:var(--media-text); }
.social-story-viewer .rl-story-icon:hover, .rl-story-insights .rl-story-icon:hover { background:var(--media-bg); }
.social-story-viewer .rl-story-icon:focus-visible, .rl-story-insights button:focus-visible { outline:2px solid var(--media-bg); outline-offset:2px; }
.rl-story-icon svg { width:22px; height:22px; }
.social-story-viewer .rl-story-reaction-picker { margin-left:auto; }
.social-story-viewer .social-story-actions { display:block; width:100%; }
.rl-story-status:empty { display:none; }
.rl-story-status { display:block; color:var(--text-primary); font-size:12px; padding:4px 8px; }
dialog.rl-story-insights { margin:auto; max-height:75dvh; overflow:auto; }
.rl-story-insights li { display:flex; align-items:center; justify-content:space-between; gap:16px; }
.rl-story-insights li span:first-child { min-width:0; }
.rl-story-insights li span:last-child { flex:none; font-size:22px; }
.rl-story-insights .rl-story-reactions { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:4px; margin-top:12px; }
.rl-story-insights .rl-story-reactions button { padding:4px; min-width:0; }
.rl-story-insights button:disabled { opacity:.45; cursor:wait; }
.rl-story-view-count { margin:12px 0 4px; color:var(--text-primary); }
@media(max-width:360px) { .rl-story-insights .rl-story-reactions { grid-template-columns:repeat(3,minmax(0,1fr)); } }
