/* 3B Videos player styles (see app.js). */
:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --card: #ffffff;
  --fill: rgba(120, 120, 128, .08);
  --fill-strong: rgba(120, 120, 128, .16);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --sep: rgba(60, 60, 67, .12);
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, .10);
  --bar: rgba(245, 245, 247, .72);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 28px rgba(0, 0, 0, .06);
  --player-shadow: 0 12px 40px rgba(0, 0, 0, .14);
  --seg-thumb: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000;
    --card: #1c1c1e;
    --fill: rgba(118, 118, 128, .18);
    --fill-strong: rgba(118, 118, 128, .28);
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #8d8d93;
    --sep: rgba(84, 84, 88, .48);
    --accent: #2997ff;
    --accent-soft: rgba(41, 151, 255, .16);
    --bar: rgba(22, 22, 23, .72);
    --shadow: 0 0 0 1px rgba(255, 255, 255, .04);
    --player-shadow: 0 12px 40px rgba(0, 0, 0, .6);
    --seg-thumb: #636366;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --card: #1c1c1e;
  --fill: rgba(118, 118, 128, .18);
  --fill-strong: rgba(118, 118, 128, .28);
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #8d8d93;
  --sep: rgba(84, 84, 88, .48);
  --accent: #2997ff;
  --accent-soft: rgba(41, 151, 255, .16);
  --bar: rgba(22, 22, 23, .72);
  --shadow: 0 0 0 1px rgba(255, 255, 255, .04);
  --player-shadow: 0 12px 40px rgba(0, 0, 0, .6);
  --seg-thumb: #636366;
}
:root {
  --plyr-color-main: var(--accent);
  --plyr-menu-background: var(--card);
  --plyr-menu-color: var(--text);
  --plyr-menu-border-color: var(--sep);
  --plyr-menu-arrow-color: var(--text-2);
  --plyr-menu-back-border-color: var(--sep);
  --plyr-menu-back-border-shadow-color: transparent;
  --plyr-tooltip-background: var(--card);
  --plyr-tooltip-color: var(--text);
  --plyr-font-family: inherit;
  --plyr-captions-background: rgba(0, 0, 0, .72);
  --plyr-captions-text-color: #fff;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.47 -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, sans-serif;
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s ease, color .3s ease;
}
button { font: inherit; color: inherit; }

/* Top bar: translucent, like Safari and apple.com */
.bar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--sep);
}
.bar-inner {
  max-width: 1440px; margin: 0 auto; height: 52px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
[hidden] { display: none !important; }
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; letter-spacing: -.02em; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  background: linear-gradient(180deg, #3a9bff, #0066d6); color: #fff;
}
.brand-mark svg { width: 12px; height: 12px; margin-left: 2px; }

/* Segmented control */
.seg { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--fill-strong); position: relative; }
.seg button {
  all: unset; cursor: pointer; position: relative; z-index: 1;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--text);
}
.seg button svg { width: 14px; height: 14px; }
.seg button[aria-pressed="true"] { background: var(--seg-thumb); box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04); }
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.layout {
  max-width: 1440px; margin: 0 auto; padding: 28px 24px 64px;
  display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 32px; align-items: start;
}

.player-wrap {
  position: relative; background: #000; border-radius: 18px; overflow: hidden; aspect-ratio: 16 / 9;
  box-shadow: var(--player-shadow); isolation: isolate;
}
.player-wrap .plyr { height: 100%; }
/* CSS fullscreen (used when the browser has no Fullscreen API for elements):
   let the player escape the rounded box and cover the whole page. */
.player-wrap:has(.plyr--fullscreen-fallback) { isolation: auto; overflow: visible; z-index: 100; box-shadow: none; }
.plyr--fullscreen-fallback { z-index: 1000 !important; }
.plyr--video .plyr__controls { padding-bottom: 14px; }

.eyebrow { margin: 24px 0 4px; font-size: 13px; font-weight: 600; color: var(--accent); letter-spacing: 0; }
h1#title { margin: 0; font-size: 32px; line-height: 1.12; font-weight: 700; letter-spacing: -.028em; }
.meta { margin-top: 8px; color: var(--text-2); font-size: 15px; display: flex; gap: 6px; flex-wrap: wrap; }
.meta > span + span::before { content: "·"; margin-right: 6px; color: var(--text-3); }

.nav { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 32px; }
#share { margin-left: auto; }
.pill {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 980px; font-size: 14px; font-weight: 500;
  background: var(--fill); color: var(--text); transition: background-color .15s ease;
}
.pill:hover { background: var(--fill-strong); }
.pill.primary { background: var(--accent); color: #fff; }
.pill.primary:hover { filter: brightness(1.08); }
.pill[disabled] { opacity: .35; pointer-events: none; }
.pill svg { width: 12px; height: 12px; }
.pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.section-title { margin: 0 0 10px 4px; font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.group { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.group ol { list-style: none; margin: 0; padding: 0; }
.row {
  all: unset; box-sizing: border-box; cursor: pointer; width: 100%;
  display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 44px; position: relative;
  transition: background-color .12s ease;
}
.row:hover { background: var(--fill); }
.row:active { background: var(--fill-strong); }
.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
li + li > .row::before {
  content: ""; position: absolute; top: 0; right: 0; left: var(--inset, 16px); border-top: .5px solid var(--sep);
}
.row .name { flex: 1; min-width: 0; padding: 11px 0; }
.row sub, .row sup, h1 sub, h1 sup { font-size: .72em; line-height: 0; }
.row .time { color: var(--text-2); font-size: 14px; font-variant-numeric: tabular-nums; }

/* Chapters */
#chapters { columns: 2; column-gap: 0; }
#chapters li { break-inside: avoid; }
#chapters .row { --inset: 16px; }
#chapters .dot { width: 6px; height: 6px; border-radius: 50%; background: transparent; flex: none; }
#chapters li.active .dot { background: var(--accent); }
#chapters li.active .name { color: var(--accent); font-weight: 600; }

/* Resume notice */
.resume { margin: 10px 0 0; font-size: 14px; color: var(--text-2); }
.resume button { all: unset; cursor: pointer; margin-left: 8px; color: var(--accent); font-weight: 500; }
.resume button:hover { text-decoration: underline; }

/* Sidebar: search, course switch, list */
.search {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; margin-bottom: 14px;
  border-radius: 10px; background: var(--fill-strong); color: var(--text-2); cursor: text;
  transition: box-shadow .15s ease;
}
.search:focus-within { box-shadow: 0 0 0 3.5px var(--accent-soft), inset 0 0 0 1px var(--accent); }
.search svg { width: 15px; height: 15px; flex: none; }
.search input { all: unset; flex: 1; min-width: 0; height: 100%; font-size: 15px; color: var(--text); }
.search input::placeholder { color: var(--text-2); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd {
  font: 500 12px/1 inherit; padding: 3px 7px; border-radius: 5px;
  background: var(--card); color: var(--text-2); box-shadow: 0 0 0 .5px var(--sep), 0 1px 1px rgba(0, 0, 0, .06);
}
.search .clear {
  all: unset; cursor: pointer; display: none; place-items: center; width: 18px; height: 18px; flex: none;
  border-radius: 50%; background: var(--text-3); color: var(--card); font-size: 10px; font-weight: 700;
}
.search.has-q .clear { display: grid; }
.search.has-q kbd { display: none; }
@media (hover: none) { .search kbd { display: none; } }

.seg-courses { display: flex; width: 100%; margin-bottom: 18px; }
.seg-courses button { flex: 1; justify-content: center; padding: 6px 4px; white-space: nowrap; }
.course-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 4px 10px; }
.course-head .section-title { margin: 0; font-size: 17px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#course-progress { flex: none; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }

.side-body { border-radius: 14px; }
#lists .row, #results .row { --inset: 64px; gap: 14px; align-items: center; }
.badge {
  width: 36px; height: 36px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: var(--fill); color: var(--text-2); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.vtext { flex: 1; min-width: 0; padding: 10px 0; }
.vtitle { display: block; font-size: 15px; line-height: 1.3; }
.vsub { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 0; }
.vsub .ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.track { flex: 1; max-width: 120px; height: 3px; border-radius: 2px; background: var(--fill-strong); overflow: hidden; }
.track i { display: block; height: 100%; background: var(--text-3); border-radius: 2px; }
.done { color: var(--text-3); }
#lists li.active .badge { background: var(--accent); color: #fff; }
#lists li.active .vtitle { color: var(--accent); font-weight: 600; }
#lists li.active .track i { background: var(--accent); }

.result-label { margin: 18px 4px 8px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); }
.result-label:first-child { margin-top: 0; }
.group.empty { padding: 20px 18px; }
.group.empty p { margin: 0; }
.group.empty .hint { margin-top: 6px; font-size: 14px; color: var(--text-2); }

/* Desktop: the list stays in view and scrolls by itself */
@media (min-width: 1001px) {
  aside { position: sticky; top: 76px; display: flex; flex-direction: column; max-height: calc(100vh - 96px); }
  .side-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
}

/* Overlays on the player: "Up next" and errors */
.overlay {
  position: absolute; inset: 0; z-index: 10; display: grid; place-content: center; justify-items: center;
  gap: 6px; padding: 24px; text-align: center; color: #fff;
  background: rgba(0, 0, 0, .72); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  animation: fade .25s ease;
}
.ov-label { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: rgba(255, 255, 255, .7); }
.ov-title { margin: 0; max-width: 32ch; font-size: clamp(18px, 2.6vw, 28px); font-weight: 700; line-height: 1.2; letter-spacing: -.02em; }
.ov-sub { margin: 0; font-size: 14px; color: rgba(255, 255, 255, .7); }
.ov-actions { display: flex; gap: 10px; margin-top: 14px; }
.ov-count { margin: 6px 0 0; font-size: 13px; color: rgba(255, 255, 255, .6); font-variant-numeric: tabular-nums; }
.overlay .pill { background: rgba(255, 255, 255, .16); color: #fff; }
.overlay .pill:hover { background: rgba(255, 255, 255, .26); }
.overlay .pill.primary { background: #fff; color: #000; }
@keyframes fade { from { opacity: 0; } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 980px; background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 500; box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Loading placeholders */
.skel { display: inline-block; max-width: 100%; height: .8em; border-radius: 6px; background: var(--fill-strong); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* Phone and tablet */
.mtabs { display: none; }
@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 0 0 48px; gap: 0; }
  .player-wrap { border-radius: 0; box-shadow: none; }
  main > :not(.player-wrap), aside { padding: 0 16px; }
  .nav { margin: 18px 0 22px; }
  main > .mtabs { display: flex; width: auto; margin: 0 16px 22px; padding: 2px; }
  .mtabs button { flex: 1; justify-content: center; padding: 7px 4px; }
  body[data-panel="videos"] #chapters-panel { display: none; }
  body:not([data-panel="videos"]) aside { display: none; }
  #chapters { columns: 1; }
}
@media (max-width: 560px) {
  .bar-inner { padding: 0 16px; }
  .bar .seg button span { display: none; }
  .bar .seg button { padding: 5px 10px; }
  h1#title { font-size: 26px; }
  .meta > span:first-child { flex-basis: 100%; }
  .meta > span:nth-child(2)::before { content: none; }
  .pill { padding: 8px 14px; }
}
@media (prefers-reduced-motion: reduce) { *, .overlay, .skel { transition: none !important; animation: none !important; } }
