/* =========================================================
   PHP MASTERY — PREMIUM CSS
   Theme: Clean White & Deep Blue — Centered Content
   Fonts: Syne (display) + DM Mono (code) + Outfit (body)
   ========================================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }

:root {
  --bg-base:        #f5f7fb;
  --bg-surface:     #ffffff;
  --bg-elevated:    #eef1f8;
  --bg-card:        #ffffff;
  --bg-hover:       #e8edf8;

  --blue-900:  #0d1f4e;
  --blue-800:  #163070;
  --blue-700:  #1e43a0;
  --blue-600:  #2558c8;
  --blue-500:  #3b72e8;
  --blue-400:  #6090f0;
  --blue-300:  #93b4f8;
  --blue-200:  #c4d6fc;
  --blue-100:  #dfe9fe;
  --blue-50:   #eef3ff;

  --accent:        var(--blue-600);
  --accent-hover:  var(--blue-700);
  --accent-light:  var(--blue-50);
  --accent-border: var(--blue-200);

  --text-primary:   #0d1f4e;
  --text-secondary: #3a4a6b;
  --text-muted:     #7a8aab;

  --border-default: #dde3f0;
  --border-strong:  #c4ceea;

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;

  --sidebar-w: 272px;
  --topbar-h:  58px;

  --font-display: 'Syne', sans-serif;
  --font-body:    'Outfit', sans-serif;
  --font-mono:    'DM Mono', monospace;

  --transition: 190ms cubic-bezier(.25,.46,.45,.94);
  --shadow-sm:  0 1px 4px rgba(30,67,160,.08), 0 0 0 1px rgba(30,67,160,.04);
  --shadow-md:  0 4px 16px rgba(30,67,160,.1), 0 1px 4px rgba(30,67,160,.06);
  --shadow-lg:  0 8px 32px rgba(30,67,160,.13), 0 2px 8px rgba(30,67,160,.07);
}

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-elevated); }
::-webkit-scrollbar-thumb { background: var(--blue-300); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--blue-400); }

/* =========================================================
   NAV
   ========================================================= */
.lesson-mega-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  height: var(--topbar-h);
  background: var(--blue-900);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.lesson-nav-container {
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 2rem;
}

.lesson-nav-left { display: flex; align-items: center; gap: 1rem; flex-shrink: 0; }

.lesson-nav-logo {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  text-decoration: none;
  letter-spacing: -.02em;
}
.lesson-nav-logo span { color: var(--blue-300); }

.lesson-mega-menu { display: flex; align-items: center; justify-content: center; gap: .25rem; flex: 1; }

.lesson-nav-search {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-shrink: 0;
}

.lesson-mega-item { position: relative; }

.lesson-mega-trigger {
  display: flex;
  align-items: center;
  gap: .4rem;
  background: none;
  border: none;
  color: rgba(255,255,255,.65);
  font-family: var(--font-body);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  padding: .45rem .75rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.lesson-mega-trigger svg { transition: transform var(--transition); }
.lesson-mega-trigger:hover { color: #fff; background: rgba(255,255,255,.1); }
.lesson-mega-item:hover .lesson-mega-trigger { color: var(--blue-300); }
.lesson-mega-item:hover .lesson-mega-trigger svg { transform: rotate(180deg); }

.lesson-mega-dropdown {
    position: absolute;
    top: 65px;
    left: 50%;
    transform: translateX(-50%);
   
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    border-radius: 0 0 8px 8px;
    padding: 1.5rem;
    width: 600px;
    opacity: 0;
    background: #ffffff;
    visibility: hidden;
    transition: all 0.2s ease;
}

.lesson-mega-item:hover .lesson-mega-dropdown {
    opacity: 1;
    visibility: visible;
}
.lesson-mega-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .2rem;
}

.lesson-mega-link {
  display: block;
  padding: .4rem .6rem;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.lesson-mega-link:hover { color: var(--blue-700); background: var(--blue-50); }
.lesson-mega-link.active {
  color: var(--blue-700);
  background: var(--blue-100);
  font-weight: 600;
}

.lesson-mega-link-plain {
  padding: .45rem .75rem;
  font-size: .875rem;
  font-weight: 500;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.lesson-mega-link-plain:hover { color: #fff; background: rgba(255,255,255,.1); }

.mobile-menu-btn {
  display: none;
  background: none;
  border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.8);
  font-size: 1.1rem;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  align-items: center;
  justify-content: center;
}
.mobile-menu-btn:hover { color: #fff; border-color: rgba(255,255,255,.4); }

/* =========================================================
   SIDEBAR
   ========================================================= */
#sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  background: #fff;
  border-right: 1px solid var(--border-default);
  overflow-y: auto;
  z-index: 900;
  display: flex;
  flex-direction: column;
  padding-bottom: 2rem;
}

.sidebar-header {
  padding: 1.5rem 1.25rem 1rem;
  background: var(--blue-900);
}

.sidebar-header .logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: .35rem;
}
.sidebar-header .logo-icon { font-size: 1.25rem; }
.sidebar-header p {
  font-size: .72rem;
  color: var(--blue-300);
  font-weight: 500;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.sidebar-app-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin-top: .5rem;
  padding: .35rem .75rem;
  font-size: .7rem;
  font-weight: 600;
  color: #a5f3fc;
  background: rgba(165,243,252,0.08);
  border: 1px solid rgba(165,243,252,0.15);
  border-radius: 6px;
  text-decoration: none;
  transition: background .2s, border-color .2s;
}
.sidebar-app-link:hover {
  background: rgba(165,243,252,0.16);
  border-color: rgba(165,243,252,0.3);
}

.nav-section { padding: .6rem 0; }

.nav-section-label {
  padding: .4rem 1.25rem;
  font-size: .63rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  width: 100%;
  padding: .52rem 1.25rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: .83rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: left;
  transition: all var(--transition);
  position: relative;
}
.nav-item:hover { color: var(--blue-700); background: var(--blue-50); }
.nav-item.active {
  color: var(--blue-700);
  background: var(--blue-50);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  height: 60%; width: 3px;
  background: var(--blue-600);
  border-radius: 0 3px 3px 0;
}

.nav-item .num {
  font-family: var(--font-mono);
  font-size: .68rem;
  color: var(--text-muted);
  min-width: 22px;
}
.nav-item.active .num { color: var(--blue-500); }

.nav-item .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
  transition: all var(--transition);
}
.nav-item.active .dot { background: var(--blue-500); }
.nav-item:hover .dot { background: var(--blue-400); }

.nav-item.syllabus-topic {
  padding: .42rem 1.25rem;
  font-size: .78rem;
}

.nav-item.syllabus-topic .num {
  min-width: 24px;
}

.sidebar-syllabus-list {
  list-style: none;
  margin: .35rem 1.25rem .75rem 3.1rem;
  padding: 0;
}

.sidebar-syllabus-list li {
  color: var(--text-muted);
  font-size: .75rem;
  line-height: 1.45;
  margin: 0 0 .28rem;
}

/* =========================================================
   MAIN
   ========================================================= */
#main {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
  display: flex;
  flex-direction: column;
}

/* ── Topbar ── */
#topbar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 800;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 2rem;
  height: 50px;
  background: #fff;
  border-bottom: 1px solid var(--border-default);
  box-shadow: var(--shadow-sm);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .78rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.breadcrumb .sep { opacity: .4; }
.breadcrumb .current { color: var(--blue-700); font-weight: 600; }

.progress-bar-wrap {
  display: none;
  align-items: center;
  gap: .75rem;
  flex: 1;
}

.progress-label {
  font-size: .72rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  flex-shrink: 0;
}

.progress-track {
  flex: 1;
  height: 4px;
  background: var(--blue-100);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-500), var(--blue-400));
  border-radius: 99px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}

.share-btn {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .35rem .75rem;
  background: none;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.share-btn svg { width: 13px; height: 13px; }
.share-btn:hover {
  color: var(--blue-700);
  border-color: var(--blue-300);
  background: var(--blue-50);
}

/* =========================================================
   CONTENT — CENTERED
   ========================================================= */
.content-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 2.5rem 2rem 4rem;
}

.content-column {
  width: 100%;
  max-width: 760px;
}

/* =========================================================
   LECTURE
   ========================================================= */
.lecture { display: none; }
.lecture.active { display: block; animation: fadeUp .3s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.lecture-tag {
  display: inline-flex;
  align-items: center;
  padding: .28rem .75rem;
  background: var(--blue-100);
  border: 1px solid var(--blue-200);
  border-radius: 99px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--blue-700);
  margin-bottom: 1rem;
}

.lecture h1 {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--blue-900);
  line-height: 1.15;
  letter-spacing: -.03em;
  margin-bottom: .75rem;
}

.lecture-meta {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin-bottom: 2rem;
}

.meta-badge {
  display: inline-flex;
  align-items: center;
  padding: .22rem .65rem;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-muted);
}
.meta-badge.level-beginner,
.meta-badge.level-intermediate,
.meta-badge.level-advanced { display: none; }

.lecture h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--blue-900);
  letter-spacing: -.02em;
  margin: 2.25rem 0 .7rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--blue-100);
}

.lecture h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--blue-800);
  margin: 1.5rem 0 .45rem;
}

.lecture h4 {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 1rem 0 .35rem;
}

.box {
  border: 1px solid var(--border-default);
  border-left: 4px solid var(--blue-500);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin: 1.25rem 0 1.5rem;
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.box.info {
  background: var(--blue-50);
  border-color: var(--blue-200);
  border-left-color: var(--blue-500);
}

.box-title {
  font-family: var(--font-display);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--blue-700);
  margin-bottom: .45rem;
}

.box p:last-child {
  margin-bottom: 0;
}

.lecture p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
  line-height: 1.8;
}

.lecture ul, .lecture ol {
  margin: .6rem 0 1rem 1.2rem;
  color: var(--text-secondary);
}
.lecture li { margin-bottom: .4rem; line-height: 1.75; }

.lecture a { color: var(--blue-600); text-decoration: none; border-bottom: 1px solid var(--blue-200); transition: all var(--transition); }
.lecture a:hover { color: var(--blue-800); border-color: var(--blue-400); }

code {
  font-family: var(--font-mono);
  font-size: .82em;
  padding: .15em .42em;
  border-radius: 4px;
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  color: var(--blue-800);
}

.kw      { color: #1d3fa5; font-family: var(--font-mono); font-weight: 500; }
.st      { color: #1a6e3c; font-family: var(--font-mono); }
.fn      { color: #0f5f8a; font-family: var(--font-mono); }
.cm      { color: #93a3b8; font-style: italic; font-family: var(--font-mono); }
.comment { color: #93a3b8; font-style: italic; font-family: var(--font-mono); }
strong   { color: var(--blue-900); font-weight: 600; }
strong.kw { color: #1d3fa5; }
strong.st { color: #1a6e3c; }

.lecture table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0 1.5rem;
  font-size: .875rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-sm);
}

.lecture th {
  background: var(--blue-900);
  padding: .6rem 1rem;
  text-align: left;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--blue-200);
}

.lecture td {
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--border-default);
  color: var(--text-secondary);
  vertical-align: middle;
}
.lecture tr:last-child td { border-bottom: none; }
.lecture tr:hover td { background: var(--blue-50); color: var(--blue-900); }

/* =========================================================
   CODE BLOCKS
   ========================================================= */
.code-block {
  background: var(--blue-900);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 1.25rem 0 1.5rem;
  box-shadow: var(--shadow-md);
}

.code-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .55rem 1rem;
  background: rgba(255,255,255,.05);
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.code-dots { display: flex; gap: 5px; }
.code-dots span { width: 10px; height: 10px; border-radius: 50%; }
.code-dots span:nth-child(1) { background: #ff5f57; }
.code-dots span:nth-child(2) { background: #febc2e; }
.code-dots span:nth-child(3) { background: #28c840; }

.filename {
  font-family: var(--font-mono);
  font-size: .7rem;
  color: var(--blue-300);
  letter-spacing: .04em;
}

.code-block pre {
  padding: 1.25rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: .85rem;
  line-height: 1.75;
  color: #c8d8f8;
  white-space: pre;
  tab-size: 4;
}

.output-block {
  background: #f0faf4;
  border: 1px solid #b3e6cb;
  border-left: 3px solid #1a7a49;
  border-radius: var(--radius-sm);
  padding: .875rem 1.25rem;
  font-family: var(--font-mono);
  font-size: .85rem;
  color: #1a5c38;
  margin: -.75rem 0 1.5rem;
}

.output-label {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #2ea865;
  display: block;
  margin-bottom: .2rem;
}

/* =========================================================
   EXERCISES
   ========================================================= */
.exercise {
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  border-left: 4px solid var(--blue-500);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
}

.exercise-title {
  font-family: var(--font-display);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--blue-600);
  margin-bottom: .6rem;
}

.exercise p, .exercise ol, .exercise li {
  color: var(--text-secondary);
  font-size: .9rem;
  margin-bottom: .35rem;
}

/* =========================================================
   COMPILER SECTION
   ========================================================= */
.compiler-section {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin: 2rem 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.compiler-section h2 {
  font-size: 1.1rem !important;
  margin-top: 0 !important;
  border-bottom: none !important;
  padding-bottom: 0 !important;
  margin-bottom: .5rem;
  color: var(--blue-900);
}
.compiler-section p { 
  font-size: .875rem; 
  color: var(--text-secondary); 
  margin-bottom: 1rem; 
  line-height: 1.6;
}
.compiler-section iframe {
  background: #fff;
  border: 1px solid var(--border-default) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.3s ease;
}
.compiler-section iframe:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.practice-tips {
  background: #fff;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-top: 1rem;
}
.practice-tips h4 {
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: .45rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.practice-tips li { font-size: .8rem; color: var(--text-muted); margin-bottom: .25rem; }

/* =========================================================
   LECTURE NAV
   ========================================================= */
.lecture-nav {
  display: flex;
  gap: .75rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-default);
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .65rem 1.5rem;
  background: #fff;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}
.nav-btn:hover {
  color: var(--blue-700);
  border-color: var(--blue-300);
  background: var(--blue-50);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.nav-btn.primary {
  background: var(--blue-600);
  border-color: var(--blue-600);
  color: #fff;
  font-weight: 600;
  margin-left: auto;
  box-shadow: 0 4px 14px rgba(37,88,200,.28);
}
.nav-btn.primary:hover {
  background: var(--blue-700);
  border-color: var(--blue-700);
  box-shadow: 0 6px 20px rgba(37,88,200,.38);
  transform: translateY(-2px);
}

/* =========================================================
   FOOTER
   ========================================================= */
#footer-grid {
  margin-left: var(--sidebar-w);
  background: var(--blue-900);
  border-top: 1px solid rgba(255,255,255,.07);
  padding: 3rem 0 1.5rem;
}

#footer-grid .container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.8fr repeat(3, 1fr);
  gap: 2.5rem;
  margin-bottom: 2.5rem;
}

.footer-col h3 {
  font-family: var(--font-display);
  font-size: .95rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: .875rem;
}
.footer-col p { font-size: .82rem; color: var(--blue-300); line-height: 1.65; }
.footer-col ul { list-style: none; }
.footer-col ul li { margin-bottom: .35rem; }
.footer-col ul a { font-size: .8rem; color: var(--blue-300); text-decoration: none; transition: color var(--transition); }
.footer-col ul a:hover { color: #fff; }

.copyright {
  border-top: 1px solid rgba(255,255,255,.08);
  padding-top: 1.25rem;
  text-align: center;
  font-size: .75rem;
  color: var(--blue-400);
}

.footer-social {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  margin-top: .9rem;
  flex-wrap: wrap;
}
.social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.15);
  color: var(--blue-300);
  transition: color .18s, border-color .18s, background .18s, transform .18s;
  text-decoration: none;
}
.social-link svg { width: 16px; height: 16px; }
.social-link:hover {
  color: #fff;
  border-color: var(--blue-400);
  background: var(--blue-700);
  transform: translateY(-2px);
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1024px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  
  .compiler-section {
    padding: 1rem;
    margin: 1rem 0;
  }
  
  .compiler-section iframe {
    height: 500px;
  }
  
  .practice-tips {
    padding: 0.75rem 1rem;
  }
  
  .practice-tips h4 {
    font-size: 0.9rem;
  }
  
  .practice-tips li {
    font-size: 0.75rem;
  }
}
@media (max-width: 768px) {
  .compiler-section {
    padding: 0.75rem;
    margin: 0.75rem 0;
  }
  
  .compiler-section h2 {
    font-size: 1rem;
  }
  
  .compiler-section p {
    font-size: 0.8rem;
  }
  
  .compiler-section iframe {
    height: 400px;
  }
  
  .practice-tips {
    padding: 0.5rem 0.75rem;
  }
  
  .practice-tips h4 {
    font-size: 0.85rem;
  }
  
  .practice-tips li {
    font-size: 0.7rem;
  }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .mobile-menu-btn { display: flex; }

  #sidebar {
    width: 272px;
    transform: translateX(-272px);
    transition: transform var(--transition);
  }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(13,31,78,.15);
  }

  #main { margin-left: 0; }
  #footer-grid { margin-left: 0; }

  .content-wrapper { padding: 1.5rem 1rem 3rem; }

  /* Nav: tighter on mobile so all items fit */
  .lesson-nav-container { padding: 0 .75rem; gap: .5rem; }
  .lesson-mega-menu { display: flex; gap: .1rem; }
  .lesson-mega-item { display: none; }
  .lesson-mega-link-plain { padding: .35rem .5rem; font-size: .78rem; }
  .lesson-nav-search { flex-shrink: 0; }

  .lecture h1 { font-size: 1.8rem; }
  .lecture h2 { font-size: 1.2rem; }

  .footer-grid { grid-template-columns: 1fr 1fr; }

  #topbar { padding: 0 1rem; gap: .75rem; }
  .progress-label { display: none; }

  .lecture-nav { flex-wrap: wrap; }
  .nav-btn.primary { margin-left: 0; }
}

@media (max-width: 480px) {
  .lecture h1 { font-size: 1.5rem; }
  .code-block pre { font-size: .78rem; }
  .footer-grid { grid-template-columns: 1fr; }
  .lesson-mega-grid { grid-template-columns: repeat(2, 1fr); }
}

::selection { background: var(--blue-200); color: var(--blue-900); }

/* =========================================================
   MISSING UTILITIES
   ========================================================= */
.code-filename {
  font-family: var(--font-mono);
  font-size: .7rem;
  color: var(--blue-300);
  letter-spacing: .04em;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 4px;
  color: rgba(255,255,255,.6);
  font-family: var(--font-mono);
  font-size: .68rem;
  cursor: pointer;
  transition: background .15s, color .15s;
  margin-left: auto;
}
.copy-btn:hover { background: rgba(255,255,255,.18); color: #fff; }
.copy-btn.copied { color: #4ade80; border-color: rgba(74,222,128,.4); }

.lecture-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--blue-900);
  color: #fff;
  font-family: var(--font-body);
  font-size: .85rem;
  font-weight: 500;
  padding: .65rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(13,31,78,.25);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  white-space: nowrap;
}
.lecture-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 38px;
  height: 38px;
  background: var(--blue-600);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  box-shadow: 0 4px 14px rgba(37,88,200,.3);
  z-index: 840;
}
.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}
.back-to-top:hover { background: var(--blue-700); transform: translateY(-2px); }

/* =========================================================
   PERSISTENT COMPILER PANEL
   ========================================================= */
.persistent-compiler {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  height: 420px;
  background: #fff;
  border-top: 2px solid var(--blue-600);
  z-index: 850;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(.25,.46,.45,.94);
  box-shadow: 0 -6px 32px rgba(13,31,78,.15);
}
.persistent-compiler.open    { transform: translateY(0); }
.persistent-compiler.expanded { height: 65vh; }

.pc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem 1.25rem;
  background: var(--blue-900);
  flex-shrink: 0;
  gap: 1rem;
}
.pc-header-left  { display: flex; align-items: center; gap: .75rem; }
.pc-header-right { display: flex; gap: .4rem; }

.pc-title {
  font-family: var(--font-display);
  font-size: .85rem;
  font-weight: 700;
  color: #fff;
}
.pc-hint {
  font-size: .68rem;
  color: var(--blue-300);
  font-family: var(--font-mono);
}

.pc-btn {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 4px;
  color: rgba(255,255,255,.8);
  cursor: pointer;
  padding: .22rem .6rem;
  font-size: .8rem;
  transition: background .15s, color .15s;
}
.pc-btn:hover { background: rgba(255,255,255,.22); color: #fff; }

.pc-body { flex: 1; overflow: hidden; }
.pc-body iframe { width: 100%; height: 100%; border: none; }

.compiler-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .35rem .75rem;
  background: var(--blue-600);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-body);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.compiler-toggle-btn:hover  { background: var(--blue-700); transform: translateY(-1px); }
.compiler-toggle-btn.active { background: var(--blue-800); }

@media (max-width: 768px) {
  .persistent-compiler { left: 0; height: 380px; }
  .persistent-compiler.expanded { height: 75vh; }
  .pc-hint { display: none; }
}
:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 2px; border-radius: 3px; }

/* =========================================================
   SEARCH OVERLAY
   ========================================================= */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(7, 12, 28, 0.72);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.search-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.search-modal {
  width: min(620px, 92vw);
  background: var(--blue-900);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 28px 70px rgba(0,0,0,.55);
  transform: translateY(-12px);
  transition: transform .18s ease;
}
.search-overlay.open .search-modal {
  transform: translateY(0);
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .9rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.search-icon { color: rgba(255,255,255,.38); flex-shrink: 0; }

.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #fff;
  font-size: 1rem;
  font-family: var(--font-body);
  caret-color: var(--blue-300);
}
.search-input::placeholder { color: rgba(255,255,255,.3); }

.search-kbd {
  font-size: .68rem;
  color: rgba(255,255,255,.28);
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 4px;
  padding: .15rem .45rem;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.search-results {
  max-height: 400px;
  overflow-y: auto;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .72rem 1.25rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,.04);
  transition: background .1s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover,
.search-result-item.active {
  background: rgba(255,255,255,.07);
}

.search-result-num {
  font-size: .68rem;
  color: rgba(255,255,255,.28);
  font-family: var(--font-mono);
  min-width: 1.6rem;
  text-align: right;
  flex-shrink: 0;
}

.search-result-title {
  flex: 1;
  font-size: .9rem;
  color: rgba(255,255,255,.82);
  font-weight: 500;
}
.search-result-title mark {
  background: none;
  color: var(--blue-300);
  font-weight: 700;
}

.search-result-tag {
  font-size: .66rem;
  color: rgba(255,255,255,.28);
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.09);
  padding: .12rem .45rem;
  border-radius: 99px;
  flex-shrink: 0;
}

.search-empty {
  padding: 2.25rem 1.25rem;
  text-align: center;
  color: rgba(255,255,255,.32);
  font-size: .875rem;
}
.search-empty strong { color: rgba(255,255,255,.55); }

.search-footer {
  display: flex;
  gap: 1.25rem;
  padding: .55rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.06);
  font-size: .68rem;
  color: rgba(255,255,255,.25);
}
.search-footer kbd {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 3px;
  padding: .05rem .3rem;
  font-family: var(--font-mono);
  font-size: .65rem;
  color: rgba(255,255,255,.4);
}

/* search button in nav */
.search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  background: none;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.6);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.search-btn:hover { color: #fff; border-color: rgba(255,255,255,.35); background: rgba(255,255,255,.08); }

@media (max-width: 480px) {
  .search-overlay { padding-top: 5vh; align-items: flex-start; }
  .search-modal { width: 100vw; border-radius: 0 0 14px 14px; }
}

/* =========================================================
   THEME TOGGLE BUTTON
   ========================================================= */
.theme-toggle-btn {
  position: fixed;
  bottom: 4.5rem;
  right: 1.5rem;
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  background: var(--blue-800);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
  color: rgba(255,255,255,.85);
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0,0,0,.35);
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}
.theme-toggle-btn svg { width: 18px; height: 18px; pointer-events: none; }
.theme-toggle-btn:hover {
  background: var(--blue-700);
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(0,0,0,.45);
}
html[data-theme="dark"] .theme-toggle-btn { background: #1e3a6e; }
html[data-theme="dark"] .theme-toggle-btn:hover { background: #254d90; }

/* =========================================================
   DARK MODE — lessons
   ========================================================= */
html[data-theme="dark"] {
  --bg-base:     #0f172a;
  --bg-surface:  #1a2440;
  --bg-elevated: #1e293b;
  --bg-card:     #1a2440;
  --bg-hover:    #243355;
  --text-primary:   #e2e8f8;
  --text-secondary: #94a3c8;
  --text-muted:     #64748b;
  --border-default: rgba(255,255,255,.09);
  --border-strong:  rgba(255,255,255,.16);
  --shadow-sm: 0 1px 4px rgba(0,0,0,.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.4);
}

html[data-theme="dark"] body {
  background: var(--bg-base);
  color: var(--text-primary);
}

html[data-theme="dark"] #sidebar {
  background: var(--bg-surface);
  border-right-color: var(--border-default);
}
html[data-theme="dark"] .sidebar-header {
  border-bottom-color: var(--border-default);
  color: var(--text-primary);
}
html[data-theme="dark"] .sidebar-header p { color: var(--text-muted); }

html[data-theme="dark"] .nav-section-label { color: var(--text-muted); }

html[data-theme="dark"] .nav-item {
  color: var(--text-secondary);
}
html[data-theme="dark"] .nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
html[data-theme="dark"] .nav-item.active {
  background: var(--blue-800);
  color: var(--blue-200);
}
html[data-theme="dark"] .nav-item.active .nav-number { color: var(--blue-300); }

html[data-theme="dark"] #topbar {
  background: var(--bg-surface);
  border-bottom-color: var(--border-default);
}
html[data-theme="dark"] .breadcrumb { color: var(--text-muted); }
html[data-theme="dark"] .breadcrumb .current { color: var(--blue-300); }

html[data-theme="dark"] .share-btn {
  border-color: var(--border-default);
  color: var(--text-secondary);
}
html[data-theme="dark"] .share-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

html[data-theme="dark"] #main { background: var(--bg-base); }

html[data-theme="dark"] .lecture h1 { color: var(--text-primary); }
html[data-theme="dark"] .lecture h2 { color: var(--text-primary); border-bottom-color: var(--border-default); }
html[data-theme="dark"] .lecture h3,
html[data-theme="dark"] .lecture h4 { color: var(--text-secondary); }
html[data-theme="dark"] .lecture p,
html[data-theme="dark"] .lecture li { color: var(--text-secondary); }

html[data-theme="dark"] .code-block {
  background: #0d1526;
  border-color: var(--border-default);
}
html[data-theme="dark"] .code-block pre { background: #0d1526; color: #c9d6f5; }
html[data-theme="dark"] code {
  background: rgba(255,255,255,.07);
  color: var(--blue-300);
}

html[data-theme="dark"] .box {
  background: var(--bg-surface);
  border-color: var(--border-default);
  border-left-color: var(--blue-500);
}

html[data-theme="dark"] .box.info {
  background: #0d1e3a;
  border-color: var(--blue-700);
}

html[data-theme="dark"] .box-title {
  color: var(--blue-300);
}

html[data-theme="dark"] .exercise {
  background: #0d1e3a;
  border-color: var(--blue-700);
}
html[data-theme="dark"] .exercise-title { color: var(--blue-300); }

html[data-theme="dark"] .meta-badge {
  background: var(--bg-surface);
  border-color: var(--border-default);
  color: var(--text-muted);
}

html[data-theme="dark"] .lecture-nav {
  background: var(--bg-surface);
  border-top-color: var(--border-default);
}
html[data-theme="dark"] .lecture-nav-btn {
  background: var(--bg-card);
  border-color: var(--border-default);
  color: var(--text-secondary);
}
html[data-theme="dark"] .lecture-nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

html[data-theme="dark"] #footer-grid {
  background: #0d1526;
  border-top-color: var(--border-default);
}
html[data-theme="dark"] .footer-col h3 { color: var(--text-primary); }
html[data-theme="dark"] .footer-col p  { color: var(--text-muted); }

html[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--bg-surface); }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--blue-700); }
