:root {
  --bg-dark: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.85);
  --bg-surface: #1e293b;
  --border-glass: rgba(148, 163, 184, 0.18);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --purple: #8b5cf6;
  --omr-pink: #db2777;
  --radius-lg: 16px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', 'Noto Sans Devanagari', system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top right, #1e1b4b, #0f172a 60%);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* Header & Topbar */
.portal-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-glass);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 800;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.35);
}

.brand-title h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
}

.brand-title p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.lang-toggle {
  display: inline-flex;
  background: #090d16;
  border: 1px solid var(--border-glass);
  border-radius: 999px;
  padding: 3px;
}

.lang-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 0.32rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.lang-btn.active {
  background: var(--primary);
  color: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.btn-accent {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border-color: var(--border-glass);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
}

.db-pill {
  font-size: 0.76rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-glass);
}

.db-pill.connected {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.4);
}

.db-pill.disconnected {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.45);
}

/* Main Container */
.portal-container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem;
}

/* Glass Card */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

/* Login Card */
.login-wrapper {
  max-width: 520px;
  margin: 1.5rem auto;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  background: #090d16;
  padding: 0.35rem;
  border-radius: 12px;
  margin: 1rem 0;
}

.mode-tab {
  padding: 0.6rem;
  text-align: center;
  border-radius: 9px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  border: none;
  background: transparent;
}

.mode-tab.active {
  background: var(--primary);
  color: #fff;
}

.form-group {
  margin-bottom: 0.9rem;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  color: #cbd5e1;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border-glass);
  background: #0f172a;
  color: #fff;
  font-size: 0.92rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* Student Hero Stats Bar */
.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.stat-tile {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 0.95rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.stat-icon {
  font-size: 1.75rem;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(59, 130, 246, 0.15);
}

.stat-val {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
}

.stat-lbl {
  font-size: 0.76rem;
  color: var(--text-muted);
}

/* Live Exam Alert Banner */
.live-banner {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.22), rgba(245, 158, 11, 0.22));
  border: 1px solid rgba(239, 68, 68, 0.5);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.15rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Navigation Pills */
.portal-nav {
  display: flex;
  gap: 0.55rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1.25rem;
}

.nav-pill {
  padding: 0.55rem 1.05rem;
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-glass);
  color: #cbd5e1;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.nav-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Chapter Cards Grid */
.chapters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.chapter-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  transition: transform 0.2s, border-color 0.2s;
}

.chapter-card:hover {
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.5);
}

.chapter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

/* Bilingual Block */
.bi-hi {
  font-size: 1.02rem;
  font-weight: 600;
  color: #f8fafc;
}

.bi-en {
  font-size: 0.88rem;
  color: #94a3b8;
  margin-top: 0.2rem;
}

/* Quiz Options */
.quiz-options {
  display: grid;
  gap: 0.65rem;
  margin: 1.1rem 0;
}

.quiz-opt {
  text-align: left;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border-glass);
  background: rgba(15, 23, 42, 0.75);
  color: #f8fafc;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.15s;
}

.quiz-opt:hover:not(:disabled) {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.12);
}

.quiz-opt.correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.22);
  color: #a7f3d0;
}

.quiz-opt.wrong {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.22);
  color: #fecaca;
}

/* Virtual Shortcut Keys */
.key-deck {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.v-key {
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  background: #0f172a;
  border: 1px solid #475569;
  border-bottom-width: 3px;
  color: #f8fafc;
  font-family: monospace;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
}

.v-key.pressed {
  background: var(--primary);
  border-color: #60a5fa;
  transform: translateY(1px);
}

/* Mini Excel Grid */
.excel-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.excel-table th,
.excel-table td {
  border: 1px solid #334155;
  padding: 0.5rem 0.75rem;
  text-align: center;
}

.excel-table th {
  background: #1e293b;
  color: #93c5fd;
  font-family: monospace;
}

/* BSEB Pink OMR Sheet */
.omr-sheet {
  background: #fff5f7;
  color: #831843;
  border: 2px solid #db2777;
  border-radius: 14px;
  padding: 1rem;
}

.omr-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px dashed #f472b6;
}

.omr-bubbles {
  display: flex;
  gap: 0.55rem;
}

.omr-bubble {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #db2777;
  background: #fff;
  color: #db2777;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.omr-bubble.filled {
  background: #1e1b4b;
  border-color: #1e1b4b;
  color: #fff;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.82);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-box {
  background: #1e293b;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  padding: 1.4rem;
  max-height: 90vh;
  overflow-y: auto;
}

/* Leaderboard Table */
.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.lb-table th,
.lb-table td {
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--border-glass);
  text-align: left;
}

/* Printable Certificate */
.certificate-print-area {
  background: #fffef8;
  color: #0f172a;
  border: 8px double #1d4ed8;
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  margin-top: 1rem;
}

@media print {
  body * {
    visibility: hidden;
  }
  #certificatePrintCard,
  #certificatePrintCard * {
    visibility: visible;
  }
  #certificatePrintCard {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    box-shadow: none;
  }
}
