:root {
  color-scheme: light dark;
  --page: #f2f6ff;
  --surface: #fdfefe;
  --surface-soft: #eaf1ff;
  --surface-strong: #dce9ff;
  --ink: #10204c;
  --muted: #617096;
  --line: #d6e0f4;
  --brand: #172d91;
  --brand-strong: #10236f;
  --brand-bright: #167fe8;
  --brand-cyan: #27aadd;
  --player: #07132f;
  --shadow: 0 18px 48px rgba(20, 47, 126, 0.12);
  --shadow-soft: 0 8px 26px rgba(20, 47, 126, 0.08);
  --radius-lg: 22px;
  --radius-md: 15px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(39, 170, 221, 0.12), transparent 26rem),
    linear-gradient(180deg, #f8faff 0, var(--page) 38rem);
}
body.dialog-open { overflow: hidden; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid rgba(39, 170, 221, 0.58);
  outline-offset: 3px;
}
[hidden] { display: none !important; }

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid rgba(214, 224, 244, 0.9);
  background: rgba(253, 254, 254, 0.9);
  box-shadow: 0 5px 20px rgba(20, 47, 126, 0.04);
  backdrop-filter: blur(18px);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 40px));
  min-height: 82px;
  margin: 0 auto;
}
.brand-lockup { display: flex; align-items: center; gap: 22px; }
.brand { display: inline-flex; align-items: center; }
.brand-logo { display: block; width: 210px; height: auto; }
.brand-section {
  padding-left: 22px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
}
.back-button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--brand);
  background: var(--surface);
  cursor: pointer;
  font-weight: 700;
  transition: border-color 160ms ease, color 160ms ease, transform 160ms ease;
}
.back-button:hover { border-color: var(--brand-bright); color: var(--brand-bright); transform: translateY(-1px); }

main {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 42px 0 72px;
}
.catalog-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 46px;
  align-items: end;
  overflow: hidden;
  padding: 46px 50px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: var(--radius-lg);
  color: #f6f9ff;
  background:
    linear-gradient(112deg, rgba(39, 170, 221, 0.24), transparent 42%),
    linear-gradient(135deg, var(--brand-strong), var(--brand) 52%, #1b64cc);
  box-shadow: var(--shadow);
}
.catalog-hero::before {
  position: absolute;
  top: -92px;
  right: 31%;
  width: 210px;
  height: 210px;
  border: 34px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  content: "";
}
.catalog-hero::after {
  position: absolute;
  right: -55px;
  bottom: -86px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: rgba(39, 170, 221, 0.2);
  content: "";
}
.intro, .search-box { position: relative; z-index: 1; min-width: 0; }
.intro-label {
  margin: 0 0 14px;
  color: #7ee5ff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.18em;
}
.intro h1 {
  max-width: 650px;
  margin: 0;
  font-size: clamp(32px, 4.6vw, 58px);
  line-height: 1.08;
  letter-spacing: -0.04em;
}
.intro-summary {
  max-width: 620px;
  margin: 20px 0 0;
  color: rgba(246, 249, 255, 0.78);
  font-size: 16px;
  line-height: 1.8;
}
.search-box {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  background: rgba(7, 19, 47, 0.24);
}
.search-box span { color: rgba(246, 249, 255, 0.76); font-size: 13px; font-weight: 700; }
.search-box input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 11px;
  color: #10204c;
  background: #f8fbff;
}
.search-box input::placeholder { color: #7a87a9; }

.status-panel, .empty-state {
  margin-top: 24px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--muted);
  background: var(--surface);
}
.skeleton { display: block; width: 42%; height: 12px; margin: 7px 0; border-radius: 6px; background: var(--surface-strong); }
.skeleton.wide { width: 72%; }
.empty-state strong { color: var(--ink); }
.empty-state p { margin: 8px 0 0; }

.course-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-top: 24px;
}
.course-card {
  display: grid;
  grid-template-columns: minmax(210px, 46%) minmax(0, 1fr);
  min-height: 276px;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  color: var(--ink);
  text-align: left;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}
.course-card:hover {
  border-color: rgba(22, 127, 232, 0.55);
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}
.course-card img {
  width: 100%;
  height: 100%;
  min-height: 276px;
  object-fit: contain;
  background: #071b4c;
}
.course-card-content { display: flex; min-width: 0; flex-direction: column; align-items: flex-start; padding: 28px 26px 26px; }
.course-card-meta {
  margin-bottom: 18px;
  padding: 6px 9px;
  border-radius: 8px;
  color: var(--brand);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 800;
}
.course-card h2 { max-width: 100%; margin: 0; overflow-wrap: anywhere; font-size: 22px; line-height: 1.35; letter-spacing: -0.02em; }
.course-card p { max-width: 100%; margin: 14px 0 24px; overflow-wrap: anywhere; color: var(--muted); font-size: 14px; line-height: 1.75; }
.course-card-action { margin-top: auto; color: var(--brand-bright); font-size: 14px; font-weight: 800; }

.player-view { display: grid; gap: 24px; }
.player-shell { overflow: hidden; border-radius: var(--radius-lg); background: var(--player); box-shadow: var(--shadow); }
.video-frame { position: relative; aspect-ratio: 16 / 9; background: #061027; }
.video-frame video { display: block; width: 100%; height: 100%; object-fit: contain; background: #061027; }
.video-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  color: #edf5ff;
  text-align: center;
  background: radial-gradient(circle at 50% 42%, rgba(39, 170, 221, 0.14), transparent 22rem), #07132f;
  pointer-events: none;
}
.video-placeholder span { color: #9bb6d8; font-size: 14px; }
.now-playing {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 68px;
  padding: 14px 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  color: #f0f6ff;
}
.now-playing > span, .now-playing a { color: #63d8f7; font-size: 13px; }

.course-heading {
  display: grid;
  grid-template-columns: minmax(210px, 260px) minmax(0, 1fr);
  gap: 34px;
  align-items: center;
  overflow: hidden;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.course-heading img {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 13px;
  object-fit: contain;
  background: #071b4c;
}
.course-heading-copy { min-width: 0; }
.course-heading h1 { margin: 0; font-size: clamp(28px, 4vw, 44px); line-height: 1.18; letter-spacing: -0.035em; }
.course-heading p { margin: 18px 0 0; color: var(--muted); line-height: 1.8; }

.lesson-section {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.lesson-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 26px 20px;
  border-bottom: 1px solid var(--line);
}
.lesson-section-header h2 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.lesson-section-header span {
  min-width: 56px;
  padding: 7px 10px;
  border-radius: 10px;
  color: var(--brand);
  text-align: center;
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 800;
}
.lesson-section .status-panel { margin: 20px; }
.lesson-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 18px;
  list-style: none;
  background: var(--surface-soft);
}
.lesson-list li { display: flex; min-width: 0; }
.lesson-button {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  min-width: 0;
  min-height: 82px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  text-align: left;
  background: var(--surface);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(20, 47, 126, 0.04);
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}
.lesson-button:hover {
  border-color: rgba(22, 127, 232, 0.5);
  color: var(--brand-bright);
  background: var(--surface);
  box-shadow: 0 9px 24px rgba(20, 47, 126, 0.1);
  transform: translateY(-2px);
}
.lesson-button:active { transform: translateY(0); }
.lesson-button.active {
  border-color: var(--brand);
  color: #f6f9ff;
  background: var(--brand);
  box-shadow: 0 10px 24px rgba(23, 45, 145, 0.22);
}
.lesson-index {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 11px;
  color: var(--brand);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.lesson-button.active .lesson-index { color: #f6f9ff; background: rgba(255, 255, 255, 0.16); }
.lesson-title {
  min-width: 0;
  overflow: hidden;
  font-size: 15px;
  font-weight: 750;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lesson-duration {
  min-width: 40px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.lesson-action {
  min-width: 48px;
  padding: 7px 9px;
  border-radius: 9px;
  color: var(--brand);
  text-align: center;
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.lesson-button.active .lesson-duration { color: rgba(246, 249, 255, 0.76); }
.lesson-button.active .lesson-action { color: var(--brand); background: #f6f9ff; }

.toast {
  position: fixed;
  z-index: 50;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100% - 40px));
  padding: 14px 18px;
  border-radius: 12px;
  color: #f6f9ff;
  background: var(--brand-strong);
  box-shadow: var(--shadow);
}

.password-overlay {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 11, 27, 0.68);
  backdrop-filter: blur(9px);
}
.password-dialog {
  position: relative;
  width: min(440px, 100%);
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 24px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(3, 12, 42, 0.34);
}
.password-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface-soft);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}
.password-icon { display: inline-block; margin-bottom: 18px; font-size: 28px; }
.password-label { margin: 0 0 8px; color: var(--brand-bright); font-size: 12px; font-weight: 800; letter-spacing: 0.14em; }
.password-dialog h2 { margin: 0; font-size: 30px; letter-spacing: -0.03em; }
.password-course { margin: 10px 0 24px; color: var(--muted); line-height: 1.6; }
.password-field { display: grid; gap: 9px; }
.password-field span { color: var(--muted); font-size: 13px; font-weight: 700; }
.password-field input {
  width: 100%;
  min-height: 52px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface);
}
.password-field input:focus { border-color: var(--brand-bright); }
.password-error { margin: 10px 0 0; color: #d93b4b; font-size: 13px; }
.password-submit {
  width: 100%;
  min-height: 52px;
  margin-top: 16px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-bright));
  cursor: pointer;
  font-weight: 800;
}
.password-submit:disabled { cursor: wait; opacity: 0.65; }
.password-help { margin: 18px 0 0; color: var(--muted); text-align: center; font-size: 12px; }

@media (max-width: 860px) {
  .catalog-hero { grid-template-columns: 1fr; gap: 30px; padding: 38px 34px; }
  .search-box { max-width: 520px; }
  .course-grid { grid-template-columns: 1fr; }
  .course-heading { grid-template-columns: 220px minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .header-inner, main { width: min(100% - 24px, 1180px); }
  .header-inner { min-height: 68px; }
  .brand-logo { width: 156px; }
  .brand-section { display: none; }
  .back-button { min-height: 38px; padding: 0 12px; font-size: 13px; }
  main { padding: 20px 0 44px; }
  .catalog-hero { gap: 24px; padding: 30px 22px 24px; border-radius: 18px; }
  .intro h1 { font-size: 36px; }
  .intro-summary { margin-top: 15px; font-size: 14px; }
  .search-box { padding: 14px; }
  .course-card { grid-template-columns: minmax(145px, 46%) minmax(0, 1fr); min-height: 210px; border-radius: 18px; }
  .course-card img { min-height: 210px; }
  .course-card-content { padding: 20px 18px; }
  .course-card-meta { margin-bottom: 12px; }
  .course-card h2 { font-size: 18px; }
  .course-card p {
    display: -webkit-box;
    overflow: hidden;
    margin: 10px 0 16px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }
  .player-view { gap: 16px; }
  .player-shell, .course-heading, .lesson-section { border-radius: 17px; }
  .now-playing { grid-template-columns: 1fr; gap: 6px; padding: 14px 16px; }
  .course-heading { grid-template-columns: 1fr; gap: 20px; padding: 20px; }
  .course-heading img { max-width: 260px; }
  .lesson-section-header { padding: 20px 18px 16px; }
  .lesson-list { grid-template-columns: 1fr; gap: 10px; padding: 12px; }
  .lesson-button { grid-template-columns: 40px minmax(0, 1fr) auto; min-height: 76px; gap: 12px; padding: 12px; }
  .lesson-duration { grid-column: 2; margin-top: -7px; }
  .lesson-action { grid-column: 3; grid-row: 1 / span 2; }
  .password-dialog { padding: 30px 22px 24px; border-radius: 20px; }
  .password-dialog h2 { font-size: 26px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #071126;
    --surface: #0d1933;
    --surface-soft: #13254a;
    --surface-strong: #18325c;
    --ink: #edf4ff;
    --muted: #a5b4d0;
    --line: #24375a;
    --brand: #2a63d5;
    --brand-strong: #132f86;
    --brand-bright: #51a7ff;
    --player: #040b1b;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
    --shadow-soft: 0 8px 26px rgba(0, 0, 0, 0.2);
  }
  body {
    background:
      radial-gradient(circle at 8% 0%, rgba(39, 170, 221, 0.13), transparent 26rem),
      linear-gradient(180deg, #0a1731 0, var(--page) 38rem);
  }
  .site-header { border-color: rgba(36, 55, 90, 0.9); background: rgba(7, 17, 38, 0.9); }
  .brand { padding: 6px 10px; border-radius: 10px; background: #f8faff; }
  .search-box input { color: #edf4ff; background: #0d1933; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
