:root {
  --chrome: #1f222b;
  --chrome-2: #2b2f3a;
  --bg: #101115;
  --card: #181a20;
  --text: #e8e9ee;
  --muted: #8d93a5;
  --faint: #6b7183;
  --accent: #4f8cff;
  --danger: #ff5a5f;
  --imdb: #f5c518;
  --side: 56px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.4em; margin: 0; }

.btn { border: 0; border-radius: 8px; padding: 8px 16px; background: var(--chrome-2); display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: var(--text); color: var(--bg); font-weight: 600; }
.btn.ghost { background: transparent; border: 1px solid var(--chrome-2); }
.icon-btn { background: transparent; border: 0; width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; font-size: 20px; }
.icon-btn:hover { background: var(--chrome-2); }

/* ---- Connexion ---- */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--chrome); border-radius: 12px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.login-card input { background: var(--chrome-2); border: 0; border-radius: 8px; padding: 10px 12px; }
.brand-lg { font-size: 24px; font-weight: 600; margin-bottom: 6px; }
.desktop-server { font-size: 12px; margin-top: -8px; }
.play-loading { position: fixed; inset: 0; z-index: 60; background: rgb(10 11 14 / 92%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 20px; }
.play-loading .pl-title { font-size: 20px; font-weight: 600; max-width: 80vw; }
.play-loading .btn { margin-top: 12px; }
.spinner { width: 48px; height: 48px; border-radius: 50%; border: 4px solid var(--chrome-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.desktop-server a { color: var(--accent); }

/* ---- Cadre : bande unie en L (barre + volet) ---- */
.shell { --sub: 0px; display: grid; grid-template-columns: var(--side) var(--sub) minmax(0, 1fr); grid-template-rows: 56px minmax(0, 1fr); height: 100vh; }
.shell.has-sub { --sub: 210px; }
.corner { grid-column: 1; grid-row: 1; }
.topbar { grid-column: 2 / 4; grid-row: 1; }
.sidebar { grid-column: 1; grid-row: 2; }
.subpanel { grid-column: 2; grid-row: 2; }
.main { grid-column: 3; grid-row: 2; }
.corner, .topbar, .sidebar { background: var(--chrome); }
.corner { display: grid; place-items: center; }
.corner #side-toggle { display: none; }
.logo-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 17px; }
.brand { font-weight: 600; font-size: 16px; white-space: nowrap; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 0 14px 0 4px; min-width: 0; }
.search { flex: 1; min-width: 120px; max-width: 520px; display: flex; align-items: center; gap: 8px; background: var(--chrome-2); border-radius: 8px; padding: 0 10px; color: var(--muted); }
.search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; padding: 8px 0; }
.filters { display: flex; gap: 6px; align-items: center; overflow-x: auto; scrollbar-width: none; }
.filters select { appearance: none; background: var(--chrome-2); border: 0; border-radius: 16px; padding: 5px 12px; font-size: 13px; color: #c9ccd6; cursor: pointer; }
.seg { display: flex; background: var(--chrome-2); border-radius: 16px; padding: 2px; }
.seg button { border: 0; background: transparent; border-radius: 14px; padding: 3px 9px; color: #c9ccd6; }
.seg button.on { background: var(--text); color: var(--bg); }
.user { position: relative; margin-left: auto; }
.user-menu { position: absolute; right: 0; top: 44px; background: var(--chrome-2); border-radius: 10px; padding: 6px; min-width: 200px; z-index: 40; display: flex; flex-direction: column; box-shadow: 0 8px 24px rgb(0 0 0 / 40%); }
.user-menu a, .user-menu button { background: transparent; border: 0; text-align: left; padding: 8px 10px; border-radius: 6px; display: flex; gap: 8px; align-items: center; }
.user-menu a:hover, .user-menu button:hover { background: var(--chrome); }
.user-name { padding: 6px 10px; color: var(--muted); font-size: 13px; }

/* Volet principal : réduit en icônes, s'ouvre au survol par-dessus le contenu */
.sidebar { width: var(--side); position: relative; z-index: 30; display: flex; flex-direction: column; gap: 4px; padding: 8px; overflow: hidden; transition: width .18s ease, box-shadow .18s ease; }
.sidebar a { display: flex; align-items: center; gap: 14px; padding: 8px 10px; border-radius: 8px; color: var(--muted); white-space: nowrap; }
.sidebar a i { font-size: 20px; flex: none; }
.sidebar a span { opacity: 0; transition: opacity .12s ease; }
.sidebar a:hover { color: var(--text); background: var(--chrome-2); }
.sidebar a.on { background: var(--accent); color: #fff; }
.side-sep { height: 1px; background: var(--chrome-2); margin: 6px 4px; }
@media (hover: hover) and (min-width: 761px) {
  .sidebar:hover { width: 220px; box-shadow: 12px 0 28px rgb(0 0 0 / 45%); }
  .sidebar:hover a span { opacity: 1; }
}

/* Volet complémentaire (genres, types) : même bande, séparée par un filet */
.subpanel { display: none; background: var(--chrome); border-left: 1px solid var(--chrome-2); flex-direction: column; gap: 1px; padding: 10px 8px; overflow-y: auto; }
.shell.has-sub .subpanel { display: flex; }
.subpanel .sec { font-size: 12px; color: var(--faint); padding: 4px 10px 6px; text-transform: uppercase; letter-spacing: .04em; }
.subpanel a { display: flex; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: 8px; font-size: 13px; color: var(--muted); }
.subpanel a:hover { color: var(--text); background: var(--chrome-2); }
.subpanel a.on { background: var(--accent); color: #fff; }
.subpanel a small { color: inherit; opacity: .7; }
.fav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fav.on svg { fill: currentColor; }

.main { overflow-y: auto; padding: 18px 22px 40px; }
.page-head { display: flex; align-items: baseline; gap: 10px; margin: 0 0 16px; }
.page-head h1 { font-size: 22px; font-weight: 600; margin: 0; }
.page-head .count { color: var(--muted); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin: -6px 0 16px; }
.pills button { background: var(--chrome-2); border: 0; border-radius: 16px; padding: 4px 12px; font-size: 13px; color: #c9ccd6; }
.pills button.on { background: var(--text); color: var(--bg); }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* ---- Cartes ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px 14px; }
.card { cursor: pointer; min-width: 0; }
.poster { position: relative; aspect-ratio: 2 / 3; border-radius: 8px; overflow: hidden; background: var(--card); display: grid; place-items: center; color: var(--faint); font-size: 28px; font-weight: 600; }
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card:hover .poster { outline: 2px solid var(--accent); }
.badge-imdb { position: absolute; top: 6px; left: 6px; background: var(--imdb); color: #1a1a1a; font-weight: 700; font-size: 12px; padding: 0 5px; border-radius: 4px; }
.fav { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgb(0 0 0 / 55%); color: #fff; display: grid; place-items: center; font-size: 17px; opacity: 0; transition: opacity .15s; }
.card:hover .fav, .fav.on, .tile:hover .fav { opacity: 1; }
.fav.on { color: #ff4d6d; }
.card-title { margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { color: var(--muted); font-size: 12px; }
.bar { height: 3px; background: var(--chrome-2); border-radius: 2px; overflow: hidden; margin-top: 5px; }
.bar div { height: 100%; background: var(--accent); }

.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 14px; background: var(--card); border-radius: 10px; padding: 10px; cursor: pointer; align-items: flex-start; }
.row:hover { outline: 2px solid var(--accent); }
.row .poster { width: 64px; flex: none; font-size: 18px; }
.row .fav { opacity: 1; position: static; background: transparent; color: var(--muted); }
.row .fav.on { color: #ff4d6d; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; }
.row-title span { font-weight: 400; color: var(--muted); }
.row-text { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 4px; }
.row-side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 12px; color: var(--muted); }
.row-side .badge-imdb { position: static; }

/* ---- Accueil ---- */
.hero { position: relative; border-radius: 14px; overflow: hidden; min-height: 300px; background: var(--card) center / cover no-repeat; display: flex; align-items: flex-end; margin-bottom: 26px; }
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgb(16 17 21 / 92%) 0%, rgb(16 17 21 / 55%) 50%, rgb(16 17 21 / 0%) 100%), linear-gradient(0deg, rgb(16 17 21 / 70%), transparent 50%); }
.hero-body { position: relative; padding: 28px; max-width: 560px; }
.hero h2 { font-size: 28px; margin: 4px 0 8px; }
.hero p { color: #c9ccd6; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hero .actions { display: flex; gap: 10px; margin-top: 14px; }
.section { margin-bottom: 26px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.section-head h3 { margin: 0; font-size: 17px; }
.section-head a { color: var(--muted); font-size: 13px; }
.rail { display: grid; grid-auto-flow: column; grid-auto-columns: 150px; gap: 14px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }
.rail.wide { grid-auto-columns: 240px; }
.resume .thumb { aspect-ratio: 16 / 9; border-radius: 8px; background: var(--card) center / cover; position: relative; }
.resume .thumb i { position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px; opacity: 0; background: rgb(0 0 0 / 35%); transition: opacity .15s; }
.resume:hover .thumb i { opacity: 1; }

/* ---- Direct ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tile { position: relative; background: var(--card); border-radius: 10px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center; }
.tile:hover { outline: 2px solid var(--accent); }
.tile .logo { width: 100%; aspect-ratio: 16 / 9; display: grid; place-items: center; background: var(--chrome); border-radius: 6px; font-weight: 600; color: var(--faint); overflow: hidden; }
.tile .logo img { max-width: 80%; max-height: 80%; object-fit: contain; }
.tile .name { font-size: 13px; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Direct : badges de qualité et mode liste avec guide */
.qbadges { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.qbadge { font-size: 10px; font-weight: 700; letter-spacing: .03em; padding: 1px 5px; border-radius: 4px; background: var(--chrome-2); color: #c9ccd6; }
.live-list { display: flex; flex-direction: column; gap: 6px; }
.live-row { display: grid; grid-template-columns: 96px minmax(140px, 220px) minmax(0, 1fr) minmax(0, 260px) 36px; gap: 14px; align-items: center; background: var(--card); border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.live-row:hover { outline: 2px solid var(--accent); }
.live-row .logo { aspect-ratio: 16 / 9; display: grid; place-items: center; background: var(--chrome); border-radius: 6px; font-weight: 600; color: var(--faint); overflow: hidden; }
.live-row .logo img { max-width: 80%; max-height: 80%; object-fit: contain; }
.live-row .ch-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-row .ch-name .qbadges { justify-content: flex-start; margin-top: 4px; }
.epg-now, .epg-next { min-width: 0; font-size: 13px; }
.epg-now .t, .epg-next .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.epg-now .t { color: var(--text); }
.epg-next { color: var(--muted); }
.epg-time { font-size: 12px; color: var(--muted); }
.live-row .fav { position: static; opacity: 1; background: transparent; color: var(--muted); }
.live-row .fav.on { color: #ff4d6d; }
.player-variant { background: var(--chrome-2); color: var(--text); border: 0; border-radius: 8px; padding: 6px 10px; }
.cast a { display: block; }
.cast a:hover .ph { outline: 2px solid var(--accent); }
.people a { color: var(--text); text-decoration: underline; text-decoration-color: var(--faint); }
.person-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.person-head .ph { width: 72px; height: 72px; border-radius: 50%; background: var(--card) center / cover; display: grid; place-items: center; color: var(--faint); font-size: 20px; font-weight: 600; flex: none; }
.lang-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; background: var(--chrome-2); border-radius: 8px; padding: 8px 10px; cursor: pointer; color: var(--text) !important; font-size: 14px !important; flex-direction: row !important; }
.check small { color: var(--muted); margin-left: auto; }

/* ---- Fiche ---- */
.detail-hero { position: relative; margin: -18px -22px 0; min-height: 380px; background: var(--card) center top / cover no-repeat; display: flex; align-items: flex-end; }
.detail-hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, var(--bg) 0%, rgb(16 17 21 / 70%) 45%, rgb(16 17 21 / 30%) 100%); }
.detail-top { position: relative; display: flex; gap: 24px; padding: 0 22px 10px; align-items: flex-end; width: 100%; }
.detail-top .poster { width: 180px; flex: none; box-shadow: 0 8px 30px rgb(0 0 0 / 50%); }
.detail-info h1 { font-size: 30px; margin: 0 0 4px; }
.detail-info .orig { color: var(--muted); margin-bottom: 8px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; color: #c9ccd6; }
.meta .badge-imdb { position: static; font-size: 13px; padding: 1px 6px; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; align-items: center; }
.detail-actions select { background: var(--chrome-2); border: 0; border-radius: 8px; padding: 8px 10px; max-width: 280px; }
.detail-body { padding: 18px 0 0; max-width: 1000px; }
.detail-body .tagline { font-style: italic; color: var(--muted); }
.detail-body .overview { font-size: 15px; line-height: 1.6; }
.people { color: var(--muted); }
.people strong { color: var(--text); font-weight: 500; }
.cast { display: grid; grid-auto-flow: column; grid-auto-columns: 96px; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.cast div { text-align: center; font-size: 12px; }
.cast .ph { width: 96px; height: 96px; border-radius: 50%; background: var(--card) center / cover; margin-bottom: 6px; display: grid; place-items: center; color: var(--faint); font-size: 22px; }
.cast small { color: var(--muted); display: block; }
.seasons { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.episodes { display: flex; flex-direction: column; gap: 8px; }
.episode { display: flex; gap: 14px; background: var(--card); border-radius: 10px; padding: 10px; cursor: pointer; }
.episode:hover { outline: 2px solid var(--accent); }
.episode .thumb { width: 160px; flex: none; aspect-ratio: 16 / 9; border-radius: 6px; background: var(--chrome) center / cover; display: grid; place-items: center; color: var(--faint); font-size: 26px; }
.episode .ep-title { font-weight: 600; }
.episode .ep-text { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---- Lecteur ---- */
.player { position: fixed; inset: 0; background: #000; z-index: 50; display: flex; flex-direction: column; }
.player-bar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: rgb(0 0 0 / 70%); }
.player-title { flex: 1; min-width: 0; }
.player-title > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player video { flex: 1; width: 100%; min-height: 0; background: #000; }
.player-error { position: absolute; inset: 56px 0 0; display: grid; place-items: center; text-align: center; padding: 24px; color: #c9ccd6; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--chrome-2); padding: 10px 16px; border-radius: 8px; z-index: 60; box-shadow: 0 8px 24px rgb(0 0 0 / 40%); }

.form-card { background: var(--card); border-radius: 12px; padding: 20px; max-width: 400px; display: flex; flex-direction: column; gap: 12px; }
.form-card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.form-card input { background: var(--chrome-2); border: 0; border-radius: 8px; padding: 10px 12px; }
.ok { color: #35c27a; margin: 0; min-height: 1.4em; }
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.app-card { background: var(--card); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.app-card:hover { outline: 2px solid var(--accent); }
.app-card i { font-size: 28px; color: var(--accent); }

/* ---- Mobile ---- */
@media (max-width: 760px) {
  .shell.has-sub { --sub: 0px; }
  .shell.has-sub .subpanel { display: none; }
  .corner #side-toggle { display: grid; }
  .logo-mark, .brand { display: none; }
  .sidebar { position: fixed; top: 56px; bottom: 0; left: 0; width: 0; padding: 8px 0; }
  .shell { grid-template-columns: 0 0 minmax(0, 1fr); }
  .corner { grid-column: 1 / 3; position: relative; z-index: 1; width: 52px; }
  .topbar { padding-left: 52px; grid-column: 1 / 4; }
  .shell.side-open .sidebar { width: 230px; padding: 8px; box-shadow: 8px 0 24px rgb(0 0 0 / 40%); }
  .shell.side-open .sidebar a span { opacity: 1; }
  .topbar { gap: 6px; padding-right: 6px; }
  .filters { max-width: 40vw; }
  .main { padding: 14px 12px 40px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 14px 10px; }
  .rail { grid-auto-columns: 112px; }
  .detail-hero { margin: -14px -12px 0; min-height: 300px; }
  .detail-top { padding: 0 12px 10px; gap: 14px; }
  .detail-top .poster { width: 110px; }
  .detail-info h1 { font-size: 22px; }
  .episode .thumb { width: 110px; }
  .live-row { grid-template-columns: 72px minmax(0, 1fr) 32px; }
  .live-row .epg-next { display: none; }
  .live-row .epg-now { grid-column: 2; grid-row: 2; }
  .live-row .fav { grid-column: 3; grid-row: 1; }
  .hero { min-height: 240px; }
  .hero-body { padding: 18px; }
  .hero h2 { font-size: 22px; }
}
