:root {
  --brand: #2ea5da;
  --brand-dark: #1f86b5;
  --brand-soft: #eaf6fc;
  --bg: #f6f7fc;
  --card: #ffffff;
  --text: #15181f;
  --muted: #6b7280;
  --line: #e7e9f0;
  --danger: #e5484d;
  --ok: #2ea44f;
  --gold: #d9a441;
  --shadow: 0 6px 22px rgba(20, 30, 60, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; }

/* ===================== Layout ===================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.3px;
}
.topbar .brand .logo {
  width: 34px; height: 34px;
  border-radius: 9px;
  object-fit: cover;
  display: block;
  box-shadow: 0 1px 4px rgba(20, 30, 60, 0.18);
}
.topbar .spacer { flex: 1; }
.topbar .user-chip {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 14px;
}
.container { max-width: 1080px; margin: 0 auto; padding: 22px 20px 60px; }

.back-link {
  display: inline-flex; align-items: center; gap: 9px;
  color: var(--text); font-size: 18px; font-weight: 700;
  margin-bottom: 20px; padding: 10px 16px 10px 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); box-shadow: var(--shadow);
  cursor: pointer; transition: color .12s, border-color .12s, background .12s;
}
.back-link:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }

/* ===================== Buttons ===================== */
.btn {
  border: none; border-radius: 11px;
  padding: 12px 18px; font-size: 15px; font-weight: 700;
  background: var(--brand); color: #fff;
  transition: background .15s, transform .05s, opacity .15s;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.subtle { background: #eef0f6; color: var(--text); }
.btn.subtle:hover { background: #e4e7ef; }
.btn.sm { padding: 8px 14px; font-size: 13px; border-radius: 9px; }

/* ===================== Login ===================== */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
.auth-hero {
  background: linear-gradient(150deg, var(--brand) 0%, #1b6f97 100%);
  color: #fff;
  padding: 60px 56px;
  display: flex; flex-direction: column; justify-content: center;
}
.auth-hero .logo-lg {
  width: 72px; height: 72px; border-radius: 20px;
  object-fit: cover; display: block; margin-bottom: 26px;
  box-shadow: 0 8px 24px rgba(0,0,0,.28);
}
.auth-hero h1 { font-size: 38px; line-height: 1.12; margin: 0 0 16px; letter-spacing: -1px; }
.auth-hero p { font-size: 17px; opacity: .9; max-width: 420px; line-height: 1.5; margin: 0 0 28px; }
.auth-hero ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.auth-hero li { display: flex; align-items: center; gap: 11px; font-size: 15px; opacity: .95; }
.auth-hero li .tick { width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,.22); display: grid; place-items: center; font-size: 13px; }

.auth-panel { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { margin: 0 0 6px; font-size: 26px; letter-spacing: -0.5px; }
.auth-card .sub { color: var(--muted); margin: 0 0 26px; font-size: 15px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 7px; }
.field input {
  width: 100%; padding: 13px 14px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 11px; background: #fbfcfe;
  transition: border .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(46,165,218,.15); background: #fff; }
.form-error {
  background: #fdecec; color: var(--danger); border: 1px solid #f6c9ca;
  padding: 10px 13px; border-radius: 10px; font-size: 14px; margin-bottom: 16px;
}
.hint-box {
  margin-top: 22px; padding: 13px 14px; border: 1px dashed var(--line);
  border-radius: 11px; background: #fafbff; font-size: 13px; color: var(--muted); line-height: 1.55;
}
.hint-box b { color: var(--text); }

/* Логин/тіркелу арасындағы сілтеме */
.auth-alt { margin-top: 18px; font-size: 14px; color: var(--muted); text-align: center; }
.auth-alt a { color: var(--brand); font-weight: 700; }
.auth-alt a:hover { color: var(--brand-dark); }
.user-chip:hover { color: var(--brand); }

/* Тіркелу қадам индикаторы */
.stepper { display: flex; gap: 8px; margin-bottom: 22px; }
.step-dot { height: 6px; flex: 1; border-radius: 999px; background: var(--line); transition: background .2s; }
.step-dot.active { background: var(--brand); }
.step-dot.done { background: var(--brand-dark); }

/* Профиль */
.container.narrow { max-width: 640px; }
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }
.field-note { font-size: 12px; color: var(--gold); margin-top: 6px; }
.select.wide { width: 100%; }
.profile-card { padding: 26px; }
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.profile-ava {
  width: 60px; height: 60px; flex: none; border-radius: 16px; background: var(--brand);
  color: #fff; display: grid; place-items: center; font-size: 26px; font-weight: 800;
}
.profile-name { font-size: 20px; font-weight: 800; }
.profile-phone { color: var(--muted); font-size: 14px; margin-top: 3px; }

/* ===================== Filters bar ===================== */
.page-title { font-size: 26px; font-weight: 800; letter-spacing: -0.6px; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 22px; font-size: 15px; }

.filters {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 22px;
}
.filters .row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.search-box { position: relative; flex: 1; min-width: 220px; }
.search-box input {
  width: 100%; padding: 12px 14px 12px 40px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 11px; background: #fbfcfe;
}
.search-box input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(46,165,218,.13); }
.search-box .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.select {
  padding: 11px 13px; font-size: 14px; border: 1px solid var(--line);
  border-radius: 11px; background: #fbfcfe; color: var(--text); min-width: 160px;
}
.select:focus { outline: none; border-color: var(--brand); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.chip {
  padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); background: #fff; color: var(--muted); transition: all .12s;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chips-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin: 16px 0 8px; }

.results-meta { color: var(--muted); font-size: 14px; margin-bottom: 14px; }

/* ===================== Course grid ===================== */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.course-card {
  position: relative; border-radius: var(--radius); overflow: hidden;
  min-height: 192px; box-shadow: var(--shadow); cursor: pointer;
  display: flex; flex-direction: column; justify-content: flex-end;
  background: var(--brand); color: #fff; transition: transform .12s, box-shadow .12s;
}
.course-card:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(20,30,60,.16); }
.course-card .bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .9; }
.course-card .overlay { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.05) 35%, rgba(0,0,0,.62) 100%); }
.course-card .content { position: relative; padding: 20px; }
.course-card .ctitle { font-size: 23px; font-weight: 700; line-height: 1.22; margin: 0 0 11px; text-shadow: 0 1px 6px rgba(0,0,0,.3); }
.course-card .cauthor { font-size: 14px; opacity: .9; line-height: 1.45; }
.course-card .cauthor span { opacity: .7; }
.badges { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; align-items: center; gap: 6px; }
.badge {
  font-size: 12px; font-weight: 800; padding: 6px 11px; border-radius: 999px;
  backdrop-filter: blur(4px); letter-spacing: .3px;
}
.badge.free { background: rgba(46,164,79,.92); color: #fff; }
.badge.vip { background: rgba(217,164,65,.95); color: #fff; }
.badge.cat { background: rgba(255,255,255,.85); color: #1f2937; margin-left: auto; }
.lock-badge {
  flex: none; width: 30px; height: 30px;
  border-radius: 50%; background: rgba(0,0,0,.5); display: grid; place-items: center;
  color: #fff; font-size: 14px;
}

/* ===================== Course detail ===================== */
.detail-head {
  position: relative; border-radius: 18px; overflow: hidden; color: #fff;
  padding: 34px 30px; margin-bottom: 24px; box-shadow: var(--shadow); background: var(--brand);
  min-height: 180px; display: flex; flex-direction: column; justify-content: flex-end;
}
.detail-head .bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .55; }
.detail-head .overlay { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.25), rgba(0,0,0,.65)); }
.detail-head .inner { position: relative; }
.detail-head h1 { font-size: 30px; margin: 0 0 10px; letter-spacing: -0.6px; text-shadow: 0 2px 10px rgba(0,0,0,.35); }
.detail-head .meta { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; opacity: .92; }
.detail-head .meta b { font-weight: 700; }

.detail-cols { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
.section-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.section-card h3 { margin: 0 0 14px; font-size: 17px; }
.section-card .desc { color: #374151; line-height: 1.65; white-space: pre-wrap; font-size: 15px; }
.section-card .desc a, .inline-link { color: var(--brand); text-decoration: underline; word-break: break-word; font-weight: 600; }
.section-card .desc a:hover, .inline-link:hover { color: var(--brand-dark); }

.lesson-list { display: flex; flex-direction: column; }
.lesson-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 12px;
  border-radius: 11px; transition: background .12s; cursor: pointer;
}
.lesson-row:hover { background: var(--brand-soft); }
.lesson-row.locked { cursor: not-allowed; opacity: .65; }
.lesson-row.locked:hover { background: #f6f7fb; }
.lesson-row + .lesson-row { border-top: 1px solid var(--line); }
.lesson-num {
  width: 34px; height: 34px; flex: none; border-radius: 9px; background: #eef2f7;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; color: var(--muted);
}
.lesson-row.done .lesson-num { background: var(--ok); color: #fff; }
.lesson-info { flex: 1; min-width: 0; }
.lesson-info .lt { font-weight: 600; font-size: 15px; }
.lesson-info .ls { font-size: 12px; color: var(--muted); margin-top: 2px; }
.lesson-row .state { color: var(--muted); }

.aside-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; position: sticky; top: 86px; }
.aside-card .price { font-size: 26px; font-weight: 800; margin-bottom: 10px; color: var(--gold); }
.aside-card .price small { font-size: 13px; color: var(--muted); font-weight: 600; }
.aside-note { color: var(--muted); font-size: 14px; line-height: 1.55; margin: 0 0 16px; }
.access-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; padding: 7px 12px; border-radius: 999px; margin-bottom: 16px; }
.access-pill.ok { background: #e7f6ec; color: var(--ok); }
.access-pill.no { background: #fdecec; color: var(--danger); }

/* ===================== Lesson reading ===================== */
.reader { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }
.video-wrap {
  position: relative; width: 100%; aspect-ratio: 16/9; background: #000;
  border-radius: 16px; overflow: hidden; box-shadow: var(--shadow);
}
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-missing { display: grid; place-items: center; height: 100%; color: #cbd5e1; gap: 8px; }

/* Су белгісі (қозғалмалы, ізделетін) */
.video-wrap .vwm {
  position: absolute; z-index: 6; pointer-events: none; user-select: none;
  color: rgba(255, 255, 255, 0.5); font-size: 13px; font-weight: 700;
  letter-spacing: 0.5px; white-space: nowrap; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.75);
  transition: top 1.1s ease, left 1.1s ease, opacity 1.1s ease;
}
/* Қорғалған (Bunny) толық экран батырмасы */
.video-wrap .vfs-btn {
  position: absolute; z-index: 7; top: 10px; right: 10px;
  width: 34px; height: 34px; border: none; border-radius: 8px;
  background: rgba(0, 0, 0, 0.45); color: #fff; font-size: 16px; cursor: pointer;
  display: grid; place-items: center; opacity: 0; transition: opacity 0.2s;
}
.video-wrap:hover .vfs-btn { opacity: 1; }
.video-wrap:fullscreen { aspect-ratio: auto; width: 100vw; height: 100vh; border-radius: 0; }
.video-wrap:fullscreen iframe { border-radius: 0; }
.lesson-title { font-size: 25px; font-weight: 800; letter-spacing: -0.5px; margin: 22px 0 6px; }
.lesson-course { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.pdf-btn { display: inline-flex; align-items: center; gap: 9px; }
.next-list { display: flex; flex-direction: column; gap: 2px; max-height: 68vh; overflow-y: auto; margin: 0 -8px; padding: 0 4px; }
.aside-card .lesson-row { padding: 11px 10px; }
.aside-card .lesson-row + .lesson-row { border-top: 1px solid var(--line); }
.lesson-row.current { background: var(--brand-soft); }
.lesson-row.current .lesson-num { background: var(--brand); color: #fff; }
.lesson-row.current .lt { color: var(--brand-dark); }
.lesson-row.current { cursor: default; }

/* ===================== States ===================== */
.empty, .center-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-size: 42px; margin-bottom: 10px; }
.spinner {
  width: 34px; height: 34px; border: 3px solid var(--brand-soft);
  border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg,#eef0f5 25%,#f6f7fb 37%,#eef0f5 63%); background-size: 400% 100%; animation: sk 1.2s ease infinite; border-radius: var(--radius); }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.sk-card { min-height: 176px; }

/* ===================== Toast ===================== */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #15181f; color: #fff; padding: 13px 20px; border-radius: 12px;
  font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  z-index: 100; max-width: 90vw;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ===================== Responsive ===================== */
@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .detail-cols, .reader { grid-template-columns: 1fr; }
  .aside-card { position: static; }
}
