/* ─────────────────────────────────────────────────────────
   CRM Видеотека — стили
   Тёмная тема, цветные градиенты ролей, YouTube-подобный watch
   ───────────────────────────────────────────────────────── */

:root {
    --bg: #0d0e11;
    --bg-elev: #16181d;
    --bg-elev-2: #1c1f25;
    --border: #25282f;
    --border-strong: #3a3e48;
    --text: #e6e8eb;
    --text-dim: #b8bdc7;
    --text-muted: #9aa0aa;
    --text-faint: #6e747f;
    --accent: #4ea1ff;
    --accent-hover: #6db2ff;
    --success: #2ec76b;
    --danger: #ff5656;

    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);

    --font: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
}

/* ─── Reset / base ─── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    background-image:
        radial-gradient(circle at 0% 0%, rgba(78, 161, 255, 0.05), transparent 40%),
        radial-gradient(circle at 100% 0%, rgba(124, 92, 255, 0.04), transparent 40%);
    background-attachment: fixed;
}
a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
input, button, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: rgba(78, 161, 255, 0.35); }

/* Кастомный скролл */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #2a2d35; border-radius: 5px; }
*::-webkit-scrollbar-thumb:hover { background: #3a3e48; }

/* ─── Topbar ─── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(13, 14, 17, 0.85);
    backdrop-filter: saturate(140%) blur(12px);
    -webkit-backdrop-filter: saturate(140%) blur(12px);
    border-bottom: 1px solid var(--border);
}
.topbar-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 12px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.01em;
    text-decoration: none;
}
.brand:hover { color: #fff; text-decoration: none; }
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, #4ea1ff, #1f86e0);
    color: #fff;
    box-shadow: 0 4px 14px rgba(78, 161, 255, 0.35);
}
.brand-mark svg { width: 16px; height: 16px; }
.brand-mark.large {
    width: 56px; height: 56px;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(78, 161, 255, 0.4);
}
.brand-mark.large svg { width: 30px; height: 30px; }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 999px;
}
.user-avatar {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c5cff, #4ea1ff);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}
.user-name { color: var(--text); font-size: 14px; font-weight: 500; }
.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 14px;
    padding: 7px 12px;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}
.btn-link:hover { background: var(--bg-elev-2); color: #fff; text-decoration: none; }

/* ─── Container ─── */
.container { max-width: 1440px; margin: 0 auto; padding: 36px 32px 64px; }
.container-watch { max-width: 1640px; padding-top: 20px; }

/* ─── Crumbs ─── */
.crumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 18px;
}
.crumbs a {
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
.crumbs a:hover { background: var(--bg-elev); color: var(--text); text-decoration: none; }
.crumbs .sep { color: var(--text-faint); }
.crumbs .current { color: var(--text); padding: 4px 8px; }

/* ─── Login ─── */
.page-login { background-image: radial-gradient(circle at 50% 30%, rgba(78, 161, 255, 0.12), transparent 50%); }
.login-wrapper {
    min-height: calc(100vh - 80px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}
.login-card {
    width: 100%;
    max-width: 420px;
}
.login-brand {
    text-align: center;
    margin-bottom: 28px;
}
.login-brand .brand-mark { margin: 0 auto 16px; }
.login-brand h1 { font-size: 24px; margin-bottom: 6px; }
.login-brand .subtitle { color: var(--text-muted); font-size: 14px; margin: 0; }

.login-form {
    background: var(--bg-elev);
    padding: 28px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.field input {
    width: 100%;
    padding: 11px 13px;
    background: var(--bg);
    border: 1px solid #2d3038;
    border-radius: 8px;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.field input::placeholder { color: var(--text-faint); }
.field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(78, 161, 255, 0.18);
}
.btn-primary {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--accent), #1f86e0);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: filter 0.15s, transform 0.05s;
    box-shadow: 0 6px 18px rgba(78, 161, 255, 0.35);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }
.error-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 86, 86, 0.1);
    border: 1px solid rgba(255, 86, 86, 0.4);
    color: #ff8888;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
}

/* ─── Hero (home) ─── */
.hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 36px;
}
.hero-eyebrow {
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 8px;
}
.hero h1 {
    font-size: clamp(28px, 4vw, 38px);
    margin: 0 0 8px;
    background: linear-gradient(180deg, #fff, #c5c9d2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero-sub { color: var(--text-muted); font-size: 16px; margin: 0; max-width: 56ch; }
.hero-stats {
    display: flex;
    gap: 12px;
}
.stat {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 18px;
    text-align: center;
    min-width: 110px;
}
.stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ─── Section heading ─── */
.section-head { margin-bottom: 18px; }
.section-head h2 { font-size: 20px; margin: 0 0 4px; }
.section-head p { color: var(--text-muted); font-size: 14px; margin: 0; }
.roles-section + .roles-section { margin-top: 48px; }

/* ─── Roles grid ─── */
.roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 18px;
}
.role-card {
    --c1: var(--accent);
    --c2: #1f86e0;
    position: relative;
    padding: 24px;
    border-radius: var(--radius-lg);
    background: var(--bg-elev);
    border: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
    transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0;
    isolation: isolate;
    min-height: 260px;
}
.role-card::before {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--c1) 55%, transparent), transparent 60%);
    -webkit-mask: linear-gradient(#fff, #fff) content-box, linear-gradient(#fff, #fff);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.18s;
    pointer-events: none;
    z-index: 1;
}
.role-card::after {
    content: "";
    position: absolute;
    top: -40%;
    right: -20%;
    width: 70%;
    height: 70%;
    background: radial-gradient(circle, color-mix(in srgb, var(--c1) 25%, transparent), transparent 70%);
    pointer-events: none;
    z-index: 0;
    opacity: 0.55;
    transition: opacity 0.18s, transform 0.4s;
}
.role-card > * { position: relative; z-index: 2; }
.role-card:hover {
    transform: translateY(-3px);
    border-color: transparent;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45),
                0 0 0 1px color-mix(in srgb, var(--c1) 60%, transparent);
    text-decoration: none;
}
.role-card:hover::before { opacity: 1; }
.role-card:hover::after { opacity: 0.85; transform: translate(-6%, 6%); }

.role-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--c1), var(--c2));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    margin-bottom: 18px;
    box-shadow: 0 10px 24px color-mix(in srgb, var(--c1) 35%, transparent);
}
.role-icon svg { width: 28px; height: 28px; }
.role-name { font-size: 19px; margin-bottom: 4px; }
.role-tagline {
    color: var(--c1);
    font-size: 13px;
    font-weight: 500;
    margin: 0 0 14px;
}
.role-description {
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 22px;
    flex: 1;
}
.role-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.role-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    font-size: 13px;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 999px;
    color: var(--text);
    font-size: 12.5px;
    font-weight: 500;
}
.chip.chip-empty { color: var(--text-faint); }
.chip.chip-progress {
    background: rgba(46, 199, 107, 0.1);
    border-color: rgba(46, 199, 107, 0.35);
    color: #6fdfa1;
}
.chip .dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--success);
}
.role-arrow {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s, transform 0.18s;
    flex-shrink: 0;
}
.role-card:hover .role-arrow {
    background: var(--c1);
    color: #fff;
    transform: translateX(2px);
}

.role-card-compact {
    min-height: 0;
    padding: 18px;
}
.role-card-compact .role-icon { width: 44px; height: 44px; border-radius: 12px; margin-bottom: 12px; }
.role-card-compact .role-icon svg { width: 22px; height: 22px; }
.role-card-compact .role-name { font-size: 16px; margin-bottom: 12px; }

/* ─── Role page header ─── */
.role-header {
    --c1: var(--accent);
    --c2: #1f86e0;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 24px;
    align-items: center;
    padding: 28px 32px;
    border-radius: var(--radius-xl);
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--c1) 18%, transparent), color-mix(in srgb, var(--c2) 6%, transparent)),
        var(--bg-elev);
    border: 1px solid var(--border);
    margin-bottom: 32px;
    position: relative;
    overflow: hidden;
}
.role-header::after {
    content: "";
    position: absolute;
    top: -50%;
    right: -10%;
    width: 50%;
    height: 200%;
    background: radial-gradient(circle, color-mix(in srgb, var(--c1) 20%, transparent), transparent 70%);
    pointer-events: none;
}
.role-header > * { position: relative; }
.role-header-icon {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--c1), var(--c2));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 14px 30px color-mix(in srgb, var(--c1) 40%, transparent);
    flex-shrink: 0;
}
.role-header-icon svg { width: 36px; height: 36px; }
.role-header-tagline {
    color: var(--c1);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin: 0 0 6px;
}
.role-header h1 { font-size: 28px; margin: 0 0 6px; }
.role-header-desc { color: var(--text-dim); font-size: 14px; margin: 0; max-width: 60ch; }
.role-header-stats {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}
.stat-pill {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: 12px;
    text-align: center;
    min-width: 88px;
}
.stat-pill strong {
    display: block;
    font-size: 22px;
    line-height: 1.1;
    font-weight: 700;
}
.stat-pill span {
    color: var(--text-muted);
    font-size: 12px;
}
.stat-pill-done strong { color: #6fdfa1; }

@media (max-width: 720px) {
    .role-header {
        grid-template-columns: 1fr;
        text-align: left;
        padding: 22px;
    }
    .role-header-stats { justify-self: stretch; }
}

/* ─── Empty state ─── */
.empty-state {
    text-align: center;
    padding: 64px 20px;
    color: var(--text-muted);
    background: var(--bg-elev);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
}
.empty-state h3 { font-size: 18px; color: var(--text); margin-bottom: 6px; }
.empty-state p { margin: 0; font-size: 14px; }
.empty-state p + p { margin-top: 8px; }
.empty-state .empty-icon {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: var(--bg-elev-2);
    color: var(--text-faint);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.empty-state code {
    background: var(--bg-elev-2);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12.5px;
    color: var(--accent);
}
.empty-state .back { margin-top: 16px; }

/* ─── Video grid (роль) ─── */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 22px;
}
.video-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
    color: inherit;
    text-decoration: none;
    display: flex;
    flex-direction: column;
}
.video-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}
.thumb-wrap {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #0a0b0d;
    overflow: hidden;
}
.thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s;
}
.video-card:hover .thumb { transform: scale(1.04); }
.thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2d3038;
    background: #14161a;
    width: 100%; height: 100%;
}
.thumb-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    opacity: 0;
    transition: opacity 0.18s;
}
.thumb-play svg {
    width: 56px; height: 56px;
    color: #fff;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
    transform: scale(0.85);
    transition: transform 0.18s;
}
.video-card:hover .thumb-play { opacity: 1; }
.video-card:hover .thumb-play svg { transform: scale(1); }
.duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}
.progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
}
.progress-bar > div {
    height: 100%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}
.badge {
    position: absolute;
    top: 8px;
    left: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}
.badge-done { background: var(--success); color: #042e15; }

.card-body {
    padding: 14px 16px 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    flex: 1;
}
.card-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--bg-elev-2);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    font-variant-numeric: tabular-nums;
}
.card-text { flex: 1; min-width: 0; }
.card-body h3 {
    font-size: 15px;
    margin-bottom: 4px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card-body p {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ─── Watch layout ─── */
.watch-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 28px;
    align-items: start;
}
@media (max-width: 1100px) {
    .watch-layout { grid-template-columns: 1fr; }
}

.video-meta {
    margin-top: 18px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
}
.video-title { font-size: 22px; margin-bottom: 12px; line-height: 1.3; }

.video-info-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.role-tag {
    --c1: var(--accent);
    --c2: #1f86e0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 6px;
    background: color-mix(in srgb, var(--c1) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--c1) 35%, transparent);
    border-radius: 999px;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s;
}
.role-tag:hover {
    background: color-mix(in srgb, var(--c1) 22%, transparent);
    text-decoration: none;
    color: var(--text);
}
.role-tag-icon {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--c1), var(--c2));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}
.role-tag-icon svg { width: 13px; height: 13px; }
.meta-dot { color: var(--text-faint); }
.video-duration { color: var(--text-muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.actions { margin-left: auto; display: flex; gap: 8px; }
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
}
.action-btn:hover {
    background: var(--border);
    border-color: var(--border-strong);
    color: var(--text);
    text-decoration: none;
}
.action-btn.action-primary {
    background: linear-gradient(135deg, var(--accent), #1f86e0);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 14px rgba(78, 161, 255, 0.3);
}
.action-btn.action-primary:hover { filter: brightness(1.08); color: #fff; }
@media (max-width: 580px) {
    .action-label { display: none; }
}

.video-description {
    color: var(--text-dim);
    font-size: 14px;
    white-space: pre-wrap;
    line-height: 1.6;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ─── Playlist (YouTube-style) ─── */
.playlist {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: sticky;
    top: 80px;
}
.playlist-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}
.playlist-head h3 { font-size: 14px; margin: 0; color: var(--text); }
.playlist-count {
    background: var(--bg-elev-2);
    color: var(--text-muted);
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 500;
}
.playlist-list {
    list-style: none;
    padding: 6px;
    margin: 0;
    max-height: 720px;
    overflow-y: auto;
}
.playlist-list li { margin-bottom: 2px; }
.playlist-list li a {
    display: flex;
    gap: 10px;
    padding: 6px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    transition: background 0.12s;
}
.playlist-list li a:hover { background: var(--bg-elev-2); text-decoration: none; }
.playlist-list li.active a {
    background: linear-gradient(90deg, rgba(78, 161, 255, 0.18), rgba(78, 161, 255, 0.05));
    box-shadow: inset 3px 0 0 var(--accent);
}
.pl-thumb {
    position: relative;
    width: 130px;
    aspect-ratio: 16 / 9;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: #0a0b0d;
}
.pl-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.pl-thumb-placeholder {
    width: 100%; height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2d3038;
}
.pl-index {
    position: absolute;
    top: 4px; left: 4px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    width: 20px; height: 20px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pl-now {
    position: absolute;
    top: 4px; left: 4px;
    background: var(--accent);
    color: #042e6b;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 3px;
}
.pl-now svg { width: 11px; height: 11px; }
.pl-duration {
    position: absolute;
    bottom: 4px; right: 4px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}
.pl-done {
    position: absolute;
    top: 4px; right: 4px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--success);
    color: #042e15;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pl-progress {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.15);
}
.pl-progress > div {
    height: 100%;
    background: var(--accent);
}

.pl-meta {
    flex: 1;
    min-width: 0;
    padding: 2px 4px 2px 0;
}
.pl-title {
    font-size: 13.5px;
    line-height: 1.35;
    color: var(--text);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-weight: 500;
}
.pl-sub { color: var(--text-muted); font-size: 11.5px; }
.playlist-list li.active .pl-title { color: var(--accent); }

/* ─── Toast ─── */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translate(-50%, 12px);
    background: var(--bg-elev);
    border: 1px solid var(--border-strong);
    color: var(--text);
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
}
.toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ─── Player ─── */
.player {
    position: relative;
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    aspect-ratio: 16 / 9;
    box-shadow: var(--shadow-md);
}
.player video {
    width: 100%;
    height: 100%;
    display: block;
    cursor: pointer;
}
.player-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    cursor: pointer;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}
.play-circle {
    width: 80px; height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: transform 0.18s, background 0.15s;
}
.play-circle svg { width: 32px; height: 32px; transform: translateX(2px); }
.player.paused .player-overlay { opacity: 1; pointer-events: auto; }
.player.paused:hover .play-circle { transform: scale(1.06); background: rgba(255, 255, 255, 0.22); }
.player.playing .player-overlay { opacity: 0; }

.crm-controls {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0) 100%);
    padding: 36px 14px 8px;
    opacity: 0;
    transition: opacity 0.2s;
}
.player:hover .crm-controls,
.player.paused .crm-controls,
.player.controls-visible .crm-controls { opacity: 1; }

.crm-progress {
    position: relative;
    height: 14px;
    cursor: pointer;
    margin-bottom: 4px;
}
.crm-progress-track,
.crm-progress-buffered,
.crm-progress-played {
    position: absolute;
    top: 6px;
    left: 0;
    height: 3px;
    border-radius: 2px;
    transition: height 0.1s;
}
.crm-progress-track { width: 100%; background: rgba(255,255,255,0.25); }
.crm-progress-buffered { background: rgba(255,255,255,0.45); }
.crm-progress-played { background: var(--accent); }
.crm-progress:hover .crm-progress-track,
.crm-progress:hover .crm-progress-buffered,
.crm-progress:hover .crm-progress-played { height: 5px; top: 5px; }
.crm-progress-handle {
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    background: var(--accent);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.1s;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}
.crm-progress:hover .crm-progress-handle { transform: translate(-50%, -50%) scale(1); }

.crm-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #fff;
}
.crm-btn {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.12s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}
.crm-btn:hover { background: rgba(255,255,255,0.18); }
.crm-btn svg { width: 18px; height: 18px; fill: currentColor; }
.crm-time {
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    color: rgba(255,255,255,0.85);
    margin-left: 6px;
}
.crm-spacer { flex: 1; }
.crm-volume { display: flex; align-items: center; gap: 4px; }
.crm-vol-slider {
    width: 0;
    overflow: hidden;
    transition: width 0.18s;
    -webkit-appearance: none;
    appearance: none;
    height: 3px;
    background: rgba(255,255,255,0.4);
    border-radius: 2px;
    outline: none;
}
.crm-volume:hover .crm-vol-slider { width: 70px; }
.crm-vol-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 11px; height: 11px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
}
.crm-vol-slider::-moz-range-thumb {
    width: 11px; height: 11px;
    background: #fff;
    border-radius: 50%;
    border: none;
    cursor: pointer;
}
.crm-speed {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 6px;
    color: #fff;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}
.crm-speed:hover { background: rgba(255,255,255,0.15); }
.crm-speed option { background: var(--bg-elev); color: #fff; }

/* fullscreen styling */
.player:fullscreen { aspect-ratio: auto; width: 100%; height: 100%; border-radius: 0; }
.player:fullscreen video { width: 100%; height: 100%; }

/* ─── Mobile tweaks ─── */
@media (max-width: 720px) {
    .container { padding: 24px 16px 56px; }
    .topbar-inner { padding: 10px 16px; }
    .user-name { display: none; }
    .roles-grid { grid-template-columns: 1fr; gap: 14px; }
    .role-card { min-height: 0; }
    .video-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
    .video-grid .card-body { padding: 12px; }
    .pl-thumb { width: 110px; }
    .playlist { position: static; }
}
@media (max-width: 480px) {
    .video-grid { grid-template-columns: 1fr; }
    .hero { gap: 16px; }
}
