:root {
    --vseti-bg: #000;
    --vseti-surface: #16181c;
    --vseti-surface-2: #202327;
    --vseti-border: #2f3336;
    --vseti-text: #eff3f4;
    --vseti-muted: #71767b;
    --vseti-blue: #1d9bf0;
    --vseti-rail: 248px;
    --vseti-mobile-nav: 64px;
    --vseti-keyboard-offset: 0px;
}

html { color-scheme: dark; background: var(--vseti-bg); }
body { background: var(--vseti-bg); }
body[data-vseti-view],
body[data-vseti-view] button,
body[data-vseti-view] input,
body[data-vseti-view] textarea {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
body.vseti-navigating { cursor: progress; }
body.vseti-navigating::before {
    content: "";
    position: fixed;
    z-index: 100000;
    top: 0;
    left: 0;
    height: 3px;
    width: 42%;
    border-radius: 0 3px 3px 0;
    background: var(--vseti-blue);
    animation: vseti-loading 850ms ease-in-out infinite alternate;
}
@keyframes vseti-loading { from { transform: translateX(-65%); } to { transform: translateX(235%); } }

/* Старые элементы чатов остаются в файлах, но не попадают в интерфейс. */
a[href="/chats"], a[href^="/chat?"], [data-nav="chats"], .chat-nav-item { display: none !important; }

.vseti-app-nav {
    position: fixed;
    z-index: 9000;
    display: flex;
    background: rgba(0, 0, 0, .9);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}
.vseti-app-nav__brand {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--vseti-text);
    font-size: 21px;
    font-weight: 850;
    text-decoration: none;
}
.vseti-app-nav__logo {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--vseti-surface);
}
.vseti-app-nav__items { display: flex; }
.vseti-app-nav__link {
    display: flex;
    align-items: center;
    color: var(--vseti-text);
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}
.vseti-app-nav__link:hover { background: rgba(239, 243, 244, .1); }
.vseti-app-nav__link[aria-current="page"] { color: var(--vseti-blue); }
.vseti-app-nav__link i { width: 29px; text-align: center; font-size: 22px; }

@media (min-width: 1024px) {
    body[data-vseti-view] { padding-left: var(--vseti-rail); }
    .vseti-app-nav {
        inset: 0 auto 0 0;
        width: var(--vseti-rail);
        flex-direction: column;
        padding: 24px 18px;
        border-right: 1px solid var(--vseti-border);
    }
    .vseti-app-nav__brand { padding: 0 10px 26px; }
    .vseti-app-nav__items { flex-direction: column; gap: 7px; }
    .vseti-app-nav__link { min-height: 52px; gap: 14px; padding: 0 14px; border-radius: 999px; font-size: 18px; font-weight: 680; }
    .vseti-app-nav__label { display: inline; }
    body[data-vseti-view] > .app-container,
    body[data-vseti-view] > .page,
    body[data-vseti-view] > .container,
    body[data-vseti-view] > .vseti-search-page,
    body[data-vseti-view] > .vseti-comments-page {
        width: min(780px, 100%);
        max-width: 780px;
        margin-inline: auto;
        border-inline: 1px solid var(--vseti-border);
    }
    body[data-vseti-view="posts"] .app-container .sidebar { display: none !important; }
    body[data-vseti-view="posts"] .main-content { max-width: 780px !important; border-left: 0; }
    body[data-vseti-view="profile"] .container,
    body[data-vseti-view="post"] .page { max-width: 780px !important; }
    .fab-create-post { right: max(28px, calc((100vw - var(--vseti-rail) - 780px) / 2 + 26px)) !important; bottom: 28px !important; }
}

@media (max-width: 1023px) {
    html, body { touch-action: pan-x pan-y; }
    body[data-vseti-view], body[data-vseti-view] * {
        -webkit-user-select: none !important;
        user-select: none !important;
        -webkit-touch-callout: none !important;
    }
    body[data-vseti-view] input,
    body[data-vseti-view] textarea,
    body[data-vseti-view] select,
    body[data-vseti-view] [contenteditable="true"],
    body[data-vseti-view] [role="textbox"] {
        -webkit-user-select: text !important;
        user-select: text !important;
    }
    body[data-vseti-view] img,
    body[data-vseti-view] video {
        -webkit-user-drag: none;
        user-drag: none;
    }
    body[data-vseti-view] { padding-bottom: calc(var(--vseti-mobile-nav) + env(safe-area-inset-bottom)); }
    .vseti-app-nav {
        inset: auto 0 0 0;
        min-height: calc(var(--vseti-mobile-nav) + env(safe-area-inset-bottom));
        padding: 5px 10px env(safe-area-inset-bottom);
        border-top: 1px solid var(--vseti-border);
    }
    .vseti-app-nav__brand { display: none; }
    .vseti-app-nav__items { width: 100%; justify-content: space-around; }
    .vseti-app-nav__link { width: 64px; min-height: 54px; justify-content: center; border-radius: 16px; }
    .vseti-app-nav__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    body[data-vseti-view="posts"] .sidebar { display: none !important; }
    .fab-create-post { bottom: calc(var(--vseti-mobile-nav) + env(safe-area-inset-bottom) + 14px) !important; }
}

/* Универсальные состояния и скелетоны. */
.vseti-state { padding: 58px 24px; text-align: center; color: var(--vseti-muted); }
.vseti-state strong { display: block; margin-bottom: 5px; color: var(--vseti-text); font-size: 18px; }
.vseti-skeleton {
    min-height: 14px;
    border-radius: 9px;
    background: linear-gradient(90deg, #16181c 25%, #25282c 50%, #16181c 75%);
    background-size: 200% 100%;
    animation: vseti-shimmer 1.25s linear infinite;
}
@keyframes vseti-shimmer { to { background-position-x: -200%; } }

/* Экран создания публикации. */
.vseti-compose-backdrop {
    position: fixed;
    z-index: 20000;
    inset: 0;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 6vh 18px;
    background: rgba(91, 112, 131, .42);
}
.vseti-compose-backdrop.open { display: flex; }
.vseti-compose {
    width: min(660px, 100%);
    min-height: 520px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--vseti-border);
    border-radius: 22px;
    background: #000;
    color: var(--vseti-text);
    box-shadow: 0 18px 70px rgba(0,0,0,.55);
}
.vseti-compose__top { display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: 12px 18px; }
.vseti-compose__cancel { border: 0; background: transparent; color: var(--vseti-text); font-size: 16px; cursor: pointer; }
.vseti-compose__publish { min-width: 116px; min-height: 40px; border: 0; border-radius: 999px; background: var(--vseti-blue); color: #fff; font-weight: 760; cursor: pointer; }
.vseti-compose__publish:disabled { opacity: .45; cursor: default; }
.vseti-compose__editor { flex: 1; display: grid; grid-template-columns: 46px 1fr; gap: 11px; padding: 8px 20px; }
.vseti-compose__avatar { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; background: var(--vseti-surface); }
.vseti-compose__text { width: 100%; min-height: 210px; resize: none; border: 0; outline: 0; background: transparent; color: var(--vseti-text); font-size: 21px; line-height: 1.45; }
.vseti-compose__text::placeholder { color: var(--vseti-muted); }
.vseti-compose__preview { grid-column: 2; display: none; position: relative; max-height: 320px; overflow: auto; border: 1px solid var(--vseti-border); border-radius: 16px; }
.vseti-compose__preview.show { display: block; }
.vseti-compose__media-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; }
.vseti-compose__media-item { position: relative; min-width: 0; min-height: 120px; overflow: hidden; border-radius: 12px; background: #050505; }
.vseti-compose__media-item:first-child:last-child { grid-column: 1 / -1; }
.vseti-compose__media-item img, .vseti-compose__media-item video { width: 100%; height: 150px; display: block; object-fit: contain; background: #050505; }
.vseti-compose__media-item:first-child:last-child img, .vseti-compose__media-item:first-child:last-child video { height: 260px; }
.vseti-compose__remove { position: absolute; top: 9px; right: 9px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(0,0,0,.72); color: #fff; cursor: pointer; }
.vseti-compose__audience { display: flex; align-items: center; gap: 8px; margin: 0 20px 6px 76px; padding: 11px 0; border: 0; background: transparent; color: var(--vseti-blue); font-weight: 720; cursor: pointer; }
.vseti-compose__tools { display: flex; align-items: center; gap: 4px; min-height: 58px; margin-left: 76px; padding: 7px 18px 12px 0; border-top: 1px solid var(--vseti-border); }
.vseti-compose__tool { width: 42px; height: 42px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--vseti-blue); font-size: 19px; cursor: pointer; }
.vseti-compose__tool:hover { background: rgba(29,155,240,.1); }
.vseti-upload-status { margin-left: auto; color: var(--vseti-muted); font-size: 13px; }

.vseti-audience-sheet { position: fixed; z-index: 21000; inset: 0; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(0,0,0,.64); }
.vseti-audience-sheet.open { display: flex; }
.vseti-audience-card { width: min(540px, 100%); max-height: min(720px, 90vh); overflow: auto; padding: 22px; border: 1px solid var(--vseti-border); border-radius: 24px; background: var(--vseti-surface); }
.vseti-audience-head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 18px; border-bottom: 1px solid #4a4e52; font-size: 21px; font-weight: 820; }
.vseti-audience-close { width: 38px; height: 38px; border: 0; border-radius: 50%; background: transparent; color: #fff; font-size: 23px; cursor: pointer; }
.vseti-audience-option { width: 100%; display: grid; grid-template-columns: 35px 1fr 26px; gap: 13px; align-items: center; padding: 17px 0; border: 0; background: transparent; color: #fff; text-align: left; font-size: 16px; font-weight: 710; cursor: pointer; }
.vseti-audience-option i:first-child { font-size: 22px; }
.vseti-audience-radio { width: 24px; height: 24px; border: 3px solid #555b60; border-radius: 50%; }
.vseti-audience-option.selected .vseti-audience-radio { border-color: #fff; box-shadow: inset 0 0 0 5px var(--vseti-surface); background: #fff; }
.vseti-audience-apply { width: 100%; min-height: 52px; margin-top: 10px; border: 0; border-radius: 999px; background: #fff; color: #000; font-size: 17px; font-weight: 800; cursor: pointer; }

@media (max-width: 700px) {
    .vseti-compose-backdrop { padding: 0; background: #000; }
    .vseti-compose { width: 100%; min-height: calc(100dvh - var(--vseti-keyboard-offset)); border: 0; border-radius: 0; box-shadow: none; }
    .vseti-compose__top { padding-top: max(12px, env(safe-area-inset-top)); }
    .vseti-compose__editor { padding-inline: 16px; }
    .vseti-compose__text { min-height: 38vh; }
    .vseti-compose__audience { margin-left: 72px; }
    .vseti-compose__tools { margin-left: 72px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
    .vseti-audience-sheet { align-items: flex-end; padding: 0; }
    .vseti-audience-card { width: 100%; max-height: 82dvh; border-radius: 28px 28px 0 0; padding: 24px 28px max(24px, env(safe-area-inset-bottom)); }
}

/* Поиск и отдельный экран комментариев. */
.vseti-search-page, .vseti-comments-page { min-height: 100vh; color: var(--vseti-text); }
.vseti-page-head { position: sticky; z-index: 50; top: 0; padding: max(12px, env(safe-area-inset-top)) 16px 12px; border-bottom: 1px solid var(--vseti-border); background: rgba(0,0,0,.86); backdrop-filter: blur(16px); }
.vseti-page-title { margin: 0 0 12px; font-size: 21px; }
.vseti-search-box { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 15px; border-radius: 999px; background: var(--vseti-surface); color: var(--vseti-muted); }
.vseti-search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--vseti-text); font-size: 16px; }
.vseti-tabs { display: flex; border-bottom: 1px solid var(--vseti-border); }
.vseti-tab { flex: 1; min-height: 50px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--vseti-muted); font-weight: 720; cursor: pointer; }
.vseti-tab.active { border-bottom-color: var(--vseti-blue); color: var(--vseti-text); }
.vseti-result { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--vseti-border); color: inherit; text-decoration: none; }
.vseti-result:hover { background: rgba(239,243,244,.04); }
.vseti-result__avatar { width: 48px; height: 48px; flex: 0 0 auto; border-radius: 50%; object-fit: cover; background: var(--vseti-surface); }
.vseti-result__body { min-width: 0; flex: 1; }
.vseti-result__name { font-weight: 780; }
.vseti-result__meta { color: var(--vseti-muted); }
.vseti-result__text { margin-top: 7px; overflow-wrap: anywhere; white-space: pre-wrap; }
.vseti-highlight { border-radius: 3px; background: rgba(29,155,240,.25); color: #8dccf7; }
.vseti-result__media { width: 110px; height: 78px; flex: 0 0 auto; border-radius: 12px; object-fit: cover; background: var(--vseti-surface); }

/* Композер комментариев не попадает под экранную клавиатуру. */
body[data-vseti-view="post"] .composer,
body[data-vseti-view="comments"] .vseti-comments-composer {
    position: fixed !important;
    bottom: calc(var(--vseti-mobile-nav) + var(--vseti-keyboard-offset) + env(safe-area-inset-bottom)) !important;
}
@media (min-width: 1024px) {
    body[data-vseti-view="post"] .composer {
        left: calc(var(--vseti-rail) + (100vw - var(--vseti-rail)) / 2);
        width: min(778px, calc(100vw - var(--vseti-rail)));
        transform: translateX(-50%);
    }
    body[data-vseti-view="post"] .composer,
    body[data-vseti-view="comments"] .vseti-comments-composer { bottom: 0 !important; }
}
@media (max-width: 1023px) {
    body[data-vseti-view="post"] .composer { left: 0; width: 100%; transform: none; }
}
body[data-vseti-view="post"] .page { padding-bottom: 120px; }
