:root {
  --bg: #121417;
  --surface: #1c1f24;
  --surface-2: #24282f;
  --border: #30353d;
  --text: #f5f5f3;
  --muted: #999fa8;
  --accent: #ff7f4f;
  --accent-hover: #ff956d;
  --green: #55bd83;
  --blue: #67a9d8;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; width: 100%; }
html { overflow-x: clip; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.modal-open { overflow: hidden; }

.library-header {
  align-items: center; border-bottom: 1px solid var(--border); display: flex; height: 76px;
  justify-content: space-between; margin: 0 auto; max-width: 1240px; padding: 0 24px;
}
.library-header, .library-shell { min-width: 0; width: 100%; }
.library-brand { align-items: center; color: inherit; display: flex; gap: 11px; min-width: 0; text-decoration: none; }
.library-header > .quiet-button { flex: 0 0 auto; }
.library-brand img { height: 42px; width: 34px; }
.library-brand b, .library-brand small { display: block; }
.library-brand b { font-size: 1rem; }
.library-brand small { color: var(--muted); font-size: .7rem; margin-top: 2px; }
.quiet-button {
  background: var(--surface); border: 1px solid var(--border); border-radius: 7px; color: #c6c9ce;
  cursor: pointer; min-height: 40px; padding: 8px 13px;
}
.quiet-button:hover { border-color: #555c66; color: var(--text); }

.library-shell { margin: 0 auto; max-width: 1240px; padding: 42px 24px 70px; }
.library-heading { align-items: flex-end; display: flex; justify-content: space-between; margin-bottom: 28px; }
.eyebrow { color: var(--accent); font-size: .69rem; font-weight: 750; text-transform: uppercase; }
.library-heading h1 { font-size: 2rem; font-weight: 680; margin: 7px 0 0; }
.library-heading > p { color: var(--muted); font-size: .78rem; margin: 0 0 4px; }

.library-controls {
  align-items: end; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  display: grid; gap: 12px; grid-template-columns: minmax(250px, 1fr) auto; padding: 14px;
}
.library-controls, .training-card, .featured-recording, .recording-grid { max-width: 100%; min-width: 0; }
.library-controls label { display: grid; gap: 6px; min-width: 0; }
.library-controls label > span { color: var(--muted); font-size: .66rem; font-weight: 650; text-transform: uppercase; }
.filter-options { display: grid; gap: 12px; grid-template-columns: 210px 170px; }
.select-control { position: relative; }
.select-control::after {
  bottom: 11px; color: #9fa5ad; content: '⌄'; font-size: 1rem; line-height: 1;
  pointer-events: none; position: absolute; right: 12px;
}
.library-controls input, .library-controls select {
  background: #15171b; border: 1px solid var(--border); border-radius: 6px; color: var(--text);
  min-height: 39px; min-width: 0; padding: 8px 10px; width: 100%;
}
.library-controls select { appearance: none; cursor: pointer; padding-right: 36px; }
.library-controls select option { background: var(--surface-2); color: var(--text); }
.select-control:focus-within::after, .select-control.has-value::after { color: var(--accent-hover); }
.library-controls input:focus, .library-controls select:focus { border-color: var(--accent); outline: none; }
.library-controls input::placeholder { color: #a0a6ae; }
.filter-toggle { display: none; }
.category-tabs {
  border-bottom: 1px solid var(--border); display: flex; gap: 24px; margin: 10px 0 26px;
  overflow-x: auto; scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar { display: none; }
.category-tabs button {
  background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted);
  cursor: pointer; font-size: .78rem; font-weight: 650; padding: 13px 1px 11px; white-space: nowrap;
}
.category-tabs button.active { border-bottom-color: var(--accent); color: var(--text); }

.recording-grid { display: grid; gap: 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.training-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; display: flex;
  flex-direction: column; min-width: 0; overflow: hidden;
}
.training-preview {
  aspect-ratio: 16 / 9; background: #282d34; border: 0; color: #fff; cursor: pointer;
  overflow: hidden; position: relative; width: 100%;
}
.training-preview > img { height: 100%; inset: 0; object-fit: cover; position: absolute; width: 100%; }
.training-preview::after {
  background: var(--accent); content: ''; height: 4px; left: 0; position: absolute; top: 0; width: 38%;
}
.preview-category {
  background: rgba(18,20,23,.86); border: 1px solid rgba(255,255,255,.08); border-radius: 4px;
  font-size: .65rem; left: 12px; max-width: calc(100% - 24px); overflow: hidden; padding: 5px 7px;
  position: absolute; text-overflow: ellipsis; top: 12px; white-space: nowrap;
}
.preview-play {
  align-items: center; background: var(--accent); border-radius: 50%; display: flex; font-size: .82rem;
  height: 46px; justify-content: center; left: 50%; padding-left: 3px; position: absolute;
  top: 50%; transform: translate(-50%, -50%); width: 46px;
}
.training-preview:hover .preview-play { background: var(--accent-hover); }
.preview-duration {
  background: rgba(0,0,0,.76); border-radius: 4px; bottom: 10px; font-size: .68rem;
  padding: 4px 6px; position: absolute; right: 10px;
}
.training-card-body { padding: 17px 17px 12px; }
.recording-date { color: var(--blue); font-size: .68rem; font-weight: 650; margin: 0 0 7px; text-transform: uppercase; }
.training-card h2 {
  font-size: 1rem; font-weight: 680; line-height: 1.35; margin: 0; overflow-wrap: anywhere;
}
.recording-speaker { color: #d1d4d8; font-size: .77rem; margin: 7px 0 0; }
.recording-description {
  color: var(--muted); display: -webkit-box; font-size: .76rem; line-height: 1.55; margin: 10px 0 0;
  overflow: hidden; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
}
.recording-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.recording-tags span {
  background: rgba(85,189,131,.1); border: 1px solid rgba(85,189,131,.2); border-radius: 4px;
  color: #84d3a5; font-size: .64rem; padding: 4px 6px;
}
.training-card-actions { display: flex; gap: 8px; margin-top: auto; padding: 4px 17px 17px; }
.watch-button {
  background: var(--accent); border: 1px solid var(--accent); border-radius: 7px; color: #fff;
  cursor: pointer; font-weight: 680; min-height: 40px; padding: 8px 16px;
}
.watch-button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.training-card-actions .watch-button, .training-card-actions .quiet-button { flex: 1; }

.featured-recording { margin-bottom: 20px; }
.featured-recording[hidden] { display: none; }
.featured-recording .training-card { display: grid; grid-template-columns: minmax(320px, .9fr) 1fr; position: relative; }
.featured-recording .training-card::before {
  background: var(--green); color: #0e1712; content: 'Featured'; font-size: .64rem; font-weight: 800;
  padding: 5px 8px; position: absolute; right: 12px; text-transform: uppercase; top: 12px; z-index: 2;
}
.featured-recording .training-preview { grid-row: 1 / span 2; height: 100%; }
.featured-recording .training-card-body { align-self: end; padding: 30px 24px 12px; }
.featured-recording .training-card h2 { font-size: 1.35rem; }
.featured-recording .training-card-actions { padding: 8px 24px 24px; }
.featured-recording .training-card-actions button { flex: 0 0 auto; min-width: 120px; }

.library-loading { animation: pulse 900ms ease-in-out infinite alternate; aspect-ratio: 4 / 3; background: var(--surface); border-radius: 8px; }
@keyframes pulse { to { opacity: .45; } }
.library-message { color: var(--muted); padding: 70px 20px; text-align: center; }
.library-message[hidden] { display: none; }

.watch-modal {
  align-items: center; background: rgba(0,0,0,.84); display: none; inset: 0; justify-content: center;
  padding: 22px; position: fixed; z-index: 20;
}
.watch-modal.open { display: flex; }
.watch-dialog { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; max-width: 1040px; overflow: hidden; position: relative; width: 100%; }
.watch-close {
  align-items: center; background: rgba(18,20,23,.88); border: 1px solid rgba(255,255,255,.16);
  border-radius: 6px; color: #fff; cursor: pointer; display: flex; font-size: 1.15rem; height: 36px;
  justify-content: center; position: absolute; right: 10px; top: 10px; width: 36px; z-index: 2;
}
.watch-stage { align-items: center; aspect-ratio: 16 / 9; background: #050505; display: flex; justify-content: center; position: relative; }
.watch-stage video { height: 100%; max-height: 72vh; width: 100%; }
.watch-stage video[hidden], .watch-stage p[hidden] { display: none; }
.watch-stage p { color: var(--muted); font-size: .8rem; position: absolute; }
.watch-details { align-items: center; display: flex; justify-content: space-between; padding: 16px 18px; }
.watch-details h2 { font-size: 1rem; margin: 0 0 5px; }
.watch-details p { color: var(--muted); font-size: .73rem; margin: 0; }
.watch-detail-actions { display: flex; gap: 8px; }
.watch-detail-actions button[hidden] { display: none; }
.library-toast {
  background: #f2f3f3; border-radius: 7px; bottom: max(20px, env(safe-area-inset-bottom)); color: #17191d;
  font-size: .78rem; font-weight: 650; left: 50%; opacity: 0; padding: 10px 14px; pointer-events: none;
  position: fixed; transform: translate(-50%, 8px); transition: opacity 160ms cubic-bezier(.23,1,.32,1), transform 160ms cubic-bezier(.23,1,.32,1); z-index: 30;
}
.library-toast.show { opacity: 1; transform: translate(-50%, 0); }

.access-page { align-items: center; display: flex; justify-content: center; min-height: 100vh; padding: 20px; }
.access-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 34px 30px; width: min(390px, 100%); }
.access-panel > img { display: block; height: 50px; margin-bottom: 24px; width: 40px; }
.access-panel h1 { font-size: 1.4rem; margin: 7px 0 26px; }
.access-panel form { display: grid; }
.access-panel label { color: var(--muted); font-size: .7rem; font-weight: 650; margin-bottom: 7px; text-transform: uppercase; }
.access-panel input {
  background: #15171b; border: 1px solid var(--border); border-radius: 7px; color: var(--text);
  font-size: 1.15rem; letter-spacing: 0; min-height: 46px; padding: 10px 12px; text-align: center;
}
.access-panel input:focus { border-color: var(--accent); outline: none; }
.access-panel button {
  background: var(--accent); border: 0; border-radius: 7px; color: #fff; cursor: pointer;
  font-weight: 700; min-height: 44px;
}
.access-panel button:disabled { cursor: default; opacity: .6; }
.access-error { color: #ef8a8a; font-size: .74rem; min-height: 18px; margin: 7px 0 9px; }

@media (max-width: 900px) {
  .recording-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .featured-recording .training-card { grid-template-columns: minmax(260px, .8fr) 1fr; }
}
@media (max-width: 680px) {
  .library-header { height: 68px; padding: 0 15px; }
  .library-header .quiet-button { min-height: 44px; }
  .library-shell { padding: 24px 15px calc(50px + env(safe-area-inset-bottom)); }
  .library-heading { align-items: flex-start; gap: 10px; margin-bottom: 20px; }
  .library-heading h1 { font-size: 1.55rem; }
  .library-heading > p { margin-top: 8px; white-space: nowrap; }
  .library-controls { align-items: end; gap: 10px; grid-template-columns: minmax(0, 1fr) auto; padding: 10px; }
  .library-controls label, .library-controls input, .library-controls select { max-width: 100%; min-width: 0; }
  .library-controls input, .library-controls select { min-height: 44px; }
  .filter-toggle {
    align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px;
    color: var(--text); cursor: pointer; display: flex; gap: 7px; justify-content: center; min-height: 44px;
    padding: 8px 11px; transition: background-color 160ms cubic-bezier(.23,1,.32,1), border-color 160ms cubic-bezier(.23,1,.32,1), transform 120ms cubic-bezier(.23,1,.32,1);
  }
  .filter-toggle:active { transform: scale(.97); }
  .filter-toggle[aria-expanded='true'], .filter-toggle.has-filters { border-color: rgba(255,127,79,.55); }
  .filter-count { align-items: center; background: var(--accent); border-radius: 999px; color: #fff; display: inline-flex; font-size: .68rem; font-weight: 750; height: 19px; justify-content: center; min-width: 19px; padding: 0 5px; }
  .filter-count[hidden] { display: none; }
  .filter-chevron { color: var(--muted); display: inline-block; font-size: 1rem; line-height: 1; transition: transform 160ms cubic-bezier(.23,1,.32,1); }
  [aria-expanded='true'] > .filter-chevron { transform: rotate(180deg); }
  .filter-options {
    border-top: 1px solid var(--border); display: none; gap: 10px; grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr)); padding-top: 10px;
  }
  .filter-options.open { display: grid; }
  .category-tabs { display: none; }
  .featured-recording { margin-top: 14px; }
  .recording-grid { grid-template-columns: 1fr; }
  .training-card-body { padding: 15px 15px 11px; }
  .training-card-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 4px 15px 15px; }
  .training-card-actions .watch-button { grid-column: 1 / -1; min-height: 46px; }
  .training-card-actions .quiet-button { min-height: 44px; }
  .featured-recording .training-card { display: flex; }
  .featured-recording .training-preview { height: auto; }
  .featured-recording .training-card-body { padding: 15px 15px 11px; }
  .featured-recording .training-card h2 { font-size: 1rem; }
  .featured-recording .training-card-actions { padding: 4px 15px 15px; }
  .featured-recording .training-card-actions button { flex: 1; min-width: 0; }
  .watch-modal { align-items: flex-start; padding: 0; }
  .watch-dialog { border: 0; border-radius: 0; max-width: none; min-height: 100dvh; overflow: auto; }
  .watch-close { min-height: 42px; right: max(10px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); width: 42px; }
  .watch-stage { margin-top: env(safe-area-inset-top); }
  .watch-details { align-items: stretch; flex-direction: column; gap: 16px; padding: 18px 15px calc(18px + env(safe-area-inset-bottom)); }
  .watch-details h2 { font-size: 1.08rem; line-height: 1.35; }
  .watch-details p { line-height: 1.5; }
  .watch-detail-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .watch-detail-actions .quiet-button { min-height: 44px; }
  .watch-detail-actions #watchDownload:last-child { grid-column: 1 / -1; }
}
@media (max-width: 390px) {
  .library-heading { display: block; }
  .library-heading > p { margin-top: 9px; }
}
@media (max-width: 680px) and (orientation: landscape) {
  .watch-stage { height: 100dvh; margin: 0; }
  .watch-details { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
