/* ---------- Polin ---------- */
@font-face { font-family: "Polin"; src: url("fonts/Polin-Thin.otf") format("opentype"); font-weight: 100; font-display: swap; }
@font-face { font-family: "Polin"; src: url("fonts/Polin-Regular.otf") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Polin"; src: url("fonts/Polin-Medium.otf") format("opentype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Polin"; src: url("fonts/Polin-Bold.otf") format("opentype"); font-weight: 700; font-display: swap; }

:root {
  --navy: #0b1f3a;
  --navy-2: #13294b;
  --red: #c8102e;
  --red-soft: #fdecef;
  --gold: #e0a526;
  --green: #12805c;
  --green-soft: #e6f4ee;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #5d6a80;
  --line: #e2e7ef;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(11, 31, 58, .06), 0 6px 20px rgba(11, 31, 58, .06);
  --sidebar-w: 340px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Polin", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
.ltr { direction: ltr; unicode-bidi: isolate; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: var(--navy);
  color: #fff;
  border-bottom: 3px solid var(--red);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--red), #8e0b20);
  font-weight: 700; letter-spacing: .5px; font-size: 15px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.18);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 18px; font-weight: 700; }
.brand-text small { font-size: 12.5px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-progress { margin-inline-start: auto; display: flex; align-items: center; gap: 12px; }
.top-progress-label { font-size: 13px; opacity: .9; white-space: nowrap; }
.top-progress .bar { width: 180px; background: rgba(255,255,255,.15); }
.icon-btn {
  background: transparent; border: 0; color: inherit;
  width: 40px; height: 40px; border-radius: 10px;
  display: none; place-items: center;
}
.icon-btn:hover { background: rgba(255,255,255,.1); }

.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--gold); border-radius: inherit; transition: width .4s ease; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--card);
  border-inline-end: 1px solid var(--line);
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  display: flex; flex-direction: column;
}
.sidebar-head { padding: 14px; border-bottom: 1px solid var(--line); }
.search {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 14px; background: var(--bg);
}
.search:focus { outline: 2px solid var(--navy-2); outline-offset: -1px; background: #fff; }
.nav { overflow-y: auto; flex: 1; padding: 8px 0 24px; }

.mod { border-bottom: 1px solid var(--line); }
.mod-head {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; background: none; border: 0; text-align: start;
}
.mod-head:hover { background: var(--bg); }
.mod-num {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--navy); color: #fff; font-weight: 700; font-size: 14px;
}
.mod.done .mod-num { background: var(--green); }
.mod-info { flex: 1; min-width: 0; }
.mod-title { font-weight: 700; font-size: 15px; display: block; }
.mod-meta { font-size: 12.5px; color: var(--muted); }
.chev { transition: transform .2s; color: var(--muted); flex-shrink: 0; }
.mod.open .chev { transform: rotate(180deg); }
.mod-body { display: none; padding: 0 0 10px; }
.mod.open .mod-body { display: block; }

.unit {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px 8px 24px; padding-inline-start: 22px;
  font-size: 14px; color: var(--text);
  border-inline-start: 3px solid transparent;
}
.unit:hover { background: var(--bg); }
.unit.active { background: #eef2f9; border-inline-start-color: var(--red); font-weight: 500; }
.unit.part { padding-inline-start: 44px; font-size: 13.5px; color: var(--muted); }
.unit.part.active { color: var(--text); }
.unit-label { flex: 1; min-width: 0; }
.unit-num { display: inline-block; min-width: 30px; color: var(--muted); font-size: 12.5px; margin-left: 6px; font-variant-numeric: tabular-nums; }
.lesson-group-title {
  padding: 8px 16px; padding-inline-start: 22px;
  font-size: 14px; font-weight: 500; display: flex; gap: 10px; align-items: center;
}
.check {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid #c3cbd8; display: grid; place-items: center; background: #fff;
}
.check.on { background: var(--green); border-color: var(--green); }
.check.on::after {
  content: ""; width: 9px; height: 5px; margin-top: -2px;
  border: solid #fff; border-width: 0 0 2px 2px; transform: rotate(-45deg);
}
.type-icon { width: 20px; height: 20px; flex-shrink: 0; color: var(--muted); display: grid; place-items: center; }
.dur { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; padding: 32px clamp(16px, 4vw, 48px) 64px; outline: none; }
.wrap { max-width: 980px; margin: 0 auto; }

.crumbs { font-size: 13.5px; color: var(--muted); margin-bottom: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs a:hover { color: var(--red); }
h1 { font-size: clamp(24px, 3.2vw, 32px); line-height: 1.25; margin: 0 0 6px; font-weight: 700; }
h2 { font-size: 20px; margin: 0 0 14px; font-weight: 700; }
.lead { color: var(--muted); margin: 0 0 24px; }
.part-pill {
  display: inline-block; font-size: 13px; font-weight: 500;
  background: var(--red-soft); color: var(--red);
  padding: 2px 10px; border-radius: 99px; vertical-align: middle; margin-inline-start: 8px;
}

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 20px; }

.video {
  position: relative; aspect-ratio: 16 / 9; width: 100%;
  border-radius: var(--radius); overflow: hidden; background: var(--navy); margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.video iframe, .video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-empty {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: #fff;
  background:
    radial-gradient(circle at 20% 20%, rgba(200,16,46,.35), transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(224,165,38,.18), transparent 50%),
    var(--navy);
}
.play {
  width: 76px; height: 76px; border-radius: 50%; margin: 0 auto 14px;
  display: grid; place-items: center; background: rgba(255,255,255,.12);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.3);
}
.video-empty p { margin: 0; opacity: .8; font-size: 15px; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-weight: 500; font-size: 15px;
}
.btn:hover { border-color: #c3cbd8; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: #a80d26; border-color: #a80d26; }
.btn-done { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.btn[disabled] { opacity: .4; cursor: default; }
.nav-btns { display: flex; gap: 10px; }

.summary { white-space: pre-line; }
textarea {
  width: 100%; min-height: 140px; resize: vertical;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 15px; background: #fbfcfe;
}
textarea:focus { outline: 2px solid var(--navy-2); outline-offset: -1px; background: #fff; }
.saved { font-size: 12.5px; color: var(--green); min-height: 18px; margin-top: 6px; }

.task { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.task:last-child { border-bottom: 0; }
.task input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--green); flex-shrink: 0; }
.task.checked span { color: var(--muted); text-decoration: line-through; }

.file { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
.file:hover { border-color: var(--navy-2); }
.file-icon { width: 42px; height: 42px; border-radius: 10px; background: var(--red-soft); color: var(--red); display: grid; place-items: center; flex-shrink: 0; }
.file-name { flex: 1; font-weight: 500; }
.empty { color: var(--muted); text-align: center; padding: 20px; border: 1px dashed var(--line); border-radius: 12px; margin: 0; }

/* ---------- Home ---------- */
.hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 70%, #1d3a66 100%);
  color: #fff; border-radius: 18px; padding: clamp(24px, 4vw, 40px);
  position: relative; overflow: hidden; margin-bottom: 28px;
}
.hero::after {
  content: ""; position: absolute; inset-inline-end: -60px; top: -60px; width: 260px; height: 260px;
  border-radius: 50%; background: radial-gradient(circle, rgba(200,16,46,.45), transparent 70%);
}
.hero h1 { color: #fff; }
.hero p { opacity: .85; margin: 0 0 22px; max-width: 560px; }
.hero-stats { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 24px; position: relative; z-index: 1; }
.hero-stats b { display: block; font-size: 28px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero-stats span { font-size: 13px; opacity: .75; }
.hero .btn-primary { position: relative; z-index: 1; }

.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.mcard {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; display: flex; flex-direction: column; gap: 10px;
  border: 1px solid transparent; transition: border-color .15s, transform .15s;
}
.mcard:hover { border-color: var(--navy-2); transform: translateY(-2px); }
.mcard-top { display: flex; justify-content: space-between; align-items: center; }
.mcard-kicker { font-size: 12.5px; font-weight: 700; color: var(--red); letter-spacing: .3px; }
.mcard h3 { margin: 0; font-size: 18px; }
.mcard-meta { font-size: 13px; color: var(--muted); }
.mcard .bar { margin-top: auto; }
.badge { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 99px; background: var(--green-soft); color: var(--green); }

.lesson-list { list-style: none; margin: 0; padding: 0; }
.lesson-list li a { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.lesson-list li:last-child a { border-bottom: 0; }
.lesson-list li a:hover { color: var(--red); }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .icon-btn { display: grid; }
  .top-progress .bar { width: 90px; }
  .brand-text small { display: none; }
  .sidebar {
    position: fixed; top: var(--topbar-h); bottom: 0; inset-inline-start: 0;
    height: auto; z-index: 25; width: min(86vw, var(--sidebar-w));
    transform: translateX(100%); visibility: hidden;
    transition: transform .25s ease, visibility .25s;
    box-shadow: var(--shadow);
  }
  body { overflow-x: clip; }
  body.nav-open .sidebar { transform: none; visibility: visible; }
  .scrim { position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(11,31,58,.4); z-index: 20; display: none; }
  body.nav-open .scrim { display: block; }
  .actions { flex-direction: column; align-items: stretch; }
  .actions > .btn { justify-content: center; }
  .nav-btns .btn { flex: 1 1 auto; justify-content: center; }
}
@media (max-width: 480px) {
  .topbar { padding: 0 12px; gap: 10px; }
  .top-progress-label { display: none; }
  .card { padding: 18px; }
}
