/* =============================================
   local_stories — universal ring, viewer, publish modal, avatar lightbox
   ============================================= */

/* ── Universal gradient ring (applies to any decorated avatar wrapper) ── */
.ou-story-active { position: relative; cursor: pointer; }
/* Instagram-style ring: 3px gradient + 3px gap around the avatar. */
.ou-story-active::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    padding: 3px;
    background: conic-gradient(from 210deg, #feda75, #fa7e1e, #d62976, #962fbf, #4f5bd5, #feda75);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: 2;
}
.ou-story-active.ou-story-seen::after {
    background: #c7cdd8;
}
/* Big profile avatar: thicker ring. */
.avatar-large.ou-story-active::after {
    inset: -11px;
    padding: 4px;
}
/* Small 44-46px avatars (chat list, follower/like lists): slim ring with a
   TIGHT 1px gap to the avatar (owner: big white gap looks wrong). */
.ou-user-avatar.ou-story-active::after {
    inset: -3px;
    padding: 2px;
}

/* ── Fullscreen story viewer ── */
.ou-stv-overlay {
    position: fixed;
    inset: 0;
    z-index: 11000;
    background: #0b0d14;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}
.ou-stv-overlay, .ou-stv-overlay * {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.ou-stv-reply { -webkit-user-select: text; user-select: text; }
.ou-stv-media { -webkit-user-drag: none; }

.ou-stv-stage {
    position: relative;
    width: min(100vw, calc((100vh - 0px) * 0.5625)); /* 9:16 on desktop */
    height: 100vh;
    max-width: 480px;
    background: #000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
@media (min-width: 769px) {
    .ou-stv-stage { height: min(100vh, 860px); border-radius: 14px; }
    .ou-stv-overlay { background: rgba(2, 6, 23, 0.94); }
}

/* Segments */
.ou-stv-segments {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    gap: 4px;
    z-index: 6;
}
.ou-stv-seg { flex: 1; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.35); overflow: hidden; }
.ou-stv-seg-fill { display: block; width: 0; height: 100%; background: #fff; border-radius: 3px; }

/* Header */
.ou-stv-head {
    position: absolute;
    top: 22px;
    left: 10px;
    right: 6px;
    display: flex;
    align-items: center;
    gap: 9px;
    z-index: 6;
    color: #fff;
}
.ou-stv-ava { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #334; flex-shrink: 0; }
.ou-stv-who { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; text-decoration: none; }
.ou-stv-name { color: #fff; font-size: 13.5px; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ou-stv-ago { color: rgba(255, 255, 255, 0.7); font-size: 12px; line-height: 1.2; white-space: nowrap; }
.ou-stv-btn {
    width: 36px; height: 36px; border: none; background: transparent; color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; border-radius: 50%; flex-shrink: 0;
}
.ou-stv-btn:hover { background: rgba(255, 255, 255, 0.12); }

/* Media */
.ou-stv-media-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.ou-stv-media { max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: contain; }
.ou-stv-caption {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 76px;
    z-index: 5;
    color: #fff;
    font-size: 14px;
    line-height: 1.45;
    text-align: center;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
    max-height: 30vh;
    overflow: hidden;
}
.ou-stv-loading {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    color: rgba(255,255,255,0.7); z-index: 4;
}
.ou-stv-spin { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,0.25); border-top-color: #fff; border-radius: 50%; animation: oustvspin 0.8s linear infinite; }
@keyframes oustvspin { to { transform: rotate(360deg); } }

/* Tap zones */
.ou-stv-tap { position: absolute; top: 60px; bottom: 76px; width: 33%; z-index: 5; }
.ou-stv-tap-prev { left: 0; }
.ou-stv-tap-next { right: 0; width: 67%; }

/* Bottom bar */
.ou-stv-foot {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 6;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.55), transparent);
}
.ou-stv-reply {
    flex: 1;
    min-width: 0;
    height: 42px;
    padding: 0 16px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 21px;
    background: transparent;
    color: #fff;
    font-size: 14px;
    outline: none;
}
.ou-stv-reply::placeholder { color: rgba(255, 255, 255, 0.65); }
.ou-stv-emoji {
    border: none; background: transparent; font-size: 22px; line-height: 1;
    cursor: pointer; padding: 4px; border-radius: 8px; flex-shrink: 0;
    transition: transform 0.12s;
}
.ou-stv-emoji:hover { transform: scale(1.25); }
.ou-stv-send {
    height: 42px; padding: 0 14px; border: none; border-radius: 21px;
    background: #4052B5; color: #fff; font-size: 13.5px; font-weight: 600;
    cursor: pointer; flex-shrink: 0; display: none;
}
.ou-stv-reply-wrap { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.ou-stv-login {
    flex: 1; height: 42px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.45); border-radius: 21px;
    color: #fff; font-size: 14px; font-weight: 600; text-decoration: none;
}
.ou-stv-login:hover { background: rgba(255, 255, 255, 0.1); color: #fff; text-decoration: none; }
.ou-stv-views {
    flex: 1; height: 42px; display: inline-flex; align-items: center; gap: 8px;
    border: none; background: transparent; color: #fff; font-size: 14px; font-weight: 600;
    cursor: pointer;
}

/* Dropdown menu (report / delete / stats) */
.ou-stv-menu {
    position: absolute;
    top: 58px;
    right: 8px;
    z-index: 8;
    background: #1c2030;
    border: 1px solid #2c3145;
    border-radius: 10px;
    overflow: hidden;
    min-width: 200px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.ou-stv-menu button {
    display: flex; align-items: center; gap: 8px;
    width: 100%; padding: 11px 14px; border: none; background: transparent;
    color: #e2e8f0; font-size: 13.5px; text-align: left; cursor: pointer;
}
.ou-stv-menu button:hover { background: #262b3f; }
.ou-stv-menu button.danger { color: #f87171; }

/* Viewers sheet (own story stats) */
.ou-stv-sheet {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    max-height: 62%;
    background: #161a28;
    border-radius: 16px 16px 0 0;
    z-index: 9;
    display: flex;
    flex-direction: column;
    animation: oustvup 0.22s ease;
}
@keyframes oustvup { from { transform: translateY(40%); opacity: 0.4; } to { transform: none; opacity: 1; } }
.ou-stv-sheet-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px 10px; color: #fff; font-size: 14px; font-weight: 700;
    border-bottom: 1px solid #262b3f;
}
.ou-stv-sheet-list { overflow-y: auto; padding: 6px 0 14px; }
.ou-stv-viewer-row { display: flex; align-items: center; gap: 10px; padding: 8px 16px; }
.ou-stv-viewer-row img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.ou-stv-viewer-name { color: #e2e8f0; font-size: 13.5px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ou-stv-viewer-meta { color: #8b93a7; font-size: 12px; }
.ou-stv-viewer-react { font-size: 15px; margin-left: 6px; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #cbd5e1; }
.ou-stv-empty { color: #8b93a7; font-size: 13.5px; text-align: center; padding: 26px 16px; }

/* Sent feedback */
.ou-stv-toast {
    position: fixed;
    left: 16px; right: 16px;
    bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    margin: 0 auto;
    width: fit-content;
    max-width: calc(100% - 32px);
    background: rgba(17, 24, 39, 0.92); color: #fff; padding: 10px 18px;
    border-radius: 14px; font-size: 14px; font-weight: 600; line-height: 1.4;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    z-index: 12000;
    animation: oustv-toast-in 0.25s ease;
}
@keyframes oustv-toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* ── Chooser (avatar click): small action modal ── */
.ou-stc-overlay {
    position: fixed; inset: 0; z-index: 10500;
    background: rgba(2, 6, 23, 0.6);
    display: flex; align-items: center; justify-content: center;
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.ou-stc-modal {
    width: min(320px, calc(100vw - 40px));
    background: #fff; border-radius: 16px; overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.ou-stc-modal button, .ou-stc-modal a {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 15px 16px; border: none; background: transparent;
    color: #1e293b; font-size: 14.5px; font-weight: 600; cursor: pointer;
    text-decoration: none; border-bottom: 1px solid #eef1f6;
}
.ou-stc-modal button:last-child, .ou-stc-modal a:last-child { border-bottom: none; }
.ou-stc-modal button:hover, .ou-stc-modal a:hover { background: #f6f8fc; color: #4052B5; text-decoration: none; }
.ou-stc-modal .ou-stc-accent { color: #4052B5; }
body.theme-dark .ou-stc-modal { background: #1c2030; }
body.theme-dark .ou-stc-modal button, body.theme-dark .ou-stc-modal a { color: #e2e8f0; border-color: #262b3f; }
body.theme-dark .ou-stc-modal button:hover, body.theme-dark .ou-stc-modal a:hover { background: #262b3f; }

/* ── Avatar lightbox ── */
.ou-stl-overlay {
    position: fixed; inset: 0; z-index: 10600;
    background: rgba(2, 6, 23, 0.92);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 18px;
}
.ou-stl-img { max-width: min(86vw, 520px); max-height: 70vh; border-radius: 50%; object-fit: cover; aspect-ratio: 1; }
.ou-stl-actions { display: flex; gap: 10px; }
.ou-stl-btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 10px 18px; border: 1px solid rgba(255, 255, 255, 0.4); border-radius: 999px;
    background: transparent; color: #fff; font-size: 13.5px; font-weight: 600;
    cursor: pointer; text-decoration: none;
}
.ou-stl-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; text-decoration: none; }
.ou-stl-close { position: absolute; top: 14px; right: 14px; }

/* ── Publish modal ── */
.ou-stp-overlay {
    position: fixed; inset: 0; z-index: 10700;
    background: rgba(2, 6, 23, 0.7);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.ou-stp-modal {
    width: min(420px, 100%);
    max-height: calc(100vh - 32px);
    background: #fff; border-radius: 16px;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.ou-stp-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid #eef1f6; }
.ou-stp-title { font-size: 16px; font-weight: 700; color: #1e293b; }
.ou-stp-close { border: none; background: transparent; color: #64748b; cursor: pointer; width: 32px; height: 32px; border-radius: 8px; }
.ou-stp-close:hover { background: #f1f5f9; }
.ou-stp-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.ou-stp-drop {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    min-height: 180px; border: 2px dashed #cbd5e1; border-radius: 12px;
    color: #64748b; font-size: 13.5px; cursor: pointer; text-align: center; padding: 14px;
    transition: border-color 0.15s;
}
.ou-stp-drop:hover { border-color: #4052B5; color: #4052B5; }
.ou-stp-hint { font-size: 12px; color: #94a3b8; }
.ou-stp-preview { position: relative; border-radius: 12px; overflow: hidden; background: #000; max-height: 380px; display: none; }
.ou-stp-preview img, .ou-stp-preview video { width: 100%; max-height: 380px; object-fit: contain; display: block; }
.ou-stp-repick {
    position: absolute; top: 8px; right: 8px;
    border: none; border-radius: 8px; background: rgba(0, 0, 0, 0.55); color: #fff;
    padding: 6px 10px; font-size: 12px; cursor: pointer;
}
.ou-stp-caption {
    width: 100%; padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 10px;
    font-size: 14px; color: #1e293b; outline: none; resize: none; box-sizing: border-box;
}
.ou-stp-caption:focus { border-color: #4052B5; }
.ou-stp-select {
    width: 100%; padding: 10px 34px 10px 12px; border: 1px solid #e2e8f0; border-radius: 10px;
    font-size: 14px; color: #1e293b; background: #fff; cursor: pointer;
    -webkit-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center;
}
.ou-stp-foot { padding: 12px 16px 16px; border-top: 1px solid #eef1f6; }
.ou-stp-publish {
    width: 100%; height: 46px; border: none; border-radius: 12px;
    background: #4052B5; color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
    transition: background 0.15s;
}
.ou-stp-publish:hover { background: #34439a; }
.ou-stp-publish:disabled { opacity: 0.6; cursor: default; }
.ou-stp-progress { height: 5px; border-radius: 3px; background: #eef1f6; overflow: hidden; display: none; margin-bottom: 10px; }
.ou-stp-progress-fill { display: block; width: 0; height: 100%; background: #4052B5; transition: width 0.15s; }
.ou-stp-error { color: #dc2626; font-size: 13px; display: none; }
body.theme-dark .ou-stp-modal { background: #1c2030; }
body.theme-dark .ou-stp-head, body.theme-dark .ou-stp-foot { border-color: #262b3f; }
body.theme-dark .ou-stp-title { color: #e2e8f0; }
body.theme-dark .ou-stp-drop { border-color: #37405c; color: #94a3b8; }
body.theme-dark .ou-stp-caption, body.theme-dark .ou-stp-select { background: #12141f; border-color: #2a2d44; color: #e2e8f0; }
body.theme-dark .ou-stp-close:hover { background: #262b3f; }
body.theme-dark .ou-stp-progress { background: #262b3f; }

/* Mobile viewer full-bleed */
@media (max-width: 768px) {
    .ou-stv-stage { width: 100vw; height: 100dvh; max-width: none; border-radius: 0; }
}

/* ── Fullscreen publish editor (Instagram-style crop) ── */
.ou-ste-overlay {
    position: fixed; inset: 0; z-index: 11500; background: #0b0d14;
    display: flex; align-items: center; justify-content: center;
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.ou-ste-stage {
    position: relative;
    width: min(100vw, calc(100vh * 0.5625));
    height: 100vh;
    max-width: 480px;
    background: #000;
    display: flex; flex-direction: column; overflow: hidden;
}
@media (min-width: 769px) {
    .ou-ste-stage { height: min(100vh, 860px); border-radius: 14px; }
    .ou-ste-overlay { background: rgba(2, 6, 23, 0.94); }
}
.ou-ste-head {
    position: absolute; top: 10px; left: 6px; right: 6px;
    display: flex; align-items: center; justify-content: space-between;
    z-index: 6; color: #fff;
}
.ou-ste-viewport {
    position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab;
}
.ou-ste-viewport:active { cursor: grabbing; }
.ou-ste-img {
    position: absolute; left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    transform-origin: center;
    max-width: none; max-height: none;
    -webkit-user-drag: none;
}
.ou-ste-video { width: 100%; height: 100%; object-fit: contain; }
.ou-ste-foot {
    position: absolute; left: 0; right: 0; bottom: 0;
    padding: 12px 12px calc(14px + env(safe-area-inset-bottom, 0px));
    display: flex; flex-direction: column; gap: 9px; z-index: 6;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.72), transparent);
}
.ou-ste-caption {
    height: 42px; padding: 0 16px;
    border: 1px solid rgba(255, 255, 255, 0.45); border-radius: 21px;
    background: rgba(0, 0, 0, 0.3); color: #fff; font-size: 16px; outline: none; /* <16px = автозум iOS */
    -webkit-user-select: text; user-select: text;
}
.ou-ste-caption::placeholder { color: rgba(255, 255, 255, 0.65); }
.ou-ste-select {
    height: 40px; padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 12px;
    background: rgba(0, 0, 0, 0.35); color: #fff; font-size: 13.5px; outline: none;
}
.ou-ste-select option { color: #111; }
.ou-ste-publish {
    height: 46px; border: none; border-radius: 23px;
    background: #4052B5; color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
}
.ou-ste-publish:hover { background: #34439a; }
.ou-ste-publish:disabled { opacity: 0.6; cursor: default; }
.ou-ste-progress { height: 4px; border-radius: 2px; background: rgba(255,255,255,0.25); overflow: hidden; display: none; }
.ou-ste-progress span { display: block; width: 0; height: 100%; background: #fff; transition: width 0.15s; }

/* ── Fix: pre-built gray ring plates (profile, repetitors, tutor cards).
   Instagram semantics: no story → solid gray plate stays; story → the SAME
   plate becomes the gradient. Never draw a second outer ring around it. ── */
.ou-story-active .avatar-story-ring {
    background: conic-gradient(from 210deg, #feda75, #fa7e1e, #d62976, #962fbf, #4f5bd5, #feda75) !important;
}
.ou-story-active.ou-story-seen .avatar-story-ring { background: #c7cdd8 !important; }
.ou-story-active:has(.avatar-story-ring)::after { content: none !important; }

/* ── Viewers sheet: rows are profile links with small story rings ── */
.ou-stv-viewer-row { text-decoration: none; }
a.ou-stv-viewer-row:hover { background: #1d2232; text-decoration: none; }
.ou-stv-viewer-ava { position: relative; display: inline-flex; flex-shrink: 0; }
.ou-stv-viewer-ava img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.ou-stv-viewer-ava.ou-story-active::after { inset: -4px; padding: 2px; }

/* ── Three ring states (Instagram semantics) ──
   1. no stories at all  → thin neutral line (the fat gray plate reads as "seen");
   2. unseen stories     → gradient (default .ou-story-active);
   3. all stories seen   → fat gray plate. */
[data-story-checked]:not(.ou-story-active) .avatar-story-ring {
    background: #e5e7eb !important;
    inset: -3px !important;
    padding: 1.5px !important;
}
[data-story-checked]:not(.ou-story-active) .avatar-story-ring::after {
    inset: 1.5px !important;
}
.ou-story-active.ou-story-seen .avatar-story-ring {
    background: #d1d5db !important;
    inset: -5px !important;
    padding: 5px !important;
}
.ou-story-active.ou-story-seen::after { background: #d1d5db; }

/* ── Guest login prompt ── */
.ou-stc-login-head {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 20px 18px 14px; color: #64748b; border-bottom: 1px solid #eef1f6;
}
.ou-stc-login-head svg { color: #4052B5; }
.ou-stc-login-head p { margin: 0; font-size: 14px; color: #1e293b; text-align: center; font-weight: 600; }
body.theme-dark .ou-stc-login-head { border-color: #262b3f; }
body.theme-dark .ou-stc-login-head p { color: #e2e8f0; }

/* ── Story-gone page ── */
.ou-stview-gone {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    padding: 70px 16px; color: #64748b; text-align: center;
}
.ou-stview-gone p { font-size: 15px; margin: 0; }

/* ── Mobile: dynamic viewport height so the publish button is never hidden
   behind the browser bottom bar ── */
@media (max-width: 768px) {
    .ou-ste-stage { width: 100vw; height: 100vh; height: 100dvh; max-width: none; border-radius: 0; }
    .ou-stv-stage { height: 100vh; height: 100dvh; }
    .ou-ste-foot { padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
}

/* ── Story cards inside chat messages ── */
a.ou-story-chat-card { display: inline-block; line-height: 0; text-decoration: none; }
.ou-story-chat-thumb {
    width: 84px !important;
    height: 140px !important;
    max-width: 84px !important;
    object-fit: cover;
    border-radius: 10px;
    display: block;
    cursor: pointer;
}


