:root {
    --bg: #ffffff;
    --bg-soft: #f2f2f2;
    --bg-hover: #e5e5e5;
    --bg-raised: #ffffff;
    --text: #0f0f0f;
    --text-2: #606060;
    --line: #e5e5e5;
    --accent: #1a6dff;
    --accent-text: #ffffff;
    --chip-active-bg: #0f0f0f;
    --chip-active-text: #ffffff;
    --shadow: 0 4px 32px rgba(0, 0, 0, .1);
    --radius: 12px;
    --topbar: 56px;
    --sidebar: 240px;
    --c-youtube: #ff0033;
    --c-rutube: #100943;
    --c-vk: #0077ff;
    --c-boosty: #f15f2c;
    --c-telegram: #26a5e4;
    --c-max: #7b4dff;
    --c-twitch: #9146ff;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0f0f0f;
        --bg-soft: #272727;
        --bg-hover: #3f3f3f;
        --bg-raised: #212121;
        --text: #f1f1f1;
        --text-2: #aaaaaa;
        --line: #3f3f3f;
        --accent: #4d8dff;
        --chip-active-bg: #f1f1f1;
        --chip-active-text: #0f0f0f;
        --shadow: 0 4px 32px rgba(0, 0, 0, .5);
        --c-rutube: #ffffff;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #0f0f0f;
    --bg-soft: #272727;
    --bg-hover: #3f3f3f;
    --bg-raised: #212121;
    --text: #f1f1f1;
    --text-2: #aaaaaa;
    --line: #3f3f3f;
    --accent: #4d8dff;
    --chip-active-bg: #f1f1f1;
    --chip-active-text: #0f0f0f;
    --shadow: 0 4px 32px rgba(0, 0, 0, .5);
    --c-rutube: #ffffff;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.4 Roboto, "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }

.icon { width: 24px; height: 24px; flex: none; }
.icon--sm { width: 20px; height: 20px; }
.icon--xs { width: 14px; height: 14px; }
.icon--accent { color: var(--c-youtube); }
.muted { color: var(--text-2); }

/* Цвета брендов */
.brand { display: inline-flex; }
.brand--youtube { color: var(--c-youtube); }
.brand--rutube { color: var(--c-rutube); }
.brand--vk, .brand--vkvideo { color: var(--c-vk); }
.brand--boosty { color: var(--c-boosty); }
.brand--telegram { color: var(--c-telegram); }
.brand--max { color: var(--c-max); }
.brand--twitch { color: var(--c-twitch); }
.brand-bg--youtube { background: var(--c-youtube); }
.brand-bg--rutube { background: #100943; }
.brand-bg--vk, .brand-bg--vkvideo { background: var(--c-vk); }
.brand-bg--boosty { background: var(--c-boosty); }
.brand-bg--telegram { background: var(--c-telegram); }
.brand-bg--max { background: var(--c-max); }
.brand-bg--twitch { background: var(--c-twitch); }

/* Кнопки */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 16px;
    border: 0;
    border-radius: 18px;
    background: var(--bg-soft);
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s;
}
.btn:hover { background: var(--bg-hover); }
.btn .icon { width: 20px; height: 20px; }
.btn--accent { background: var(--text); color: var(--bg); }
.btn--accent:hover { background: var(--text); opacity: .85; }
.btn--youtube, .btn--rutube, .btn--vkvideo { color: #fff; }
.btn--youtube { background: var(--c-youtube); }
.btn--rutube { background: #100943; }
.btn--vkvideo { background: var(--c-vk); }
.btn--youtube:hover { background: var(--c-youtube); }
.btn--rutube:hover { background: #100943; }
.btn--vkvideo:hover { background: var(--c-vk); }
.btn--ghost { background: transparent; border: 1px solid var(--line); color: var(--accent); }
.btn--ghost:hover { background: var(--bg-soft); }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}
.icon-btn:hover { background: var(--bg-soft); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Шапка */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: var(--topbar);
    padding: 0 16px;
    background: var(--bg);
}
.topbar__start, .topbar__end { display: flex; align-items: center; gap: 8px; flex: none; }
.logo { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.logo img { width: 32px; height: 32px; border-radius: 50%; }

.search { display: flex; flex: 0 1 640px; min-width: 0; }
.search__input {
    flex: 1;
    min-width: 0;
    height: 40px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-right: 0;
    border-radius: 20px 0 0 20px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 16px;
}
.search__input:focus { outline: none; border-color: var(--accent); }
.search__btn {
    display: grid;
    place-items: center;
    width: 64px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: 0 20px 20px 0;
    background: var(--bg-soft);
    cursor: pointer;
}
.search__btn .icon { width: 22px; height: 22px; }
.search-open { display: none; }

/* Каркас */
.shell { display: flex; }

.sidebar {
    position: sticky;
    top: var(--topbar);
    flex: none;
    width: var(--sidebar);
    height: calc(100vh - var(--topbar));
    padding: 12px;
    overflow-y: auto;
    background: var(--bg);
    scrollbar-width: thin;
}
.sidebar__section { padding: 12px 0; border-bottom: 1px solid var(--line); }
.sidebar__section:first-child { padding-top: 0; }
.sidebar__title { padding: 6px 12px; font-size: 16px; font-weight: 600; }
.sidebar__foot { padding: 16px 12px; color: var(--text-2); font-size: 12px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 40px;
    padding: 0 12px;
    border-radius: 10px;
}
.nav-item:hover { background: var(--bg-soft); }
.nav-item.is-active { background: var(--bg-soft); font-weight: 600; }
.scrim { display: none; }

.main { flex: 1; min-width: 0; padding: 0 24px 48px; }

/* Шапка канала */
.channel { max-width: 1284px; margin: 0 auto; }
.channel__banner { margin-top: 8px; border-radius: var(--radius); overflow: hidden; aspect-ratio: 6.2 / 1; background: var(--bg-soft); }
.channel__banner img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
.channel__head { display: flex; gap: 24px; align-items: center; padding: 16px 0; }
.channel__avatar { width: 160px; height: 160px; flex: none; border-radius: 50%; object-fit: cover; }
.channel__info { min-width: 0; }
.channel__name { font-size: 36px; font-weight: 700; line-height: 1.2; letter-spacing: -.5px; }
.channel__stats { display: flex; flex-wrap: wrap; gap: 0 6px; margin-top: 6px; color: var(--text-2); }
.channel__stats span + span::before { content: "·"; margin-right: 6px; }
.channel__stats span:first-child { color: var(--text); font-weight: 500; }
.channel__desc { display: block; margin-top: 6px; color: var(--text-2); }
.channel__desc span { color: var(--text); font-weight: 500; }
.channel__subscribe { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab { padding: 12px 0; color: var(--text-2); font-size: 16px; font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--text); }

/* Чипсы */
.chips { display: flex; gap: 12px; max-width: 1284px; margin: 0 auto; padding: 16px 0 20px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 32px; padding: 0 12px; border-radius: 8px; background: var(--bg-soft); font-weight: 500; line-height: 32px; white-space: nowrap; }
.chip:hover { background: var(--bg-hover); }
.chip.is-active { background: var(--chip-active-bg); color: var(--chip-active-text); }

/* Сетка роликов */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 40px 16px;
    max-width: 1284px;
    margin: 0 auto;
}
.card { display: block; min-width: 0; }
.thumb { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: var(--bg-soft); }
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.card:hover .thumb img { transform: scale(1.03); }
.thumb__time {
    position: absolute;
    right: 8px;
    bottom: 8px;
    padding: 1px 4px;
    border-radius: 4px;
    background: rgba(0, 0, 0, .8);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
}
.card__body { padding-top: 12px; }
.card__title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 16px;
    font-weight: 500;
    line-height: 22px;
}
.card__meta { margin-top: 4px; color: var(--text-2); }
.card__platforms { display: flex; gap: 6px; margin-top: 6px; opacity: .9; }

/* Shorts */
.shelf { max-width: 1284px; margin: 40px auto; padding: 24px 0; border-block: 1px solid var(--line); }
.shelf__title { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 20px; }
.shelf__row { display: grid; grid-auto-flow: column; grid-auto-columns: 210px; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: thin; padding-bottom: 8px; }
.shelf__row .short-card { scroll-snap-align: start; }
.shelf__more { display: inline-block; margin-top: 12px; color: var(--accent); font-weight: 500; }
.shorts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(46%, 200px), 1fr));
    gap: 24px 8px;
    max-width: 1284px;
    margin: 20px auto 0;
}
.short-card { display: block; min-width: 0; }
.short-card__thumb { aspect-ratio: 9 / 16; border-radius: var(--radius); overflow: hidden; background: var(--bg-soft); }
.short-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.short-card__title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 8px;
    font-size: 15px;
    font-weight: 500;
    line-height: 21px;
}

.more { display: flex; justify-content: center; margin-top: 32px; }
.empty { max-width: 1284px; margin: 48px auto; color: var(--text-2); font-size: 16px; text-align: center; }

/* Списки (поиск, «Следующие») */
.page-head { max-width: 1096px; margin: 24px auto 16px; }
.page-title { font-size: 24px; }
.list { display: flex; flex-direction: column; gap: 16px; max-width: 1096px; margin: 0 auto; }
.list .card { display: grid; grid-template-columns: minmax(0, 360px) 1fr; gap: 16px; }
.list .card__body { padding-top: 0; }
.list .card__title { font-size: 18px; line-height: 26px; }
.list--compact { gap: 8px; }
.list--compact .card { grid-template-columns: 168px 1fr; gap: 8px; }
.list--compact .thumb { border-radius: 8px; }
.list--compact .card__title { font-size: 14px; line-height: 20px; }
.list--compact .card__meta { font-size: 12px; }
.list--compact .card__platforms { margin-top: 4px; }

/* Страница ролика */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) 402px; gap: 24px; max-width: 1754px; margin: 0 auto; padding-top: 24px; }
.watch--short { grid-template-columns: minmax(0, 1fr) 360px; }
.players { display: flex; flex-direction: column; gap: 12px; }
.players__rest { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.players__rest.players--n1 { grid-template-columns: minmax(0, 1fr); max-width: 50%; }
.player { margin: 0; min-width: 0; }
.player__frame { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; }
.player__frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player__facade { position: absolute; inset: 0; padding: 0; border: 0; background: #000; cursor: pointer; }
.player__facade img { width: 100%; height: 100%; object-fit: cover; opacity: .92; transition: opacity .2s; }
.player__facade:hover img { opacity: 1; }
.player__play {
    position: absolute;
    top: 50%;
    left: 50%;
    display: grid;
    place-items: center;
    width: 68px;
    height: 48px;
    border-radius: 14px;
    color: #fff;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 12px rgba(0, 0, 0, .35);
    transition: transform .15s;
}
.player__facade:hover .player__play { transform: translate(-50%, -50%) scale(1.08); }
.player__play .icon { width: 30px; height: 30px; }
.player:not(.player--main) .player__play { width: 56px; height: 40px; border-radius: 12px; }
.player__bar { display: flex; align-items: center; gap: 8px; padding: 8px 4px 0; }
.player__bar .brand .icon { width: 20px; height: 20px; }
.player__name { font-weight: 600; }
.player__views { color: var(--text-2); font-size: 13px; }
.player__open { display: inline-grid; place-items: center; width: 32px; height: 32px; margin-left: auto; border-radius: 50%; color: var(--text-2); }
.player__open:hover { background: var(--bg-soft); color: var(--text); }

.players--shorts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; max-width: 1000px; }
.players--shorts.players--n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 680px; }
.players--shorts.players--n1 { grid-template-columns: minmax(0, 1fr); max-width: 360px; }
.players--shorts .player__frame { aspect-ratio: 9 / 16; }

.watch__title { margin-top: 16px; font-size: 20px; font-weight: 700; line-height: 28px; overflow-wrap: anywhere; }
.watch__owner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.owner { display: flex; align-items: center; gap: 12px; }
.owner img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.owner span { display: flex; flex-direction: column; }
.owner b { font-size: 16px; font-weight: 600; }
.owner small { color: var(--text-2); font-size: 12px; }
.watch__links { display: flex; flex-wrap: wrap; gap: 8px; }

.descr { margin-top: 12px; padding: 12px; border-radius: var(--radius); background: var(--bg-soft); }
.descr__meta { font-weight: 600; }
.descr__text { position: relative; max-height: 4.2em; margin-top: 6px; overflow: hidden; overflow-wrap: anywhere; }
.descr__text a { color: var(--accent); }
.descr.is-open .descr__text { max-height: none; }
.descr__toggle { margin-top: 4px; padding: 0; border: 0; background: none; font-weight: 600; cursor: pointer; }

.aside__title { margin-bottom: 12px; font-size: 16px; }
.shorts-grid--aside { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 0; }

/* О канале */
.about { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 48px; max-width: 1284px; margin: 24px auto 0; }
.about__block + .about__block { margin-top: 32px; }
.about__block h2 { margin-bottom: 12px; font-size: 20px; }
.about__text { font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
.about__text a { color: var(--accent); }
.socials { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 8px; }
.social { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius); background: var(--bg-soft); }
.social:hover { background: var(--bg-hover); }
.social__icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; color: #fff; }
.social__icon .icon { width: 22px; height: 22px; }
.social__text { display: flex; flex-direction: column; min-width: 0; }
.social__text small { overflow: hidden; color: var(--text-2); text-overflow: ellipsis; white-space: nowrap; }
.stats { margin: 0; }
.stats div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.stats dt { color: var(--text-2); }
.stats dd { margin: 0; font-weight: 600; text-align: right; white-space: nowrap; }

.notfound { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 80px 0; text-align: center; }
.notfound img { width: 160px; height: 160px; }
.notfound h1 { font-size: 24px; }

/* Адаптив */
@media (max-width: 1312px) {
    .main { padding: 0 16px 40px; }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 50;
        height: 100%;
        padding-top: calc(var(--topbar) + 4px);
        transform: translateX(-100%);
        transition: transform .2s;
        box-shadow: var(--shadow);
    }
    body.menu-open .sidebar { transform: none; }
    body.menu-open .scrim { position: fixed; inset: 0; z-index: 40; display: block; background: rgba(0, 0, 0, .4); }
    body.menu-open .topbar { z-index: 60; }
}

@media (max-width: 1100px) {
    .watch, .watch--short { grid-template-columns: minmax(0, 1fr); }
    .list--compact { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 24px 16px; }
    .list--compact .card { display: block; }
    .list--compact .card__body { padding-top: 10px; }
    .shorts-grid--aside { grid-template-columns: repeat(auto-fill, minmax(min(46%, 180px), 1fr)); }
    .about { grid-template-columns: minmax(0, 1fr); gap: 32px; }
}

@media (max-width: 720px) {
    .topbar { gap: 4px; padding: 0 8px; }
    .logo span { display: none; }
    .search { display: none; }
    .search-open { display: inline-grid; }
    body.search-mode .topbar__start, body.search-mode .topbar__end { display: none; }
    body.search-mode .search { display: flex; flex: 1; }
    .topbar__end .btn span { display: none; }
    .topbar__end .btn { width: 36px; padding: 0; justify-content: center; }

    .main { padding: 0 12px 32px; }
    .channel__banner { aspect-ratio: 3.2 / 1; }
    .channel__head { gap: 16px; align-items: flex-start; }
    .channel__avatar { width: 72px; height: 72px; }
    .channel__name { font-size: 24px; }
    .channel__stats { font-size: 13px; }
    .channel__desc { font-size: 13px; }

    .grid { gap: 24px; }
    .list .card { display: block; }
    .list .card__body { padding-top: 10px; }
    .list .card__title { font-size: 16px; line-height: 22px; }

    .watch { padding-top: 12px; }
    .players__rest, .players__rest.players--n1 { grid-template-columns: minmax(0, 1fr); max-width: none; }
    .players--shorts, .players--shorts.players--n2 {
        display: grid;
        grid-auto-flow: column;
        grid-template-columns: none;
        grid-auto-columns: 78%;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
        max-width: none;
    }
    .players--shorts .player { scroll-snap-align: center; }
    .players--shorts.players--n1 { grid-auto-columns: 100%; max-width: 360px; margin: 0 auto; }
    .watch__title { font-size: 18px; line-height: 26px; }
    .shelf__row { grid-auto-columns: 42%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}
