:root {
  --bg: #f5f3ff;
  --bg-soft: #fbfaff;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-solid: #ffffff;
  --panel-strong: #ffffff;
  --line: rgba(120, 106, 255, 0.14);
  --line-strong: rgba(120, 106, 255, 0.22);
  --text: #101114;
  --muted: #60646f;
  --accent: #7a66ff;
  --accent-2: #a799ff;
  --accent-3: #efeaff;
  --shadow: 0 20px 60px rgba(23, 18, 67, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --sidebar-width: 310px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(122, 102, 255, 0.12), transparent 28%),
    radial-gradient(circle at bottom left, rgba(167, 153, 255, 0.12), transparent 24%),
    linear-gradient(180deg, #f8f7ff 0%, #f4f2ff 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
video {
  max-width: 100%;
  display: block;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
  overflow: auto;
}

.sidebar.is-collapsed {
  width: 92px;
}

.sidebar__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  text-align: left;
}

.brand__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), #5e4af4);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: 0 12px 24px rgba(122, 102, 255, 0.28);
}

.brand__text {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
  max-width: 140px;
}

.sidebar__content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar__label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.tree-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tree-node {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 18px;
  padding: 11px 12px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.tree-node:hover {
  background: rgba(255, 255, 255, 0.8);
  border-color: var(--line);
  transform: translateY(-1px);
}

.tree-node.is-active {
  background: #fff;
  border-color: rgba(122, 102, 255, 0.25);
  box-shadow: 0 10px 24px rgba(122, 102, 255, 0.08);
}

.tree-node__cover {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  object-fit: cover;
  flex: none;
  background: #ece7ff;
}

.tree-node__meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tree-node__title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-node__sub {
  font-size: 12px;
  color: var(--muted);
}

.tree-node--folder {
  background: rgba(255, 255, 255, 0.42);
}

.tree-node--lesson .tree-node__cover {
  object-fit: cover;
}

.tree-node--locked {
  opacity: 0.54;
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.eyebrow {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 6px;
}

.page-title {
  margin: 0;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.search input {
  width: min(340px, 45vw);
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.84);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search input:focus {
  border-color: rgba(122, 102, 255, 0.34);
  box-shadow: 0 0 0 4px rgba(122, 102, 255, 0.12);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  box-shadow: 0 8px 20px rgba(30, 20, 80, 0.04);
}

.icon-btn span {
  font-size: 18px;
  line-height: 1;
}

.hero {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, rgba(122, 102, 255, 0.11), rgba(255, 255, 255, 0.9)),
    rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.hero__stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stat {
  min-width: 120px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(122, 102, 255, 0.12);
}

.stat__value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.stat__label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.hero__text {
  max-width: 560px;
}

.hero__title {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.15;
}

.hero__desc {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.content {
  display: grid;
  gap: 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 40px rgba(35, 22, 80, 0.06);
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: rgba(122, 102, 255, 0.24);
  box-shadow: 0 18px 44px rgba(35, 22, 80, 0.1);
}

.card__cover {
  aspect-ratio: 1.45 / 0.92;
  width: 100%;
  background: linear-gradient(135deg, rgba(122, 102, 255, 0.18), rgba(167, 153, 255, 0.07));
  position: relative;
}

.card__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card__badge {
  position: absolute;
  top: 14px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(20, 14, 66, 0.08);
}

.card__badge--locked {
  background: rgba(255, 240, 240, 0.92);
  color: #b33a3a;
}

.card__body {
  padding: 16px;
  display: grid;
  gap: 10px;
}

.card__title {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.card__meta {
  color: var(--muted);
  font-size: 13px;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.breadcrumbs a,
.breadcrumbs span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.breadcrumbs a::after,
.breadcrumbs span::after {
  content: "/";
  color: #b9b1e8;
}

.breadcrumbs a:last-child::after,
.breadcrumbs span:last-child::after {
  content: "";
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.panel__header {
  padding: 18px 18px 0;
}

.panel__title {
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.panel__subtitle {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.page-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 18px 18px 0;
}

.tab-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 600;
}

.tab-btn.is-active {
  background: linear-gradient(135deg, var(--accent), #5f4bf7);
  color: #fff;
  border-color: transparent;
}

.page-content {
  padding: 18px;
  display: grid;
  gap: 18px;
}

.block {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(122, 102, 255, 0.12);
  background: #fff;
}

.block + .block {
  margin-top: 2px;
}

.block h1,
.block h2,
.block h3,
.block h4 {
  margin: 0 0 10px;
  line-height: 1.15;
}

.block p {
  margin: 0;
  color: #16161b;
  line-height: 1.7;
}

.block ul,
.block ol {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.block li {
  line-height: 1.6;
}

.block hr {
  border: 0;
  border-top: 1px solid rgba(122, 102, 255, 0.14);
  margin: 4px 0;
}

.media-card {
  display: grid;
  gap: 12px;
}

.media-card__caption {
  font-size: 13px;
  color: var(--muted);
}

.media-card video {
  width: 100%;
  border-radius: 18px;
  background: #000;
}

.pdf-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pdf-card__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(122, 102, 255, 0.11), rgba(167, 153, 255, 0.06));
  border: 1px solid rgba(122, 102, 255, 0.14);
  color: #4737cc;
  font-weight: 700;
}

.exercise-list {
  display: grid;
  gap: 10px;
}

.exercise-item {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(247, 245, 255, 0.92);
  border: 1px solid rgba(122, 102, 255, 0.12);
}

.exercise-item__name {
  font-weight: 700;
  margin: 0 0 4px;
}

.exercise-item__meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.lesson-layout {
  display: grid;
  gap: 18px;
}

.lesson-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.lesson-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.lesson-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pill-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 600;
}

.pill-btn.is-active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.empty-state,
.loading-state,
.error-state {
  padding: 34px 22px;
  border: 1px dashed rgba(122, 102, 255, 0.24);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  line-height: 1.7;
}

.muted {
  color: var(--muted);
}

.mobile-nav {
  display: none;
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, 330px);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 20;
    box-shadow: 30px 0 80px rgba(33, 18, 90, 0.12);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .main {
    padding: 16px;
  }

  .mobile-nav {
    position: sticky;
    bottom: 12px;
    display: flex;
    gap: 10px;
    padding: 0 16px 16px;
    z-index: 10;
  }

  .mobile-nav__btn {
    flex: 1;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    padding: 12px 16px;
    font-weight: 700;
    box-shadow: var(--shadow);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .search input {
    width: min(100%, 100vw - 32px);
  }
}
