:root {
  --ink: #0b0f19; --ink2: #151e32; --ink3: #22304d; --accent: #FA541C; 
  --accent-grad: linear-gradient(135deg, #FF6B35 0%, #FA541C 100%);
  --text: #f8fafc; --muted: #94a3b8; --border: rgba(255,255,255,0.1);
  --success: #10b981; --warning: #f59e0b; --danger: #ef4444;
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 15px rgba(250, 84, 28, 0.3);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', sans-serif; background: var(--ink); color: var(--text); display: flex; height: 100vh; overflow: hidden; }

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: var(--ink3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
/* Login Overlay */
#login-overlay { position: fixed; inset: 0; background: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 9999; }
#login-overlay.hidden { display: none; }
.login-box { background: var(--ink2); padding: 40px; border-radius: 12px; border: 1px solid var(--border); text-align: center; max-width: 400px; }

/* Sidebar */
.sidebar { width: 260px; background: rgba(21, 30, 50, 0.6); backdrop-filter: blur(12px); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; box-shadow: 4px 0 15px rgba(0,0,0,0.2); z-index: 20; }
.brand { padding: 20px; font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.nav-item { padding: 12px 20px; color: var(--muted); cursor: pointer; display: flex; align-items: center; gap: 10px; font-weight: 500; border-left: 3px solid transparent; transition: all 0.3s ease; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,0.05); color: var(--text); border-left-color: var(--accent); text-shadow: 0 0 8px rgba(255,255,255,0.2); }
.user-info { margin-top: auto; padding: 20px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); word-break: break-all; }

/* Main Content */
.main { flex: 1; display: flex; flex-direction: column; overflow-y: auto; background: var(--ink); position: relative; min-width: 0; }
.topbar { padding: 20px 30px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: rgba(11, 15, 25, 0.75); backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 10; box-shadow: 0 4px 20px rgba(0,0,0,0.3); }
.content { padding: 32px 40px; max-width: 1400px; margin: 0 auto; width: 100%; }

/* Sections */
.view-section { display: none; animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.view-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Cards & Grids */
.card { background: rgba(21, 30, 50, 0.7); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 16px; padding: 28px; margin-bottom: 24px; box-shadow: var(--shadow-sm); transition: transform 0.3s ease, box-shadow 0.3s ease; }
.card:hover { box-shadow: var(--shadow-md); }
.card h2 { margin: 0 0 16px 0; font-size: 20px; display: flex; align-items: center; gap: 8px; font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }

/* UI Elements */
.btn { background: var(--accent-grad); color: #fff; border: none; padding: 10px 20px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 4px 10px rgba(250, 84, 28, 0.25); text-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 15px rgba(250, 84, 28, 0.4); filter: brightness(1.1); }
.btn:active { transform: translateY(0); box-shadow: 0 2px 5px rgba(250, 84, 28, 0.3); }
.btn.outline { background: transparent; border: 1px solid var(--border); box-shadow: none; text-shadow: none; }
.btn.outline:hover { background: rgba(255,255,255,0.08); transform: translateY(-1px); border-color: rgba(255,255,255,0.2); }
.btn.danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); box-shadow: none; }
.btn.danger:hover { background: rgba(239, 68, 68, 0.2); box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2); border-color: rgba(239, 68, 68, 0.4); }

.inp { width: 100%; background: rgba(0,0,0,0.2); border: 1px solid var(--border); color: #fff; padding: 12px 16px; border-radius: 10px; font-family: 'Inter', sans-serif; font-size: 14px; margin-bottom: 16px; outline: none; transition: all 0.3s ease; box-shadow: inset 0 2px 4px rgba(0,0,0,0.1); }
.inp:focus { border-color: var(--accent); box-shadow: inset 0 2px 4px rgba(0,0,0,0.1), var(--shadow-glow); background: rgba(0,0,0,0.4); }
label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }

.status-badge { padding: 4px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; background: rgba(255,255,255,0.1); }

/* Editor Layout */
.editor-layout { display: flex; gap: 20px; height: calc(100vh - 160px); }
.editor-sidebar { width: 300px; display: flex; flex-direction: column; gap: 16px; }
.editor-main { flex: 1; display: flex; flex-direction: column; }
.code-editor { flex: 1; background: #0b0f19; color: #a5b4fc; border: 1px solid var(--border); border-radius: 8px; padding: 16px; font-family: 'Consolas', 'Monaco', monospace; font-size: 14px; line-height: 1.5; resize: none; outline: none; }

.form-group { background: var(--ink); padding: 16px; border-radius: 8px; border: 1px solid var(--border); }

/* Log Box */
.log-box { background: #000; color: #4ade80; padding: 16px; border-radius: 8px; font-family: monospace; font-size: 12px; height: 200px; overflow-y: auto; white-space: pre-wrap; margin-top: 16px; display: none; }

/* ── Course Management Cards ──────────────────────────────────── */
/* courseGrid is a plain block container — NO grid class on the wrapper */
#courseGrid { display: block; }

.course-section { margin-bottom: 32px; }

.course-section-header {
  font-size: 13px; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 10px 0 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}

.course-cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.course-card {
  background: rgba(21, 30, 50, 0.5);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}
.course-card.hover, .course-card:hover { border-color: rgba(250, 84, 28, 0.5); transform: translateY(-4px); box-shadow: var(--shadow-md), var(--shadow-glow); background: rgba(21, 30, 50, 0.8); }
.course-card.editing { grid-column: span 2; border-color: var(--accent); box-shadow: var(--shadow-glow); }
@media (max-width: 600px) { .course-card.editing { grid-column: span 1; } }

.course-card-icon { font-size: 28px; margin-bottom: 10px; }

.course-card-body { flex: 1; }
.course-card-title { margin: 0 0 6px; font-size: 15px; font-weight: 700; color: var(--text); padding-right: 28px; }
.course-card-desc  { margin: 0 0 12px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.course-card-badge {
  display: inline-block; padding: 4px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
  background: rgba(59,130,246,0.15); color: #93c5fd;
}

.course-card-footer {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

.course-delete-btn {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 14px; padding: 2px 4px;
  border-radius: 4px; transition: color 0.15s, background 0.15s;
  opacity: 0;
}
.course-card:hover .course-delete-btn, .course-card:hover .course-view-btn { opacity: 1; }
.course-delete-btn:hover { color: var(--danger); background: rgba(239,68,68,0.1); }
.course-view-btn {
  position: absolute; top: 12px; right: 40px;
  background: none; border: none; cursor: pointer; text-decoration: none;
  color: var(--muted); font-size: 14px; padding: 2px 4px;
  border-radius: 4px; transition: color 0.15s, background 0.15s;
  opacity: 0; display:flex; align-items:center; justify-content:center;
}
.course-view-btn:hover { color: var(--primary); background: rgba(99,102,241,0.1); }
.header-toggle-btn {
  font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 6px;
  cursor: pointer; transition: 0.2s; border: 1px solid var(--border);
  background: rgba(255,255,255,0.04); color: var(--muted);
}
.header-toggle-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.header-toggle-btn.in-header {
  background: rgba(16,185,129,0.12); color: #34d399;
  border-color: rgba(16,185,129,0.35);
}
.header-toggle-btn.in-header:hover { background: rgba(16,185,129,0.2); }

.header-toggle-btn.btn-categories {
  background: rgba(139, 92, 246, 0.12); color: #a78bfa;
  border-color: rgba(139, 92, 246, 0.35);
}
.header-toggle-btn.btn-categories:hover { background: rgba(139, 92, 246, 0.2); color: #ddd6fe; }

.header-toggle-btn.btn-rightpanel {
  background: rgba(245, 158, 11, 0.12); color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.35);
}
.header-toggle-btn.btn-rightpanel:hover { background: rgba(245, 158, 11, 0.2); color: #fde68a; }

/* ── AI Generator Apply Button ───────────────────────────────── */
.gen-apply-btn {
  display: none; width: 100%; justify-content: center; padding: 8px;
  background: var(--success); margin-top: 8px;
}
.gen-apply-btn.visible { display: inline-flex; }

/* ── Redesigned Course Card UI ───────────────────────────────── */
.course-card-actions {
  display: flex; flex-direction: column; gap: 12px; padding-top: 12px; margin-top: auto;
  border-top: 1px solid var(--border);
}
.visibility-toggles {
  display: flex; gap: 6px; justify-content: space-between;
  background: rgba(0,0,0,0.2); padding: 6px; border-radius: 8px;
}
.icon-toggle-btn {
  flex: 1; text-align: center; font-size: 14px; padding: 6px 0; border-radius: 6px;
  cursor: pointer; transition: 0.2s; border: 1px solid transparent;
  background: transparent; color: var(--muted); opacity: 0.6;
}
.icon-toggle-btn:hover { background: rgba(255,255,255,0.05); opacity: 1; }
.icon-toggle-btn.in-header {
  background: rgba(16,185,129,0.1); color: #34d399; opacity: 1;
  border-color: rgba(16,185,129,0.3);
}
.icon-toggle-btn.in-header:hover { background: rgba(16,185,129,0.2); }

.module-pills {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.module-pill-btn {
  font-size: 12px; font-weight: 600; padding: 8px; border-radius: 6px;
  cursor: pointer; transition: 0.2s; border: 1px solid var(--border);
  background: rgba(255,255,255,0.02); color: var(--muted);
  text-align: center; display: flex; align-items: center; justify-content: center; gap: 4px;
}
.module-pill-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.module-pill-btn.active {
  background: rgba(16,185,129,0.1); color: #34d399;
  border-color: rgba(16,185,129,0.3);
}
.module-pill-btn.active:hover { background: rgba(16,185,129,0.2); }
.module-pill-btn.full-width { grid-column: 1 / -1; }
