:root {
    --bg: #0f0f0f;
    --bg2: #212121;
    --bg3: #272727;
    --hover: #3f3f3f;
    --text: #f1f1f1;
    --muted: #aaa;
    --accent: #ff0033;
    --link: #3ea6ff;
    --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Roboto", "Segoe UI", Arial, sans-serif;
    font-size: 14px;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1:focus { outline: none; }
code { background: var(--bg3); padding: 1px 5px; border-radius: 4px; }

/* ---------- Barre du haut ---------- */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 24px;
    height: 56px; padding: 0 16px;
    background: var(--bg);
}
.logo { display: flex; align-items: center; gap: 4px; font-size: 20px; font-weight: 700; letter-spacing: -1px; }
.search { flex: 1; max-width: 720px; margin: 0 auto; display: flex; }
.search input {
    flex: 1; height: 40px; padding: 0 16px;
    background: #121212; color: var(--text);
    border: 1px solid #303030; border-right: none;
    border-radius: 40px 0 0 40px; font-size: 16px; outline: none;
}
.search input:focus { border-color: #1c62b9; }
.search button {
    width: 64px; height: 40px; border: 1px solid #303030;
    background: var(--bg2); border-radius: 0 40px 40px 0; cursor: pointer;
}
.toplinks { display: flex; gap: 4px; }
.toplinks a { padding: 8px 14px; border-radius: 20px; }
.toplinks a:hover { background: var(--bg3); }
.toplinks a.active { background: var(--text); color: var(--bg); }

.shell { display: flex; align-items: flex-start; }
.content { flex: 1; min-width: 0; padding: 16px 24px 48px; max-width: 2200px; margin: 0 auto; }

/* ---------- Menu latéral ---------- */
.menu-toggle { display: none; }
.menu-btn { display: flex; padding: 8px; border-radius: 50%; cursor: pointer; }
.menu-btn:hover { background: var(--bg3); }
.sidebar {
    position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto;
    width: 240px; flex-shrink: 0; padding: 12px; scrollbar-width: thin;
}
.menu-toggle:checked ~ .shell .sidebar { display: none; }
@media (max-width: 900px) {
    .sidebar { display: none; }
    .menu-toggle:checked ~ .shell .sidebar { display: block; position: fixed; left: 0; z-index: 20; background: var(--bg); box-shadow: 4px 0 16px rgba(0,0,0,.5); }
}
.side-link {
    display: flex; align-items: center; gap: 20px; height: 40px; padding: 0 12px;
    border-radius: 10px; white-space: nowrap; overflow: hidden;
}
.side-link:hover { background: var(--bg3); }
.side-link.active { background: var(--bg3); font-weight: 600; }
.side-link .ico { width: 24px; text-align: center; }
.side-link.channel { gap: 16px; height: 40px; }
.side-link.channel img, .mini-avatar {
    width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.mini-avatar { background: #5c6bc0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.side-link .name { overflow: hidden; text-overflow: ellipsis; }
.side-sep { border-top: 1px solid #3a3a3a; margin: 12px 0; }
.side-head { padding: 6px 12px; font-size: 16px; font-weight: 600; display: flex; flex-direction: column; gap: 8px; }
.side-filter {
    height: 30px; padding: 0 10px; background: #121212; color: var(--text); font-weight: 400;
    border: 1px solid #303030; border-radius: 15px; outline: none; font-size: 13px;
}
.side-empty { color: var(--muted); font-size: 13px; padding: 0 12px; line-height: 1.5; }

/* ---------- Abonnement / onglets de chaîne ---------- */
.pill.subscribe { background: var(--text); color: var(--bg); }
.pill.subscribe:hover { background: #d9d9d9; }
.avatar-big.placeholder { display: flex; align-items: center; justify-content: center; font-size: 56px; font-weight: 600; background: #5c6bc0; }
.channel-info { min-width: 0; }
.channel-info .pills { margin-top: 12px; }
.channel-toolbar {
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px;
    border-bottom: 1px solid #3a3a3a; margin-bottom: 24px;
}
.tabs { display: flex; gap: 8px; }
.tabs a { padding: 12px 16px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--text); }
.chips { display: flex; gap: 8px; padding: 8px 0; }
.chip { padding: 6px 12px; border-radius: 8px; background: var(--bg3); font-weight: 500; }
.chip:hover { background: var(--hover); }
.chip.active { background: var(--text); color: var(--bg); }
.more-wrap { display: flex; justify-content: center; margin: 32px 0; }

/* ---------- Grilles de vidéos ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 40px 16px;
}
.card { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.thumb {
    position: relative; display: block; aspect-ratio: 16 / 9;
    border-radius: var(--radius); overflow: hidden; background: var(--bg3);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.card:hover .thumb img { transform: scale(1.02); }
.duration {
    position: absolute; right: 6px; bottom: 6px;
    background: rgba(0,0,0,.8); padding: 1px 5px; border-radius: 4px;
    font-size: 12px; font-weight: 500;
}
.duration.live { background: #cc0000; }
.badge {
    position: absolute; left: 6px; top: 6px;
    background: rgba(0,0,0,.8); padding: 2px 6px; border-radius: 4px; font-size: 12px; font-weight: 500;
}
.badge.ok { background: #1e7d32; }
.badge.short { left: auto; right: 6px; background: var(--accent); }
.meta h3 {
    margin: 0 0 4px; font-size: 16px; font-weight: 500; line-height: 22px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sub { color: var(--muted); font-size: 13px; line-height: 19px; }
a.sub { display: block; }
a.sub:hover { color: var(--text); }

.channel-card { align-items: center; justify-content: center; text-align: center; padding: 16px; }
.avatar-big { width: 136px; height: 136px; border-radius: 50%; overflow: hidden; background: var(--bg3); object-fit: cover; flex-shrink: 0; }
.avatar-big img { width: 100%; height: 100%; object-fit: cover; }

.section-title { font-size: 20px; margin: 24px 0 16px; display: flex; align-items: center; gap: 16px; }
.section-title .more { font-size: 14px; color: var(--link); font-weight: 500; }

.hero { max-width: 760px; margin: 48px auto 24px; text-align: center; }
.hero h1 { font-size: 32px; }
.hero p { color: var(--muted); font-size: 16px; line-height: 1.6; }
.hero a { color: var(--link); }
.hero .hint { font-size: 13px; }

.empty { color: var(--muted); text-align: center; margin: 48px 0; font-size: 16px; }
.empty a { color: var(--link); }
.error-box { background: #3b1111; border: 1px solid #7a2020; padding: 16px; border-radius: var(--radius); margin: 24px 0; }

/* ---------- Chargement ---------- */
.loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 64px; color: var(--muted); }
.spinner {
    width: 32px; height: 32px; border-radius: 50%;
    border: 3px solid rgba(255,255,255,.2); border-top-color: var(--text);
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Page chaîne ---------- */
.channel-header { display: flex; gap: 24px; align-items: center; margin: 8px 0 32px; }
.channel-header h1 { margin: 0 0 8px; font-size: 36px; }
.channel-header .sub a { color: var(--link); }
.channel-desc { color: var(--muted); max-width: 900px; white-space: pre-line; max-height: 4.5em; overflow: hidden; }

/* ---------- Page lecture ---------- */
.watch { display: flex; gap: 24px; max-width: 1800px; margin: 0 auto; }
.watch-main { flex: 1; min-width: 0; }
.watch-side { width: 402px; flex-shrink: 0; }
@media (max-width: 1100px) { .watch { flex-direction: column; } .watch-side { width: auto; } }

.player-wrap {
    position: relative; width: 100%; aspect-ratio: 16 / 9; max-height: calc(100vh - 170px);
    background: #000; border-radius: var(--radius); overflow: hidden;
}
.player-wrap video { width: 100%; height: 100%; display: block; background: #000; }
.player-wrap.downloading img { width: 100%; height: 100%; object-fit: cover; filter: blur(6px) brightness(.4); transform: scale(1.05); }
.dl-overlay {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 24px;
}
.dl-status { font-size: 18px; font-weight: 500; }
.dl-status.error { color: #ff8a80; max-width: 80%; }
.dl-detail { color: #ddd; font-variant-numeric: tabular-nums; }
.dl-buttons { display: flex; gap: 8px; }
.progress { width: min(480px, 80%); height: 6px; background: rgba(255,255,255,.2); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .25s; }

.heatmap { width: 100%; height: 28px; display: block; margin-top: 4px; }
.heatmap path { fill: rgba(255,255,255,.18); }

.video-title { font-size: 20px; font-weight: 600; margin: 12px 0 8px; line-height: 28px; }
.video-actions { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.channel-line { display: flex; align-items: center; gap: 12px; }
.avatar {
    width: 40px; height: 40px; border-radius: 50%; background: #5c6bc0; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 18px; object-fit: cover;
}
.channel-name { font-size: 16px; font-weight: 600; }
.verified { color: var(--muted); font-size: 12px; margin-left: 4px; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
    display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 16px;
    background: var(--bg3); border: none; border-radius: 18px; cursor: pointer; font-weight: 500; white-space: nowrap;
}
.pill:hover { background: var(--hover); }
.pill:disabled { opacity: .4; cursor: default; }
.pill.danger { background: #b3261e; }
.pill.danger:hover { background: #d32f2f; }

.description { background: var(--bg3); border-radius: var(--radius); padding: 12px; margin-top: 12px; }
.description:not(.open) .desc-text { max-height: 3.9em; overflow: hidden; }
.desc-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.desc-text { white-space: pre-wrap; line-height: 1.4; overflow-wrap: anywhere; }
.desc-text a, .description .tag { color: var(--link); }
.link { background: none; border: none; padding: 8px 0 0; cursor: pointer; font-weight: 600; }
.details { margin-top: 16px; border-collapse: collapse; width: 100%; }
.details th, .details td { text-align: left; padding: 6px 8px; border-top: 1px solid #3a3a3a; vertical-align: top; }
.details th { color: var(--muted); font-weight: 500; width: 190px; }

.comments h2 { font-size: 20px; margin: 24px 0; }
.comments h2 small { color: var(--muted); font-weight: 400; font-size: 14px; }
.comment { display: flex; gap: 16px; margin-bottom: 20px; }
.comment.reply { margin: 12px 0 0; }
.comment.reply .avatar { width: 24px; height: 24px; font-size: 12px; }
.comment-body { flex: 1; min-width: 0; }
.comment-head { display: flex; gap: 6px; align-items: baseline; margin-bottom: 2px; }
.author { font-weight: 500; font-size: 13px; }
.author.uploader { background: #555; padding: 1px 8px; border-radius: 10px; }
.comment-text { white-space: pre-wrap; line-height: 20px; overflow-wrap: anywhere; }
.comment-foot { display: flex; gap: 12px; color: var(--muted); font-size: 12px; margin-top: 6px; }
.pinned { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.replies-toggle { color: var(--link); padding-top: 6px; }

.panel { background: var(--bg2); border-radius: var(--radius); padding: 12px; margin-bottom: 16px; }
.panel h3 { margin: 4px 4px 12px; font-size: 16px; }
.chapter {
    display: flex; gap: 12px; width: 100%; text-align: left; background: none; border: none;
    padding: 8px; border-radius: 8px; cursor: pointer;
}
.chapter:hover { background: var(--bg3); }
.chapter .time { color: var(--link); font-variant-numeric: tabular-nums; min-width: 48px; }
.side-item { display: flex; gap: 8px; margin-bottom: 8px; padding: 4px; border-radius: 8px; }
.side-item:hover { background: var(--bg3); }
.thumb.small { width: 168px; flex-shrink: 0; border-radius: 8px; }
.side-title {
    font-weight: 500; line-height: 20px; margin-bottom: 4px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---------- Bibliothèque ---------- */
.library-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 16px; margin-bottom: 16px; }
.library-head h1 { margin: 0 0 4px; }
.library-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.library-tools input, .library-tools select {
    height: 36px; padding: 0 12px; background: #121212; color: var(--text);
    border: 1px solid #303030; border-radius: 18px; outline: none;
}
.library-tools input { width: 260px; }
.lib-item { position: relative; border-radius: var(--radius); }
.lib-item.selected { outline: 3px solid var(--link); outline-offset: 4px; }
.select-overlay { position: absolute; z-index: 2; inset: 0 0 auto 0; aspect-ratio: 16 / 9; cursor: pointer; display: block; }
.select-overlay input { position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; cursor: pointer; }
.lib-extra { display: flex; align-items: center; gap: 4px; }
.icon-btn { margin-left: auto; background: none; border: none; cursor: pointer; padding: 4px 8px; border-radius: 50%; font-size: 15px; }
.icon-btn:hover { background: var(--bg3); }

.jobs { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.job { display: flex; align-items: center; gap: 12px; background: var(--bg2); padding: 8px; border-radius: var(--radius); }
.job img { width: 120px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; display: block; }
.job-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.job-info .progress { width: 100%; }
.job.failed .sub { color: #ff8a80; }
.job.completed .sub { color: #81c784; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--bg2); border-radius: var(--radius); padding: 24px; width: min(560px, 92vw); max-height: 80vh; overflow: auto; }
.modal h2 { margin-top: 0; }
.delete-list { padding-left: 18px; line-height: 1.6; }
.modal-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- Erreurs Blazor ---------- */
#blazor-error-ui {
    background: #5c1a1a; color: #fff; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2);
    display: none; left: 0; padding: .6rem 1.25rem .7rem 1.25rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
#blazor-error-ui a { color: var(--link); }

/* ---------- Profils ---------- */
.profile-btn { display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 20px; font-weight: 500; }
.profile-btn:hover { background: var(--bg3); }
.who-mini { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.who { text-align: center; margin-top: 10vh; }
.who h1 { font-size: 44px; font-weight: 500; margin-bottom: 40px; }
.who-list { display: flex; justify-content: center; gap: 40px; flex-wrap: wrap; }
.who-item { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 180px; }
.who-avatar {
    width: 150px; height: 150px; border-radius: 16px; display: flex; align-items: center; justify-content: center;
    font-size: 72px; font-weight: 700; border: 3px solid transparent; transition: border-color .15s, transform .15s;
}
.who-item:hover .who-avatar { border-color: var(--text); transform: scale(1.04); }
.who-item.current .who-avatar { border-color: var(--link); }
.who-name { font-size: 20px; color: var(--muted); }
.who-item:hover .who-name { color: var(--text); }

/* ---------- Paramètres ---------- */
.settings { max-width: 900px; }
.settings .panel { padding: 20px 24px; margin-bottom: 20px; }
.settings h2 { margin: 0 0 8px; font-size: 20px; }
.settings h3 { margin: 20px 0 8px; font-size: 15px; }
.settings p.sub { line-height: 1.6; }
.settings a { color: var(--link); }
.settings .status { margin: 12px 0; padding: 10px 14px; border-radius: 8px; background: var(--bg3); display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.settings .status.ok { background: #1b3a1f; }
.steps { line-height: 1.8; color: var(--muted); padding-left: 20px; }
.steps b { color: var(--text); }
.settings .row { display: flex; gap: 8px; flex-wrap: wrap; }
.settings select, .settings .row input {
    height: 36px; padding: 0 12px; background: #121212; color: var(--text); border: 1px solid #303030; border-radius: 18px; outline: none;
}
.settings .row input { flex: 1; min-width: 220px; }
.settings .message { margin-top: 14px; padding: 10px 14px; border-radius: 8px; }
.settings .message.ok { background: #1b3a1f; }
.settings .message.error { background: #3b1111; }
.side-empty a { color: var(--link); }
.settings a.pill { color: inherit; }
