:root {
  --bg: #0f1420;
  --bg-panel: #171e2e;
  --bg-panel-2: #1e2740;
  --bg-elev: #232d4a;
  --brand: #4f8cff;
  --brand-2: #7c5cff;
  --text: #eef2fb;
  --text-dim: #9aa6c2;
  --border: #2a3350;
  --ok: #2ecc71;
  --err: #ff5d6c;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Cairo', system-ui, "Segoe UI", Tahoma, sans-serif;
  min-height: 100vh;
}

/* ===== Top bar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  background: linear-gradient(90deg, var(--bg-panel), var(--bg-panel-2));
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 12px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: var(--shadow);
}
.brand-text h1 { margin: 0; font-size: 1.15rem; font-weight: 800; }
.brand-text p { margin: 2px 0 0; font-size: .8rem; color: var(--text-dim); }
.menu-toggle {
  display: none;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1.2rem;
  width: 42px; height: 42px;
  cursor: pointer;
}

/* ===== Layout ===== */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: calc(100vh - 71px);
}
.sidebar {
  grid-column: 1;
  grid-row: 1;
  background: var(--bg-panel);
  border-inline-end: 1px solid var(--border);
  padding: 18px 14px;
  overflow-y: auto;
  max-height: calc(100vh - 71px);
  position: sticky;
  top: 71px;
}
.content {
  grid-column: 2;
  grid-row: 1;
  padding: 26px clamp(16px, 4vw, 48px);
  overflow-x: hidden;
}

/* ===== Sidebar nav ===== */
.nav { display: flex; flex-direction: column; gap: 8px; }
.sec { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-panel-2); }
.sec.locked { opacity: .55; }
.sec-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  font-weight: 700;
}
.sec.locked .sec-head { cursor: not-allowed; }
.sec-badge {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  font-size: .85rem; font-weight: 800;
  flex-shrink: 0;
}
.sec.locked .sec-badge { background: var(--bg-elev); color: var(--text-dim); }
.sec-title { flex: 1; font-size: .95rem; }
.sec-caret { color: var(--text-dim); transition: transform .2s; font-size: .8rem; }
.sec.open .sec-caret { transform: rotate(180deg); }
.lock-tag { font-size: .7rem; color: var(--text-dim); }

.sec-body { display: none; padding: 6px 10px 12px; }
.sec.open .sec-body { display: block; }

.group-title { font-size: .8rem; color: var(--text-dim); margin: 10px 6px 6px; font-weight: 700; }

.item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: .88rem;
  color: var(--text-dim);
  transition: background .15s, color .15s;
}
.item:hover { background: var(--bg-elev); color: var(--text); }
.item.active { background: linear-gradient(90deg, rgba(79,140,255,.18), transparent); color: var(--text); }
.item .ic { width: 20px; text-align: center; flex-shrink: 0; }

/* ===== Content ===== */
.placeholder { text-align: center; padding: 80px 20px; color: var(--text-dim); }
.placeholder-icon { font-size: 4rem; }
.placeholder h2 { color: var(--text); }

.view-head { margin-bottom: 18px; }
.view-head .crumb { color: var(--text-dim); font-size: .85rem; }
.view-head h2 { margin: 6px 0 0; font-size: 1.5rem; }

.player-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow);
  max-width: 1000px;
}
.player-wrap video { width: 100%; display: block; }

.pdf-frame {
  width: 100%;
  height: 80vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}
.pdf-actions { margin-bottom: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--brand);
  color: #fff; text-decoration: none;
  border: none; border-radius: 10px;
  padding: 10px 18px; font-family: inherit; font-weight: 700; font-size: .9rem;
  cursor: pointer;
}
.btn.secondary { background: var(--bg-elev); color: var(--text); border: 1px solid var(--border); }
.btn:hover { filter: brightness(1.08); }

/* ===== Exam link ===== */
.exam-intro {
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 620px;
}
.exam-intro p { color: var(--text-dim); }
.exam-intro code {
  background: var(--bg-elev);
  padding: 2px 6px;
  border-radius: 6px;
  font-family: monospace;
  direction: ltr;
  display: inline-block;
}

/* ===== Responsive ===== */
.overlay { display: none; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .menu-toggle { display: grid; place-items: center; margin-inline-start: auto; }
  .sidebar {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 300px; max-width: 85vw;
    max-height: 100vh;
    transform: translateX(105%);
    transition: transform .25s;
    z-index: 50;
    padding-top: 70px;
  }
  .sidebar.show { transform: translateX(0); }
  .overlay.show {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 40;
  }
  .content { grid-column: 1; }
}
