:root { color-scheme: dark; font-family: system-ui, -apple-system, Segoe UI, sans-serif; background: #0f1117; color: #f5f7fb; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #07111c url("../site/bck2-television.jpg") center / cover fixed no-repeat; }
button, input { font: inherit; }
a { color: inherit; }
.library { padding: 16px clamp(14px, 4vw, 44px) 48px; max-width: 1600px; margin: auto; }
.library-header { display: grid; gap: 14px; padding-bottom: 22px; border-bottom: 1px solid #ffffff18; }
.back-link { width: fit-content; padding: 10px 16px; background: #242834; border: 1px solid #ffffff24; border-radius: 12px; text-decoration: none; font-weight: 700; }
.title-row, .category-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
h1 { font-size: clamp(1.8rem, 3vw, 2.3rem); margin: 4px 0; }
.count-pill { border: 1px solid #ffffff24; border-radius: 999px; background: #ffffff0e; padding: 5px 12px; font-size: .85rem; color: #cfd5e1; font-weight: 700; }
label { font-size: .9rem; color: #cfd5e1; margin-bottom: -7px; }
input { width: min(100%, 520px); min-height: 46px; border: 1px solid #ffffff26; border-radius: 12px; background: #171923; color: #fff; padding: 10px 14px; }
input::placeholder { color: #a1a9ba; }
.category { margin-top: 32px; }
.category + .category { margin-top: 44px; }
.category-heading { padding-bottom: 12px; border-bottom: 2px solid #7288d9; }
.category:nth-child(2) .category-heading { border-color: #bc99e9; }
h2 { font-size: clamp(1.35rem, 2.5vw, 1.85rem); margin: 0; }
.description { color: #b8c0d0; line-height: 1.55; margin: 12px 0 22px; }
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 28px 24px; }
.video-card { min-width: 0; text-decoration: none; border-radius: 12px; display: flex; flex-direction: column; align-items: flex-start; }
.cover { width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; position: relative; overflow: hidden; display: grid; place-items: center; border: 1px solid #ffffff25; box-shadow: 0 8px 22px #0003; transition: transform .15s; background: linear-gradient(135deg, #314775, #182537); }
.rose { background: linear-gradient(135deg, #833d55, #342034); }
.teal { background: linear-gradient(135deg, #256a6b, #18303e); }
.purple { background: linear-gradient(135deg, #6a458d, #282039); }
.gold { background: linear-gradient(135deg, #726133, #302c21); }
.orange { background: linear-gradient(135deg, #915135, #3c2529); }
.green { background: linear-gradient(135deg, #386f53, #192e2e); }
.native-name { font-size: clamp(1.75rem, 2.3vw, 2.3rem); font-weight: 700; padding: 12px 12px 34px; text-align: center; }
.cover img { width: 100%; height: 100%; object-fit: cover; position: absolute; }
.play { position: absolute; bottom: 12px; right: 14px; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #0007; color: #fff; font-size: 14px; padding-left: 2px; }
h3 { margin: 12px 0 5px; font-size: 1.2rem; }
.lesson-name { margin: 0 0 10px; color: #b8c0d0; font-size: .9rem; line-height: 1.5; }
.watch-label { color: #afc4ff; font-size: .9rem; margin-top: auto; }
.video-card:hover .cover { transform: translateY(-4px); }
:focus-visible { outline: 3px solid #c4d3ff; outline-offset: 5px; }
[hidden] { display: none !important; }
dialog { width: min(960px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 20px; border: 1px solid #ffffff35; border-radius: 16px; background: #171923; color: #f5f7fb; }
dialog::backdrop { background: #000c; }
.watch-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.watch-header h2 { font-size: 1.15rem; line-height: 1.5; }
.watch-header button { flex-shrink: 0; cursor: pointer; border: 1px solid #ffffff30; border-radius: 8px; background: #303747; color: white; padding: 10px 14px; }
.video-frame { aspect-ratio: 16 / 9; background: #000; }
.video-frame iframe { display: block; width: 100%; height: 100%; border: 0; }
.watch-help { line-height: 1.6; color: #cfd5e1; margin-bottom: 0; }
@media (max-width: 540px) { .video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 14px; } .native-name { font-size: 1.25rem; padding-bottom: 24px; } .play { width: 24px; height: 24px; bottom: 6px; right: 8px; font-size: 11px; } h3 { font-size: 1.05rem; } dialog { padding: 14px; } }
@media (max-width: 340px) { .video-grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .cover { transition: none; } }
/* Language selection and the interactive episode popup. */
#languageScreen > .back-link { display: inline-block; margin-bottom: 26px; }
.language-grid { margin-top: 28px; }
.language-choice { min-height: 156px; border: 1px solid #ffffff30; border-radius: 14px; color: white; cursor: pointer; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 12px; font: inherit; background-color: #263b60; }
.language-choice .native-name { padding: 0 10px; }
.language-choice:hover { border-color: #c4d3ff; filter: brightness(1.12); }
.library-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; }
.library-nav button { color: inherit; cursor: pointer; font: inherit; }
#chosenLanguage { color: #cfd5e1; }
#videoFrame.episode-frame { aspect-ratio: auto; background: #171923; }
#videoFrame.episode-frame iframe { height: 650px; }
body:has(#videoDialog[open]) { overflow: hidden; }
.watch-header { position: sticky; top: -20px; z-index: 2; padding: 10px 0; background: #171923; }
@media(max-width:540px) { .language-choice { min-height: 130px; } .watch-header { top: -14px; } }

/* Category previews remain visible when the video shelves are collapsed. */
.category + .category { margin-top: 20px; }
.category-heading { display: block; padding: 0; border: 0; }
.category-toggle { display: flex; align-items: center; gap: 24px; width: 100%; padding: 16px; border: 1px solid #ffffff24; border-radius: 16px; color: inherit; background: #171923; text-align: left; cursor: pointer; }
.category-toggle:hover { background: #202432; border-color: #7288d9; }
.category-preview { display: block; width: 192px; height: 108px; flex-shrink: 0; object-fit: cover; border-radius: 9px; background: #263b60; }
.category-copy { display: grid; justify-items: start; gap: 12px; min-width: 0; }
.category-title { font-size: clamp(1.2rem, 2.5vw, 1.85rem); font-weight: 700; overflow-wrap: anywhere; }
.category-chevron { margin-left: auto; font-size: 1.8rem; line-height: 1; }
.category-toggle[aria-expanded="true"] .category-chevron { transform: rotate(180deg); }
.category-content { padding: 4px 16px 16px; }
@media(max-width:540px) {
 .category-toggle { padding: 12px; gap: 12px; }
 .category-preview { width: 104px; height: 70px; }
 .category-title { font-size: 1.1rem; }
 .category-copy { gap: 8px; }
 .category-copy .count-pill { font-size: .75rem; padding: 4px 8px; }
 .category-content { padding: 4px 0 12px; }
}
