/* ============================================================
   Тубик.ТВ — современная тёмная тема в стиле YouTube
   ============================================================ */

:root {
    --bg: #0f0f0f;
    --surface: #212121;
    --surface-2: #272727;
    --surface-3: #383838;
    --hover: #3f3f3f;
    --text: #f1f1f1;
    --text-2: #aaaaaa;
    --line: #303030;
    --accent: #ff0000;
    --accent-dark: #cc0000;
    --link: #3ea6ff;
    --nav-h: 56px;
    --sidebar-w: 228px;
    --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Roboto", "Segoe UI", Arial, sans-serif;
    font-size: 14px;
}

a { color: inherit; text-decoration: none; }
a:hover { color: inherit; text-decoration: none; }
img { display: block; }

/* ---------------- Шапка ---------------- */

.yt-nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--nav-h);
    background: var(--bg);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    z-index: 1000;
}

.yt-nav-burger {
    width: 40px; height: 40px;
    border: 0; border-radius: 50%;
    background: transparent;
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    flex: none;
}
.yt-nav-burger:hover { background: var(--surface-2); }

.yt-brand {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: none;
}
.yt-brand img { height: 26px; width: auto; }
.yt-brand span {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -.5px;
    color: var(--text);
    white-space: nowrap;
}
.yt-brand sup { color: var(--text-2); font-weight: 400; }

.yt-search {
    flex: 1;
    max-width: 640px;
    margin: 0 auto;
    display: flex;
}
.yt-search input {
    flex: 1;
    height: 40px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-right: 0;
    border-radius: 20px 0 0 20px;
    background: #121212;
    color: var(--text);
    font-size: 15px;
    outline: none;
}
.yt-search input:focus { border-color: var(--link); }
.yt-search input::placeholder { color: #888; }
.yt-search button {
    width: 64px; height: 40px;
    border: 1px solid var(--line);
    border-radius: 0 20px 20px 0;
    background: var(--surface-2);
    color: var(--text);
    font-size: 15px;
    cursor: pointer;
}
.yt-search button:hover { background: var(--surface-3); }

.yt-nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
    margin-left: auto;
}

.yt-auth-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border-radius: 18px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}
.yt-auth-link:hover { background: var(--surface-2); }
.yt-auth-link.solid {
    background: #fff;
    color: #0f0f0f;
}
.yt-auth-link.solid:hover { background: #d9d9d9; }

.yt-user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 6px 0 6px;
    border-radius: 18px;
    background: var(--surface-2);
    font-size: 13px;
    color: var(--text);
    max-width: 260px;
}
.yt-user-chip .yt-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex: none;
}
.yt-user-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.yt-user-chip:hover { background: var(--surface-3); }

/* ---------------- Каркас ---------------- */

.yt-shell {
    display: flex;
    padding-top: var(--nav-h);
    min-height: 100vh;
}

.yt-sidebar {
    width: var(--sidebar-w);
    flex: none;
    position: fixed;
    top: var(--nav-h);
    bottom: 0;
    left: 0;
    padding: 12px;
    overflow-y: auto;
    background: var(--bg);
}
.yt-sidebar-item {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    color: var(--text);
}
.yt-sidebar-item i { width: 22px; text-align: center; font-size: 16px; }
.yt-sidebar-item:hover { background: var(--surface-2); }
.yt-sidebar-item.active { background: var(--surface-2); font-weight: 500; }
.yt-sidebar-sep {
    border-top: 1px solid var(--line);
    margin: 10px 4px;
}
.yt-sidebar-title {
    padding: 6px 12px;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
}

.yt-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 24px;
    min-width: 0;
}

/* ---------------- Чипсы-фильтры ---------------- */

.yt-chips {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.yt-chip {
    height: 32px;
    padding: 0 13px;
    border: 0;
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.yt-chip:hover { background: var(--surface-3); }
.yt-chip.active {
    background: #f1f1f1;
    color: #0f0f0f;
}

.yt-page-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 18px;
}

/* ---------------- Сетка карточек ---------------- */

.yt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 22px 16px;
}

.yt-card {
    display: block;
    cursor: pointer;
}
.yt-card-thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}
.yt-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .2s ease;
}
.yt-card:hover .yt-card-thumb img { transform: scale(1.04); }
.yt-badge {
    position: absolute;
    left: 8px;
    bottom: 8px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    letter-spacing: .2px;
}
.yt-badge.source-youtube { background: rgba(204, 0, 0, .92); }
.yt-badge.source-vk { background: rgba(0, 119, 255, .92); }
.yt-badge.source-rutube { background: rgba(0, 100, 180, .92); }
.yt-badge.source-dzen { background: rgba(240, 170, 0, .92); }

.yt-card-meta {
    display: flex;
    gap: 12px;
    padding: 12px 2px 0;
}
.yt-card-avatar {
    width: 36px; height: 36px;
    flex: none;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-2);
}
.yt-card-avatar.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-2);
    font-size: 15px;
}
.yt-card-title {
    margin: 0 0 5px;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.35;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.yt-card:hover .yt-card-title { color: #fff; }
.yt-card-line {
    margin: 0;
    font-size: 13px;
    color: var(--text-2);
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    overflow: hidden;
}
.yt-card-line a { color: var(--text-2); }
.yt-card-line a:hover { color: var(--text); }

/* ---------------- Страница просмотра ---------------- */

.yt-watch {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 24px;
    align-items: start;
}
@media (max-width: 1100px) {
    .yt-watch { grid-template-columns: 1fr; }
}

.yt-player {
    aspect-ratio: 16 / 9;
    width: 100%;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
}
.yt-player iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.yt-watch-title {
    font-size: 19px;
    font-weight: 700;
    line-height: 1.4;
    margin: 14px 0 10px;
}

.yt-watch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}
.yt-watch-source {
    display: flex;
    align-items: center;
    gap: 12px;
}
.yt-watch-source img { height: 28px; width: auto; }
.yt-watch-source b { font-size: 15px; display: block; }
.yt-watch-source small { color: var(--text-2); font-size: 12px; }

.yt-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 18px;
    border: 0;
    border-radius: 19px;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.yt-btn:hover { background: var(--accent-dark); color: #fff; }
.yt-btn.ghost {
    background: var(--surface-2);
    color: var(--text);
}
.yt-btn.ghost:hover { background: var(--surface-3); }

.yt-desc {
    margin-top: 14px;
    padding: 14px 16px;
    background: var(--surface);
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
}
.yt-desc h6 { margin: 0 0 6px; font-size: 14px; font-weight: 600; }
.yt-desc p { margin: 0; color: var(--text-2); }

/* Похожие видео */

.yt-related-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 12px;
}
.yt-related {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.yt-related-item {
    display: flex;
    gap: 10px;
    padding: 4px;
    border-radius: 10px;
}
.yt-related-item:hover { background: var(--surface); }
.yt-related-thumb {
    position: relative;
    width: 168px;
    flex: none;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface);
}
.yt-related-thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
}
.yt-related-info { min-width: 0; }
.yt-related-info h4 {
    margin: 0 0 4px;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.35;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.yt-related-info p {
    margin: 0;
    font-size: 12px;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.yt-related-info .yt-badge { position: static; display: inline-block; margin-top: 5px; }

/* ---------------- Формы / карточки-центры ---------------- */

.yt-center-wrap {
    max-width: 420px;
    margin: 40px auto;
}
.yt-panel {
    background: var(--surface);
    border-radius: 16px;
    padding: 28px;
}
.yt-panel h4 {
    margin: 0 0 18px;
    font-size: 20px;
    font-weight: 700;
    text-align: center;
}
.yt-panel .alert {
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 13.5px;
}
.yt-panel .alert-danger { background: rgba(255, 0, 0, .14); color: #ff8989; }
.yt-panel .alert-success { background: rgba(62, 166, 255, .14); color: #7cc4ff; }

.yt-field { margin-bottom: 16px; }
.yt-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-2);
}
.yt-field input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #121212;
    color: var(--text);
    font-size: 15px;
    outline: none;
}
.yt-field input:focus { border-color: var(--link); }
.yt-field small { color: var(--text-2); font-size: 12px; }

.yt-panel .yt-btn { width: 100%; justify-content: center; }
.yt-panel-foot {
    margin-top: 16px;
    text-align: center;
    font-size: 13.5px;
    color: var(--text-2);
}
.yt-panel-foot a { color: var(--link); }

.yt-message {
    text-align: center;
}
.yt-message .yt-message-icon {
    font-size: 44px;
    margin-bottom: 12px;
}
.yt-message p { color: var(--text); font-size: 14.5px; line-height: 1.5; }
.yt-message .yt-btn { margin-top: 14px; }
.yt-message .yt-btn + .yt-btn { margin-left: 8px; }

/* ---------------- 404 ---------------- */

.yt-404 {
    text-align: center;
    padding: 60px 0;
}
.yt-404 img { margin: 0 auto 20px; max-width: 220px; }
.yt-404 h1 { font-size: 26px; font-weight: 700; }
.yt-404 p { color: var(--text-2); }

/* ---------------- Подвал ---------------- */

.yt-footer {
    margin-top: 48px;
    padding: 20px 0 28px;
    border-top: 1px solid var(--line);
    color: var(--text-2);
    font-size: 12.5px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}
.yt-footer a { color: var(--text-2); }
.yt-footer a:hover { color: var(--text); }

/* ---------------- Адаптив ---------------- */

.yt-nav-search-toggle { display: none; }

@media (max-width: 900px) {
    .yt-sidebar {
        display: none;
    }
    .yt-sidebar.open {
        display: block;
        position: fixed;
        top: var(--nav-h);
        left: 0;
        bottom: 0;
        z-index: 998;
        box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .5);
    }
    .yt-content {
        margin-left: 0;
        padding: 16px;
    }
    .yt-search { display: none; }
    .yt-search.open {
        display: flex;
        position: fixed;
        top: var(--nav-h);
        left: 8px; right: 8px;
        z-index: 999;
    }
    .yt-search.open input, .yt-search.open button { border-radius: 20px; border: 1px solid var(--line); }
    .yt-search.open button { border-left: 0; }
    .yt-nav-search-toggle { display: inline-flex; }
    .yt-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px 12px; }
}

@media (max-width: 480px) {
    .yt-brand span { display: none; }
    .yt-grid { grid-template-columns: 1fr; }
    .yt-related-thumb { width: 130px; }
}

/* ---------------- Таймер и пакеты ---------------- */

.yt-timer {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 16px;
    border-radius: 19px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}
.yt-timer i { color: #7cc4ff; }

.yt-packages {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.yt-package input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.yt-package-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 18px 12px;
    border: 2px solid var(--line);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
.yt-package-body b {
    font-size: 22px;
    font-weight: 700;
}
.yt-package-body small {
    color: var(--text-2);
    font-size: 12.5px;
}
.yt-package:hover .yt-package-body {
    background: var(--surface-2);
}
.yt-package input:checked + .yt-package-body {
    border-color: var(--accent);
    background: rgba(255, 0, 0, .08);
}

.yt-panel select {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #121212;
    color: var(--text);
    font-size: 15px;
    outline: none;
}
.yt-panel select:focus { border-color: var(--link); }

/* ---------------- Индикатор времени (шапка) ---------------- */

.yt-time-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 14px;
    border-radius: 18px;
    background: rgba(62, 166, 255, .10);
    border: 1px solid rgba(62, 166, 255, .35);
    color: var(--text);
    font-size: 13.5px;
    font-weight: 600;
    overflow: hidden;
    white-space: nowrap;
}
.yt-time-chip i {
    color: #7cc4ff;
    position: relative;
    z-index: 1;
}
.yt-time-chip span {
    position: relative;
    z-index: 1;
}
.yt-time-chip .yt-time-fill {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    background: rgba(62, 166, 255, .18);
    transition: width .6s ease;
}
.yt-time-chip:hover { border-color: rgba(62, 166, 255, .7); }
.yt-time-chip.low {
    background: rgba(255, 68, 68, .10);
    border-color: rgba(255, 68, 68, .45);
}
.yt-time-chip.low i { color: #ff7b7b; }
.yt-time-chip.low .yt-time-fill { background: rgba(255, 68, 68, .16); }

/* Старый таймер на странице просмотра — в том же стиле */
.yt-timer {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 16px;
    border-radius: 19px;
    background: rgba(62, 166, 255, .10);
    border: 1px solid rgba(62, 166, 255, .35);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}
.yt-timer i {
    color: #7cc4ff;
    position: relative;
    z-index: 1;
}
.yt-timer #watch-left { position: relative; z-index: 1; }
.yt-timer .yt-time-fill {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    background: rgba(62, 166, 255, .18);
}

/* ---------------- Личный кабинет ---------------- */

.yt-account {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.yt-account-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 26px;
}
.yt-account-head {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 20px;
}
.yt-account-avatar {
    width: 56px; height: 56px;
    flex: none;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}
.yt-account-email {
    margin: 0 0 4px;
    font-size: 20px;
    font-weight: 700;
    word-break: break-all;
}
.yt-account-since {
    margin: 0;
    color: var(--text-2);
    font-size: 13px;
}

.yt-balance {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    border-radius: 14px;
    background: rgba(62, 166, 255, .08);
    border: 1px solid rgba(62, 166, 255, .3);
}
.yt-balance.low {
    background: rgba(255, 68, 68, .07);
    border-color: rgba(255, 68, 68, .35);
}
.yt-balance-icon {
    width: 44px; height: 44px;
    flex: none;
    border-radius: 50%;
    background: rgba(62, 166, 255, .18);
    color: #7cc4ff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
.yt-balance.low .yt-balance-icon {
    background: rgba(255, 68, 68, .16);
    color: #ff7b7b;
}
.yt-balance-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.yt-balance-label {
    font-size: 12.5px;
    color: var(--text-2);
}
.yt-balance-value {
    font-size: 20px;
    font-weight: 700;
}
.yt-balance-track {
    height: 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, .08);
    overflow: hidden;
    margin-top: 4px;
}
.yt-balance-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #3ea6ff, #7cc4ff);
}
.yt-balance.low .yt-balance-fill {
    background: linear-gradient(90deg, #ff4444, #ff7b7b);
}
.yt-balance .yt-btn { flex: none; }

.yt-account-actions {
    margin-top: 18px;
    display: flex;
    justify-content: flex-end;
}
.yt-account-title {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 700;
}

.yt-history {
    display: flex;
    flex-direction: column;
}
.yt-history-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--line);
}
.yt-history-row:last-child { border-bottom: 0; }
.yt-history-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.yt-history-main b { font-size: 14px; font-weight: 500; }
.yt-history-main small { color: var(--text-2); font-size: 12px; }
.yt-history-status {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 10px;
    white-space: nowrap;
}
.yt-history-status.ok {
    background: rgba(46, 204, 113, .12);
    color: #5ad48e;
}
.yt-history-status.wait {
    background: rgba(240, 170, 0, .12);
    color: #ffc95c;
}
.yt-history-amount { font-size: 14px; white-space: nowrap; }
.yt-history-empty {
    color: var(--text-2);
    font-size: 14px;
    margin: 0;
}

@media (max-width: 600px) {
    .yt-balance { flex-wrap: wrap; }
    .yt-balance .yt-btn { width: 100%; justify-content: center; }
    .yt-user-chip span { display: none; }
    .yt-user-chip { padding: 0 10px; }
}

/* Маскот в аватаре кабинета */
.yt-account-avatar img { border-radius: 50%; }

.yt-page-title { margin-bottom: 18px; }
.alert-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(62, 166, 255, .1);
    margin-bottom: 18px;
    font-size: 13.5px;
    color: var(--text);
}
