/* Video Library - YouTube-like layout, light/dark, phone to desktop */
:root {
  --bg: #ffffff; --bg2: #f2f2f2; --bg3: #e5e5e5; --fg: #0f0f0f; --fg2: #606060;
  --accent: #e5483c; --accent-fg: #ffffff; --ring: rgba(229, 72, 60, .35);
  --shadow: 0 1px 2px rgba(0,0,0,.08); --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f0f0f; --bg2: #212121; --bg3: #303030; --fg: #f1f1f1; --fg2: #aaaaaa; --shadow: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.4 Roboto, "Segoe UI", system-ui, -apple-system, Arial, sans-serif; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
svg { fill: currentColor; }

/* header */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 16px; background: var(--bg); border-bottom: 1px solid var(--bg2); }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 19px; letter-spacing: -.3px; white-space: nowrap; }
.logo svg { width: 30px; height: 30px; }
.logo svg rect { fill: var(--accent); } .logo svg path { fill: #fff; }
.search { flex: 1; display: flex; max-width: 640px; margin: 0 auto; }
.search input { flex: 1; min-width: 0; height: 40px; padding: 0 16px; border: 1px solid var(--bg3);
  border-right: 0; border-radius: 20px 0 0 20px; background: var(--bg); color: var(--fg); font-size: 15px; outline: none; }
.search input:focus { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--ring); }
.search button { width: 60px; height: 40px; border: 1px solid var(--bg3); border-radius: 0 20px 20px 0;
  background: var(--bg2); cursor: pointer; }
.search button svg { width: 22px; height: 22px; }
.nav a { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; }
.nav a:hover { background: var(--bg2); }
.nav svg { width: 24px; height: 24px; }
@media (max-width: 600px) {
  .top { gap: 8px; padding: 0 10px; }
  .logo span { display: none; }
  .search button { width: 46px; }
}

main { padding: 20px 24px 48px; max-width: 1800px; margin: 0 auto; }
@media (max-width: 600px) { main { padding: 12px 10px 40px; } }
.loading, .empty { padding: 60px 0; text-align: center; color: var(--fg2); }

/* sections and rows */
.section { margin-bottom: 34px; }
.section-head { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; }
.section-head h2 { margin: 0; font-size: 20px; }
.section-head .more { margin-left: auto; padding: 6px 14px; border-radius: 18px; background: var(--bg2); font-size: 14px; font-weight: 500; }
.section-head .more:hover { background: var(--bg3); }
.section-head img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 16px;
  overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 6px; scrollbar-width: thin; }
.row > * { scroll-snap-align: start; }
@media (min-width: 1200px) { .row { grid-auto-columns: calc((100% - 4 * 16px) / 5); } }
@media (max-width: 600px) { .row { grid-auto-columns: 72%; } }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 28px 16px; }
@media (max-width: 600px) { .grid { grid-template-columns: 1fr; gap: 20px; } }

/* video card */
.card { display: block; min-width: 0; }
.thumb { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: var(--bg2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.card:hover .thumb img { transform: scale(1.03); }
.dur { position: absolute; right: 6px; bottom: 6px; padding: 1px 5px; border-radius: 4px;
  background: rgba(0,0,0,.8); color: #fff; font-size: 12px; font-weight: 600; }
.prog { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.35); }
.prog i { display: block; height: 100%; background: var(--accent); }
.seen { position: absolute; left: 6px; top: 6px; padding: 1px 6px; border-radius: 4px; background: rgba(0,0,0,.75);
  color: #fff; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.od { position: absolute; right: 6px; top: 6px; padding: 1px 6px; border-radius: 4px; background: rgba(0,0,0,.75);
  color: #fff; font-size: 11px; font-weight: 600; letter-spacing: .3px; }
.prep { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.72); color: #fff; text-align: center; padding: 16px; }
.prep[hidden], .prep-box [hidden] { display: none; }   /* sinon display:grid/flex l'emporte sur hidden */
.prep-box { display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 420px; }
.prep-box b { font-size: 18px; }
.prep-box span { font-size: 14px; opacity: .85; }
.prep-bar { width: 260px; max-width: 70vw; height: 6px; margin-top: 6px; border-radius: 3px; background: rgba(255,255,255,.25); overflow: hidden; }
.prep-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .6s; }
.prep-box button { margin-top: 8px; padding: 8px 18px; border: 0; border-radius: 18px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid rgba(255,255,255,.25); border-top-color: #fff; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.meta { display: flex; gap: 12px; padding-top: 10px; }
.meta .av { flex: 0 0 36px; height: 36px; border-radius: 50%; overflow: hidden; background: var(--bg2); }
.meta .av img { width: 100%; height: 100%; object-fit: cover; }
.meta h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta p { margin: 0; color: var(--fg2); font-size: 13px; }

/* home: channel cards */
.channels { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
@media (max-width: 600px) { .channels { grid-template-columns: 1fr; gap: 14px; } }
.chan-card { display: block; border-radius: 16px; overflow: hidden; background: var(--bg2); box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s; }
.chan-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.chan-banner { position: relative; aspect-ratio: 4 / 1; background: linear-gradient(135deg, var(--accent), #f39c4a) center / cover no-repeat; }
.badge { position: absolute; right: 10px; top: 10px; padding: 3px 10px; border-radius: 12px; background: var(--accent);
  color: var(--accent-fg); font-size: 12px; font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.chan-body { display: flex; align-items: center; gap: 14px; padding: 0 16px 16px; }
.chan-body img { flex: 0 0 72px; width: 72px; height: 72px; margin-top: -24px; border-radius: 50%; object-fit: cover;
  border: 4px solid var(--bg2); background: var(--bg2); }
.chan-body h3 { margin: 10px 0 2px; font-size: 18px; }
.chan-body p { margin: 0; color: var(--fg2); font-size: 13px; }

/* channel page */
.banner { aspect-ratio: 6 / 1; border-radius: var(--radius); background: var(--bg2) center / cover no-repeat; margin-bottom: 18px; }
.chan-head { display: flex; align-items: center; gap: 20px; margin-bottom: 18px; }
.chan-head img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; background: var(--bg2); }
.chan-head h1 { margin: 0 0 4px; font-size: 28px; }
.chan-head p { margin: 0; color: var(--fg2); }
@media (max-width: 600px) { .chan-head img { width: 64px; height: 64px; } .chan-head h1 { font-size: 21px; } }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 20px; }
.chip { padding: 7px 14px; border: 0; border-radius: 8px; background: var(--bg2); font-size: 14px; font-weight: 500; cursor: pointer; }
.chip:hover { background: var(--bg3); }
.chip.on { background: var(--fg); color: var(--bg); }
.toolbar input { margin-left: auto; height: 34px; min-width: 200px; padding: 0 12px; border: 1px solid var(--bg3);
  border-radius: 8px; background: var(--bg); color: var(--fg); }
.loadmore { display: block; margin: 28px auto 0; padding: 10px 24px; border: 0; border-radius: 20px; background: var(--bg2); cursor: pointer; font-weight: 500; }

/* watch page */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; }
@media (max-width: 1100px) { .watch { grid-template-columns: 1fr; } }
.player { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; }
.player video { width: 100%; height: 100%; display: block; background: #000; }
@media (max-width: 600px) { .player { margin: -12px -10px 0; border-radius: 0; } }
.watch h1 { margin: 14px 0 10px; font-size: 20px; line-height: 1.3; }
.byline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.byline img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.byline b { display: block; }
.byline small { color: var(--fg2); }
.byline .spacer { flex: 1; }
.toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--fg2); font-size: 14px; cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.desc { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius); background: var(--bg2); font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.desc.short { max-height: 7.5em; overflow: hidden; }
.desc .ts { color: #3ea6ff; cursor: pointer; }
.desc-more { margin-top: 6px; border: 0; background: none; font-weight: 600; cursor: pointer; padding: 4px 0; }
.chapters { display: flex; gap: 8px; overflow-x: auto; margin-top: 12px; padding-bottom: 4px; }
.chapters button { flex: 0 0 auto; max-width: 220px; padding: 6px 10px; border: 1px solid var(--bg3); border-radius: 8px;
  background: var(--bg); cursor: pointer; text-align: left; font-size: 13px; }
.chapters button b { color: #3ea6ff; margin-right: 6px; }
.side h2 { margin: 0 0 12px; font-size: 16px; }
.mini { display: grid; grid-template-columns: 168px 1fr; gap: 10px; margin-bottom: 10px; }
.mini .thumb { border-radius: 8px; }
.mini h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mini p { margin: 0; color: var(--fg2); font-size: 12px; }
.mini.current { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.notice { padding: 14px; border-radius: var(--radius); background: var(--bg2); color: var(--fg2); }
.page-title { margin: 0 0 18px; font-size: 22px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
