:root {
  --navy: #10233f;
  --navy-2: #17365f;
  --blue: #2967d7;
  --blue-soft: #eaf1ff;
  --ink: #172235;
  --muted: #667085;
  --line: #dde3ec;
  --surface: #ffffff;
  --canvas: #f4f6f9;
  --pdf: #d94b4b;
  --video: #2c72dd;
  --shadow: 0 12px 32px rgba(16, 35, 63, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.hero {
  min-height: 124px;
  padding: 24px clamp(22px, 4vw, 64px);
  background: linear-gradient(115deg, #0e203a 0%, #183c69 70%, #245ea4 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

.brand { display: flex; align-items: center; gap: 16px; }
.brand-mark {
  width: 58px; height: 58px; display: grid; place-items: center;
  background: #fff; color: var(--navy); border-radius: 17px;
  font: 800 30px/1 Georgia, serif; box-shadow: 0 8px 22px rgba(0,0,0,.2);
}
.eyebrow { margin: 0 0 5px; font-size: 11px; font-weight: 800; letter-spacing: .13em; opacity: .7; }
h1 { margin: 0; font: 700 clamp(22px, 3vw, 32px)/1.1 Georgia, serif; }

.hero-stats { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.stat-pill { padding: 9px 13px; border: 1px solid rgba(255,255,255,.22); border-radius: 12px; background: rgba(255,255,255,.08); }
.stat-pill strong { display: block; font-size: 16px; }
.stat-pill span { font-size: 11px; opacity: .72; }

.layout { max-width: 1680px; margin: 0 auto; display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.sidebar {
  height: 100vh; padding: 30px 22px;
  background: #fff; border-right: 1px solid var(--line); position: sticky; top: 0; align-self: start;
  overflow-y: auto; scrollbar-color: #aab4c2 transparent; scrollbar-width: thin;
}
.sidebar-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; font-weight: 800; }
.text-button { border: 0; background: none; color: var(--blue); cursor: pointer; font-size: 12px; font-weight: 700; }
.course-nav { display: grid; gap: 7px; }
.course-button {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  width: 100%; padding: 11px 12px; border: 1px solid transparent; border-radius: 11px;
  background: transparent; color: #3e4a5c; text-align: left; cursor: pointer;
}
.course-button:hover { background: #f5f7fa; }
.course-button.active { color: var(--blue); background: var(--blue-soft); border-color: #ccdcfb; font-weight: 750; }
.course-button small { font-size: 11px; color: #8992a3; }
.category-heading {
  display: flex; justify-content: space-between; align-items: center;
  margin: 28px 0 10px; padding-top: 20px; border-top: 1px solid var(--line); font-weight: 800;
}
.category-tree { margin: 0 -8px; border-top: 1px solid #edf0f4; }
.tree-node { min-width: 0; }
.tree-row {
  width: 100%; min-height: 45px; display: grid; grid-template-columns: minmax(0, 1fr) auto 18px;
  align-items: center; gap: 7px; padding: 9px 5px 9px calc(9px + var(--depth, 0) * 15px);
  border: 0; border-bottom: 1px solid #edf0f4; background: transparent; color: var(--ink);
  text-align: left; cursor: pointer;
}
.tree-row:hover { background: #f6f8fb; }
.tree-row.active { background: var(--blue-soft); color: #1758ad; box-shadow: inset 3px 0 var(--blue); }
.tree-label { overflow: hidden; text-overflow: ellipsis; font-size: 12px; font-weight: 680; line-height: 1.35; }
.tree-course > .tree-row .tree-label { font-size: 13px; font-weight: 800; }
.tree-count { min-width: 23px; color: #49709d; font-size: 10px; font-weight: 800; text-align: right; }
.tree-chevron { color: #536174; font-size: 15px; line-height: 1; transition: transform .16s; }
.tree-row.open .tree-chevron { transform: rotate(90deg); }
.tree-row:not(.has-children) .tree-chevron { visibility: hidden; }
.field-label { display: block; margin: 28px 0 9px; font-size: 12px; font-weight: 800; }
select { width: 100%; padding: 11px 32px 11px 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; }
.legend { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.legend p { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-video { background: var(--video); }
.dot-pdf { background: var(--pdf); }

.content { min-width: 0; padding: 28px clamp(18px, 3vw, 44px) 60px; }
.toolbar {
  display: grid; grid-template-columns: minmax(260px, 1fr) auto auto; align-items: center; gap: 14px;
  padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: var(--shadow);
}
.search-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; }
.search-wrap:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(41,103,215,.1); }
.search-wrap svg { width: 19px; fill: none; stroke: #7a8494; stroke-width: 1.8; }
.search-wrap input { width: 100%; min-width: 0; padding: 11px 0; border: 0; outline: 0; }
kbd { padding: 2px 7px; border: 1px solid var(--line); border-radius: 5px; color: #8992a3; background: #f7f8fa; font-size: 11px; }
.type-tabs { display: flex; padding: 4px; background: #f0f3f7; border-radius: 10px; }
.type-tab { padding: 8px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 700; }
.type-tab.active { background: #fff; color: var(--navy); box-shadow: 0 2px 7px rgba(16,35,63,.1); }
.unique-toggle { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; cursor: pointer; }
.unique-toggle input { accent-color: var(--blue); }

.result-bar { display: flex; justify-content: space-between; align-items: end; gap: 20px; padding: 34px 3px 18px; }
.result-bar h2 { margin: 0; font: 700 25px/1.2 Georgia, serif; }
#result-count { margin: 0; color: var(--muted); font-size: 13px; }

.catalog { display: grid; gap: 14px; }
.folder {
  overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 4px 15px rgba(16,35,63,.035);
}
.folder summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 16px 18px; cursor: pointer; user-select: none; }
.folder summary::-webkit-details-marker { display: none; }
.folder summary::before { content: "›"; color: #8b95a6; font-size: 23px; line-height: 1; transition: transform .18s; }
.folder[open] summary::before { transform: rotate(90deg); }
.folder-icon { width: 34px; height: 29px; display: grid; place-items: center; border-radius: 8px; background: #f2f5f9; color: var(--navy-2); }
.folder-title { min-width: 0; flex: 1; }
.folder-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.folder-title span { color: var(--muted); font-size: 11px; }
.folder-count { color: var(--muted); font-size: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(285px, 1fr)); gap: 11px; padding: 0 14px 14px; }
.card { display: flex; flex-direction: column; min-height: 170px; padding: 16px; border: 1px solid #e5e9ef; border-radius: 12px; background: #fafbfc; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.type-badge, .repeat-badge, .offline-badge { padding: 4px 7px; border-radius: 6px; font-size: 9px; font-weight: 850; letter-spacing: .08em; }
.type-video { color: #1758ad; background: #e5efff; }
.type-pdf { color: #a82f2f; background: #ffe8e8; }
.repeat-badge { color: #735515; background: #fff2c6; letter-spacing: 0; }
.offline-badge { color: #777; background: #eceff3; letter-spacing: 0; }
.card h3 { margin: 13px 0 7px; font-size: 14px; line-height: 1.38; }
.card-detail { margin: 0 0 15px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.card-actions { display: flex; align-items: center; gap: 8px; margin-top: auto; }
.primary-button, .secondary-button, .icon-button {
  display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; cursor: pointer; text-decoration: none; font-weight: 750;
}
.primary-button { padding: 8px 12px; border: 1px solid var(--blue); background: var(--blue); color: #fff; font-size: 12px; }
.secondary-button { padding: 8px 12px; border: 1px solid var(--line); background: #fff; color: var(--navy); font-size: 12px; }
.icon-button { width: 33px; height: 33px; border: 1px solid var(--line); background: #fff; color: var(--muted); }
.disabled-button { pointer-events: none; opacity: .5; }
.empty-state { padding: 70px 20px; text-align: center; color: var(--muted); }
.empty-state div { font-size: 46px; }
.empty-state h2 { color: var(--ink); }

.player-dialog { width: min(900px, calc(100vw - 30px)); padding: 0; border: 0; border-radius: 18px; color: var(--ink); box-shadow: 0 30px 100px rgba(0,0,0,.35); }
.player-dialog::backdrop { background: rgba(8,18,32,.76); backdrop-filter: blur(4px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 20px 22px; }
.dialog-head h2 { margin: 0; font: 700 21px/1.2 Georgia, serif; }
.close-button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: #eef1f5; color: var(--ink); cursor: pointer; font-size: 25px; }
.video-frame { position: relative; min-height: 360px; display: grid; place-items: center; background: #07101d; }
.video-frame video { width: 100%; max-height: 68vh; background: #07101d; }
.video-frame p { position: absolute; color: rgba(255,255,255,.75); pointer-events: none; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px 20px; }

@media (max-width: 980px) {
  .hero { align-items: flex-start; flex-direction: column; }
  .hero-stats { justify-content: flex-start; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { height: auto; min-height: 0; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .course-nav { display: flex; overflow-x: auto; padding-bottom: 5px; }
  .course-button { min-width: 190px; }
  .legend { display: none; }
  .field-label { margin-top: 18px; }
  .category-tree { max-height: 460px; overflow-y: auto; }
}

@media (max-width: 700px) {
  .hero { padding: 20px; }
  .layout { display: block; }
  .sidebar { padding: 20px 16px; }
  .content { padding: 18px 13px 50px; }
  .toolbar { grid-template-columns: 1fr; }
  .type-tabs { justify-content: stretch; }
  .type-tab { flex: 1; }
  .unique-toggle { justify-content: center; padding: 4px; }
  .result-bar { align-items: flex-start; flex-direction: column; }
  .cards { grid-template-columns: 1fr; }
  .video-frame { min-height: 220px; }
  kbd { display: none; }
}
