:root {
  --bg: #eef6fb;
  --panel: #ffffff;
  --panel-2: #f9fcff;
  --text: #102033;
  --muted: #6b7a90;
  --accent: #3a8bcd;
  --accent-dark: #1768a8;
  --accent-soft: rgba(58, 139, 205, 0.12);
  --border: rgba(16, 32, 51, 0.09);
  --shadow: 0 18px 45px rgba(20, 45, 75, 0.10);
  --shadow-soft: 0 8px 24px rgba(20, 45, 75, 0.08);
  --radius: 22px;
  --nav-width: 330px;
  --status-height: 42px;
  font-family: system-ui, -apple-system, "Segoe UI", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  background: radial-gradient(circle at top right, rgba(58,139,205,0.18), transparent 35%), linear-gradient(180deg, #f6fbff 0%, #eef6fb 55%, #e9f2fa 100%);
  color: var(--text);
  padding-bottom: var(--status-height);
}
body.rtl { direction: rtl; }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }

.app {
  display: grid;
  grid-template-columns: var(--nav-width) minmax(0, 1fr);
  min-height: calc(100vh - var(--status-height));
  gap: 18px;
  padding: 18px;
}

.left-nav {
  position: sticky;
  top: 18px;
  height: calc(100vh - 36px - var(--status-height));
  overflow-y: auto;
  background: rgba(255,255,255,0.86);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 18px;
  scrollbar-width: thin;
}

.brand { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.logo { width: 52px; height: 52px; border-radius: 18px; background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff; display: grid; place-items: center; font-size: 24px; font-weight: 900; box-shadow: 0 10px 22px rgba(58,139,205,0.28); flex: 0 0 auto; }
.brand-text { min-width: 0; }
.brand h1 { margin: 0; font-size: 1.05rem; line-height: 1.3; }
.muted { color: var(--muted); font-size: 0.85rem; }
.controls { margin-inline-start: auto; display: flex; gap: 6px; }
.collapse-btn { border: 1px solid var(--border); background: var(--panel-2); color: var(--accent-dark); border-radius: 12px; min-width: 34px; height: 34px; }
.collapse-btn:hover { background: var(--accent-soft); }
.side-note { background: linear-gradient(135deg, rgba(58,139,205,0.12), rgba(255,255,255,0.8)); color: var(--accent-dark); padding: 12px; border: 1px solid rgba(58,139,205,0.12); border-radius: 16px; font-size: 0.9rem; line-height: 1.7; margin-bottom: 14px; }
.nav-list { list-style: none; padding: 0; margin: 0; }
.nav-item { margin-bottom: 8px; }
.lvl1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-radius: 15px; padding: 12px 13px; background: transparent; color: var(--text); cursor: pointer; transition: 0.18s ease; border: 1px solid transparent; }
.lvl1:hover { background: var(--panel); border-color: var(--border); box-shadow: 0 6px 16px rgba(20,45,75,0.06); transform: translateY(-1px); }
.lvl1 .title { font-weight: 800; font-size: 0.95rem; }
.lvl2-container { margin: 7px 12px 10px 0; padding: 6px 10px 6px 0; border-right: 2px solid rgba(58,139,205,0.16); }
.lvl2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; border-radius: 13px; cursor: pointer; color: #26384d; transition: 0.18s ease; }
.lvl2:hover, .lvl2.highlight { background: rgba(58,139,205,0.12); color: var(--accent-dark); }
.sidebar-footer { margin-top: 18px; padding: 14px; border-radius: 16px; background: #102033; color: #fff; line-height: 1.6; }
.sidebar-footer small { display: block; color: rgba(255,255,255,0.70); }

.right { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 18px; align-items: stretch; }
.hero-content, .hero-card, .player-area, .lecture-list, .banner { background: rgba(255,255,255,0.88); backdrop-filter: blur(16px); border: 1px solid var(--border); box-shadow: var(--shadow-soft); border-radius: var(--radius); }
.hero-content { padding: 28px; overflow: hidden; position: relative; }
.hero-content::before { content: ""; position: absolute; inset-inline-start: -80px; top: -90px; width: 230px; height: 230px; background: radial-gradient(circle, rgba(58,139,205,0.22), transparent 70%); pointer-events: none; }
.hero-kicker { display: inline-flex; align-items: center; gap: 8px; background: var(--accent-soft); color: var(--accent-dark); border-radius: 999px; padding: 7px 13px; font-weight: 800; font-size: 0.88rem; margin-bottom: 12px; }
.hero h2 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.7rem); line-height: 1.35; letter-spacing: -0.02em; }
.hero p { max-width: 760px; margin: 10px 0 0; color: var(--muted); line-height: 1.9; font-size: 1rem; }
.search-box { margin-top: 20px; display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--border); border-radius: 18px; padding: 0 14px; min-height: 54px; box-shadow: 0 10px 24px rgba(20,45,75,0.06); }
.search-box input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); min-width: 0; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.quick-btn { border: 1px solid var(--border); background: var(--panel); color: var(--accent-dark); border-radius: 999px; padding: 10px 15px; font-weight: 800; text-decoration: none; box-shadow: 0 6px 14px rgba(20,45,75,0.05); transition: 0.18s ease; }
.quick-btn:hover { transform: translateY(-2px); background: var(--accent); color: #fff; }
.link-btn { display: inline-flex; align-items: center; }
.hero-card { padding: 22px; display: flex; flex-direction: column; justify-content: center; gap: 14px; background: linear-gradient(145deg, rgba(58,139,205,0.15), rgba(255,255,255,0.92)); }
.hero-card-icon { width: 64px; height: 64px; display: grid; place-items: center; font-size: 30px; border-radius: 22px; background: #fff; box-shadow: var(--shadow-soft); }
.hero-card strong { display: block; font-size: 1.1rem; margin-bottom: 7px; }
.hero-card span { color: var(--muted); line-height: 1.8; }

.banner { text-align: center; padding: 10px; }
.banner img { display: block; width: 100%; max-width: 950px; height: auto; margin: 0 auto; border-radius: 18px; cursor: pointer; }

.player-area { padding: 18px; }
.player-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.player-meta { display: flex; align-items: center; gap: 14px; min-width: 0; }
.meta-thumb { width: 70px; height: 70px; border-radius: 22px; background: linear-gradient(135deg, rgba(58,139,205,0.18), rgba(58,139,205,0.04)); border: 1px solid rgba(58,139,205,0.16); flex: 0 0 auto; position: relative; }
.meta-thumb::after { content: "▶"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--accent-dark); font-size: 25px; font-weight: 900; }
.meta-copy { min-width: 0; }
.meta-label { color: var(--accent-dark); font-weight: 900; font-size: 0.8rem; margin-bottom: 3px; }
.meta-title { font-weight: 900; font-size: 1.05rem; line-height: 1.6; }
.meta-sub { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
.now-playing-pill { background: #102033; color: #fff; border-radius: 999px; padding: 8px 12px; font-size: 0.78rem; font-weight: 900; white-space: nowrap; }
.media-wrap { display: flex; align-items: center; justify-content: center; }
video, audio { width: 100%; max-width: 100%; border: 0; border-radius: 18px; background: #000; }
video { height: 230px; }
audio { background: transparent; }
.progress-container { width: 100%; height: 10px; background: #dbe9f5; border-radius: 999px; margin: 14px 0 12px; cursor: pointer; position: relative; direction: ltr; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-dark)); border-radius: 999px; transition: width 0.1s linear; }
.skip-controls { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.skip-controls button { min-width: 54px; min-height: 46px; border: 0; border-radius: 16px; background: #102033; color: #fff; font-size: 1.15rem; box-shadow: 0 8px 18px rgba(16,32,51,0.14); transition: 0.18s ease; }
.skip-controls button:hover { transform: translateY(-2px); background: var(--accent-dark); }

.lecture-list { padding: 18px; min-height: 360px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--border); padding-bottom: 14px; }
.section-heading h2 { margin: 0; font-size: 1.25rem; }
.section-heading p { margin: 4px 0 0; color: var(--muted); }
.hidden-select-wrap { display: none; }
.grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; padding: 6px 0; }
.tile { min-height: 145px; background: linear-gradient(145deg, #ffffff, #f6fbff); border: 1px solid var(--border); border-radius: 20px; padding: 18px; cursor: pointer; box-shadow: 0 8px 22px rgba(20,45,75,0.06); transition: 0.18s ease; position: relative; overflow: hidden; }
.tile::before { content: ""; position: absolute; inset-inline-end: -40px; top: -40px; width: 110px; height: 110px; background: radial-gradient(circle, rgba(58,139,205,0.18), transparent 70%); }
.tile:hover { transform: translateY(-5px); box-shadow: var(--shadow); border-color: rgba(58,139,205,0.22); }
.tile-icon { width: 44px; height: 44px; border-radius: 15px; background: var(--accent-soft); color: var(--accent-dark); display: grid; place-items: center; font-size: 22px; margin-bottom: 14px; }
.tile-title { font-size: 1.05rem; font-weight: 900; line-height: 1.6; position: relative; z-index: 1; }
.tile-meta { color: var(--muted); font-size: 0.88rem; margin-top: 8px; position: relative; z-index: 1; }
.back-btn { border: 1px solid var(--border); background: #fff; color: var(--accent-dark); border-radius: 999px; padding: 10px 14px; font-weight: 900; margin-bottom: 14px; }
.back-btn:hover { background: var(--accent); color: #fff; }
.lecture-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; background: #fff; border: 1px solid var(--border); border-radius: 18px; padding: 12px; margin-bottom: 10px; transition: 0.18s ease; box-shadow: 0 5px 14px rgba(20,45,75,0.04); }
.lecture-row:hover { transform: translateY(-2px); border-color: rgba(58,139,205,0.25); box-shadow: 0 10px 26px rgba(20,45,75,0.08); }
.lecture-info { display: flex; align-items: center; gap: 12px; min-width: 0; width: 100%; }
.lecture-title { font-weight: 850; line-height: 1.7; color: var(--text); }
.play-btn, .play-btn-red { border: 0; border-radius: 15px; min-width: 74px; min-height: 42px; color: #fff; font-weight: 900; box-shadow: 0 8px 16px rgba(58,139,205,0.18); transition: 0.18s ease; }
.play-btn { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); }
.play-btn-red { background: linear-gradient(135deg, #d83a3a, #9d1e1e); }
.play-btn:hover, .play-btn-red:hover { transform: scale(1.04); }
.progress-badge { display: inline-flex; margin-inline-start: 8px; background: var(--accent-soft); color: var(--accent-dark) !important; padding: 3px 8px; border-radius: 999px; }
.empty-state { background: #fff; border: 1px dashed rgba(58,139,205,0.35); color: var(--muted); padding: 22px; border-radius: 18px; text-align: center; }

.history-panel { position: fixed; top: 0; bottom: 0; left: -390px; width: 370px; max-width: 92vw; background: rgba(255,255,255,0.96); backdrop-filter: blur(18px); box-shadow: 14px 0 45px rgba(16,32,51,0.18); z-index: 9999; transition: left 0.28s ease; overflow-y: auto; border-right: 1px solid var(--border); }
.history-panel.open { left: 0; }
.history-header { position: sticky; top: 0; z-index: 1; background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff; padding: 16px; font-weight: 900; display: flex; justify-content: space-between; align-items: center; }
.close-btn { background: rgba(255,255,255,0.18); color: #fff; border: 0; width: 36px; height: 36px; border-radius: 12px; font-weight: 900; }
.history-tools { padding: 12px 16px 4px; }
.danger-btn { background: #d83a3a; color: #fff; border: 0; border-radius: 12px; padding: 9px 12px; font-weight: 800; }
.history-content { padding: 12px 16px 24px; }
.history-item { padding: 13px; margin: 8px 0; border-radius: 16px; background: #f6fbff; border: 1px solid var(--border); cursor: pointer; transition: 0.18s ease; }
.history-item:hover { background: var(--accent-soft); transform: translateY(-2px); }
.history-item .title { line-height: 1.7; }
.history-toggle { position: fixed; left: 18px; bottom: calc(var(--status-height) + 18px); z-index: 1200; border: 0; border-radius: 999px; background: #102033; color: #fff; box-shadow: 0 14px 28px rgba(16,32,51,0.25); padding: 12px 16px; display: inline-flex; align-items: center; gap: 8px; transition: 0.18s ease; }
.history-toggle:hover { transform: translateY(-3px); background: var(--accent-dark); }

#statusBar { position: fixed; right: 0; left: 0; bottom: 0; min-height: var(--status-height); display: flex; align-items: center; justify-content: center; background: #102033; color: #fff; z-index: 1000; padding: 8px 14px; text-align: center; font-size: 0.9rem; }
#statusBar a { color: #9ed8ff; text-decoration: underline; }
#statusBar a:hover { color: #fff; }

@media (max-width: 1050px) { .hero { grid-template-columns: 1fr; } .hero-card { flex-direction: row; align-items: center; } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; padding: 12px; }
  .left-nav { position: fixed; top: 0; right: 0; left: auto; bottom: 0; width: 86%; max-width: 360px; height: 100vh; border-radius: 0; z-index: 3000; transform: translateX(110%); transition: transform 0.25s ease; }
  .left-nav.open { transform: translateX(0); }
  .menu-toggle { position: fixed; top: 14px; right: 14px; z-index: 3500; width: 48px; height: 48px; border: 0; border-radius: 16px; background: #102033; color: #fff; font-size: 22px; box-shadow: 0 10px 22px rgba(16,32,51,0.20); }
  .right { padding-top: 54px; }
  .hero-content { padding: 22px; }
  video { height: 190px; }
  .player-top { align-items: flex-start; flex-direction: column; }
  .now-playing-pill { align-self: flex-start; }
  .grid-container { grid-template-columns: 1fr; }
  .lecture-info { align-items: flex-start; }
  .history-toggle { left: 12px; bottom: calc(var(--status-height) + 12px); }
}
@media (max-width: 600px) {
  .hero h2 { font-size: 1.55rem; }
  .hero-card { flex-direction: column; align-items: flex-start; }
  .search-box { min-height: 50px; }
  .skip-controls button { min-width: 48px; min-height: 42px; font-size: 1rem; }
  .lecture-title { font-size: 0.95rem; }
  #statusBar { font-size: 0.78rem; }
}
