/* ============================================================
   Study Helper — Complete Stylesheet (single source of truth)
   ============================================================ */

/* -- Variables ---------------------------------------------- */
:root {
  --primary:       #4A90E2;
  --primary-dark:  #357ABD;
  --primary-light: #EBF4FF;
  --secondary:     #2ECC71;
  --danger:        #E74C3C;
  --warning:       #F39C12;
  --info:          #3498DB;
  --dark:          #2C3E50;
  --gray:          #7F8C8D;
  --light:         #ECF0F1;
  --white:         #FFFFFF;
  --bg:            #F5F7FA;
  --card:          #FFFFFF;
  --text:          #2C3E50;
  --text-muted:    #7F8C8D;
  --border:        #E2E8F0;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
  --shadow-md:     0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:     0 10px 24px rgba(0,0,0,.14);
  --shadow:        var(--shadow-md);
  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     16px;
  --nav-height:    64px;
  --sp-1: .5rem; --sp-2: 1rem; --sp-3: 1.5rem;
  --sp-4: 2rem;  --sp-5: 3rem;
  --transition:    all .2s ease;
  --focus-ring:    0 0 0 3px rgba(74,144,226,.25);
  color-scheme:    light;
}

/* -- Reset -------------------------------------------------- */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-gutter: stable;
  hanging-punctuation: first last; /* Safari only; progressive enhancement */
}
body {
  font-family: 'Noto Sans Bengali', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6; font-size: 16px; overflow-x: hidden;
}
a { text-decoration:none; color:inherit; transition:all .2s; }
img { max-width:100%; height:auto; display:block; }
button { font-family:inherit; }

/* -- Typography --------------------------------------------- */
h1,h2,h3,h4,h5,h6 { font-weight:600; line-height:1.3; color:var(--dark); text-wrap:balance; } /* text-wrap:balance: Chrome 114+/Edge 114+ progressive enhancement */
h1 { font-size:clamp(1.5rem,4vw,2.25rem); }
h2 { font-size:clamp(1.25rem,3vw,1.875rem); }
h3 { font-size:clamp(1.1rem,2.5vw,1.5rem); }
p  { margin-bottom:var(--sp-2); text-wrap:pretty; } /* text-wrap:pretty: Chrome 117+ progressive enhancement */

/* -- Layout ------------------------------------------------- */
.main-content { min-height:calc(100vh - var(--nav-height)); padding-top:var(--nav-height); }
.page-container { max-width:1280px; margin:0 auto; padding:var(--sp-3) var(--sp-2); }
.container      { max-width:1200px; margin:0 auto; padding:0 var(--sp-2); }

/* -- Nav ---------------------------------------------------- */
.nav-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:998; backdrop-filter:blur(2px); }
.nav-overlay.active { display:block; }
.navbar { background:var(--white); box-shadow:var(--shadow-md); position:fixed; top:0; left:0; right:0; z-index:999; height:var(--nav-height); }
.nav-container { max-width:1280px; margin:0 auto; padding:0 var(--sp-2); display:flex; align-items:center; height:100%; gap:var(--sp-2); }
.nav-brand a { display:flex; align-items:center; }
.nav-logo { height:58px; width:auto; max-width:100%; }
.nav-menu { display:none; list-style:none; align-items:center; gap:.25rem; margin-left:auto; }
.nav-menu a { display:flex; align-items:center; gap:.4rem; padding:.45rem .8rem; border-radius:var(--radius-sm); color:var(--text); font-size:.9rem; font-weight:500; white-space:nowrap; }
.nav-menu a:hover, .nav-menu a.active { background:var(--primary-light); color:var(--primary); }
.nav-menu .mobile-only, .nav-divider-mobile { display:none; }
.nav-header-actions { margin-left:auto; display:flex; align-items:center; gap:.55rem; }
.nav-user { position:relative; margin-left:var(--sp-2); }
.desktop-only { display:none !important; }
.user-btn { display:flex; align-items:center; gap:.5rem; padding:.4rem .75rem; border:2px solid var(--border); border-radius:var(--radius); background:transparent; cursor:pointer; font-size:.9rem; font-weight:500; transition:all .2s; }
.user-btn:hover { border-color:var(--primary); background:var(--primary-light); }
.user-avatar { width:30px; height:30px; background:var(--primary); color:#fff; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:.85rem; flex-shrink:0; }
.user-name { max-width:120px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chevron { font-size:.7rem; transition:transform .2s; }
.user-btn[aria-expanded="true"] .chevron { transform:rotate(180deg); }
.user-dropdown { display:none; position:absolute; top:calc(100% + 8px); right:0; background:var(--white); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow-lg); min-width:200px; overflow:hidden; z-index:1001; }
.nav-user.open > .user-dropdown, .user-dropdown.open { display:block !important; }
.dropdown-header { padding:var(--sp-2); background:var(--primary-light); border-bottom:1px solid var(--border); }
.dropdown-header strong { display:block; font-size:.95rem; }
.dropdown-header small  { color:var(--text-muted); font-size:.8rem; }
.user-dropdown a { display:flex; align-items:center; gap:.6rem; padding:.65rem var(--sp-2); font-size:.9rem; color:var(--text); transition:background .15s; }
.user-dropdown a:hover { background:var(--bg); }
.user-dropdown hr { border:none; border-top:1px solid var(--border); margin:0; }
.logout-link { color:var(--danger) !important; }
.logout-link:hover { background:#fff5f5 !important; }
.hamburger { display:flex; flex-direction:column; justify-content:center; gap:5px; width:40px; height:40px; background:none; border:none; cursor:pointer; padding:4px; border-radius:var(--radius-sm); transition:background .2s; }
.hamburger:hover { background:var(--bg); }
.hamburger span { display:block; width:22px; height:2.5px; background:var(--dark); border-radius:3px; transition:all .3s cubic-bezier(.4,0,.2,1); transform-origin:center; }
.hamburger.open span:nth-child(1) { transform:translateY(7.5px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity:0; transform:scaleX(0); }
.hamburger.open span:nth-child(3) { transform:translateY(-7.5px) rotate(-45deg); }
@media (max-width:767px) {
  .nav-logo { height:50px; }
  .nav-menu { display:flex; flex-direction:column; align-items:stretch; gap:0; position:fixed; top:0; right:-280px; width:280px; height:100%; background:var(--white); box-shadow:var(--shadow-lg); z-index:1000; padding:var(--nav-height) 0 var(--sp-3); overflow-y:auto; transition:right .3s cubic-bezier(.4,0,.2,1); }
  .nav-menu.open { right:0; }
  .nav-menu li a { padding:.85rem var(--sp-3); font-size:1rem; border-radius:0; border-left:3px solid transparent; }
  .nav-menu li a:hover, .nav-menu li a.active { background:var(--primary-light); border-left-color:var(--primary); color:var(--primary); }
  .nav-menu .mobile-only { display:list-item; }
  .nav-divider-mobile { display:block; border-top:1px solid var(--border); margin:var(--sp-2) 0; }
  .mobile-logout { color:var(--danger) !important; }
  .desktop-only { display:none !important; }
  .nav-header-actions { gap:.45rem; }
  .dark-toggle { width:38px; height:38px; }
  .hamburger { display:flex; }
}
@media (min-width:768px) {
  .nav-menu { display:flex; }
  .nav-header-actions { gap:.6rem; }
  .hamburger { display:none !important; }
  .desktop-only { display:flex !important; }
}
body.nav-open { overflow:hidden; }

/* ══════════════════════════════════════════════════════════════════
   LANDING PAGE  (rvz-*)
   ══════════════════════════════════════════════════════════════════ */

.rvz-page { min-height: 100vh; background: var(--bg); }

/* Navbar */
.rvz-nav {
    background: var(--white); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow-sm);
}
.rvz-shell { max-width: 1180px; margin: 0 auto; padding: 0 var(--sp-2); }
.rvz-nav-row {
    display: flex; align-items: center;
    justify-content: space-between; gap: var(--sp-2);
    padding: .75rem 0; flex-wrap: wrap;
}
.rvz-brand { display: flex; align-items: center; }
.rvz-logo  { height: 42px; width: auto; }
.rvz-nav-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.rvz-menu-btn {
    background: none; border: none; cursor: pointer;
    font-size: 1.2rem; color: var(--text); padding: .35rem;
    display: none;
}

/* Sidebar (mobile nav) */
.rvz-sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 200;
}
.rvz-sidebar-overlay.active { display: block; }
.rvz-sidebar {
    position: fixed; top: 0; right: -280px; width: 260px; height: 100%;
    background: var(--white); z-index: 300; box-shadow: var(--shadow-lg);
    transition: right .25s; padding: var(--sp-2);
}
.rvz-sidebar.open { right: 0; }
.rvz-sidebar-head {
    display: flex; align-items: center; justify-content: space-between;
    padding-bottom: var(--sp-1); border-bottom: 1px solid var(--border);
    margin-bottom: var(--sp-1);
}
.rvz-sidebar-close {
    background: none; border: none; font-size: 1.2rem; cursor: pointer;
    color: var(--text);
}
.rvz-sidebar-links { display: flex; flex-direction: column; gap: .25rem; }
.rvz-sidebar-link {
    display: flex; align-items: center; gap: .5rem;
    padding: .55rem .7rem; border-radius: var(--radius-sm);
    color: var(--text); font-weight: 500;
}
.rvz-sidebar-link:hover { background: var(--primary-light); color: var(--primary); }
.rvz-sidebar-ctas {
    display: flex; flex-direction: column; gap: .5rem;
    margin-top: var(--sp-2);
}

/* Landing buttons */
.rvz-btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .55rem 1.1rem; border-radius: var(--radius);
    font-size: .9rem; font-weight: 600; cursor: pointer;
    border: 2px solid transparent; transition: all .18s; text-decoration: none;
}
.rvz-btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.rvz-btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.rvz-btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.rvz-btn-outline:hover { background: var(--primary-light); }

/* Hero */
.rvz-hero {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: var(--sp-4); align-items: start;
    padding: var(--sp-5) var(--sp-2);
}
.rvz-kicker {
    display: inline-flex; align-items: center; gap: .4rem;
    background: var(--primary-light); color: var(--primary);
    padding: .3rem .75rem; border-radius: 999px;
    font-size: .8rem; font-weight: 600; margin-bottom: var(--sp-2);
}
.rvz-hero h1 { font-size: clamp(1.6rem,4vw,2.4rem); margin-bottom: var(--sp-2); }
.rvz-tagline { color: var(--text-muted); font-size: 1.05rem; margin-bottom: var(--sp-3); }
.rvz-hero-ctas { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: var(--sp-3); }
.rvz-priority-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.rvz-priority-card {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .3rem .7rem; border-radius: var(--radius-sm);
    background: var(--white); border: 1px solid var(--border);
    font-size: .82rem; font-weight: 500; color: var(--text-muted);
}
.rvz-flash { border-color: var(--primary); color: var(--primary); }

.rvz-hero-panel {
    background: var(--white); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md); overflow: hidden;
    border: 1px solid var(--border);
}
.rvz-mini-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: .75rem 1rem; border-bottom: 1px solid var(--border);
    background: var(--primary-light);
}
.rvz-mini-title { font-weight: 600; font-size: .9rem; color: var(--primary); }
.rvz-mini-badge {
    background: var(--primary); color: #fff;
    font-size: .72rem; padding: .15rem .55rem;
    border-radius: 999px; font-weight: 600;
}
.rvz-mini-list { padding: 0 1rem; }
.rvz-mini-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: .65rem 0; border-bottom: 1px solid var(--border);
    gap: .5rem; font-size: .9rem;
}
.rvz-mini-item:last-child { border: none; }

/* Scroll reveal */
.rvz-reveal { opacity: 0; transform: translateY(18px); transition: opacity .45s, transform .45s; }
.rvz-reveal.in-view { opacity: 1; transform: none; }

/* Feature section */
.rvz-feature-section { padding: var(--sp-5) var(--sp-2); }
.rvz-section-head { text-align: center; margin-bottom: var(--sp-4); }
.rvz-section-head h2 { margin-bottom: .5rem; }
.rvz-section-head p { color: var(--text-muted); }
.rvz-feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px,1fr));
    gap: var(--sp-2);
}
.rvz-feature-card {
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: var(--sp-3);
    transition: box-shadow .2s, transform .2s;
}
.rvz-feature-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.rvz-feature-icon {
    width: 44px; height: 44px; background: var(--primary-light);
    color: var(--primary); border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; margin-bottom: var(--sp-2);
}
.rvz-feature-card h3 { font-size: 1rem; margin-bottom: .4rem; }
.rvz-feature-card p  { font-size: .9rem; color: var(--text-muted); margin: 0; }

/* CTA */
.rvz-cta {
    text-align: center; background: var(--primary-light);
    border-radius: var(--radius-lg);
    margin: var(--sp-4) var(--sp-2);
    padding: var(--sp-5) var(--sp-2);
}
.rvz-cta h2 { margin-bottom: .5rem; }
.rvz-cta p  { color: var(--text-muted); margin-bottom: var(--sp-3); }

/* Footer */
.rvz-footer { border-top: 1px solid var(--border); padding: var(--sp-3) var(--sp-2); }
.rvz-footer-row {
    display: flex; align-items: center;
    justify-content: space-between; flex-wrap: wrap; gap: var(--sp-1);
}
.rvz-footer-links { display: flex; gap: var(--sp-2); }
.rvz-footer-links a { color: var(--text-muted); font-size: .9rem; }
.rvz-footer-links a:hover { color: var(--primary); }
.rvz-muted { color: var(--text-muted); font-size: .85rem; margin: 0; }

@media (max-width: 768px) {
    .rvz-menu-btn { display: flex; }
    .rvz-nav-actions .rvz-btn { display: none; }
    .rvz-hero { grid-template-columns: 1fr; }
    .rvz-hero-panel { display: none; }
}

/* -- Buttons ------------------------------------------------ */
.btn { display:inline-flex; align-items:center; gap:.4rem; padding:.65rem 1.25rem; border:2px solid transparent; border-radius:var(--radius); font-size:.95rem; font-weight:500; cursor:pointer; white-space:nowrap; transition:all .2s; text-decoration:none; -webkit-tap-highlight-color:transparent; }
.btn:active { transform:scale(.97); }
.btn-primary  { background:var(--primary); color:#fff; border-color:var(--primary); }
.btn-primary:hover { background:var(--primary-dark); border-color:var(--primary-dark); box-shadow:0 4px 12px rgba(74,144,226,.35); }
.btn-outline  { background:transparent; color:var(--primary); border-color:var(--primary); }
.btn-outline:hover { background:var(--primary); color:#fff; }
.btn-danger   { background:var(--danger); color:#fff; border-color:var(--danger); }
.btn-danger:hover { background:#c0392b; }
.btn-success  { background:var(--secondary); color:#fff; border-color:var(--secondary); }
.btn-ghost    { background:transparent; color:var(--gray); border-color:var(--border); }
.btn-ghost:hover { background:var(--bg); }
.btn-white    { background:#fff; color:var(--primary); }
.btn-white:hover { background:var(--light); }
.btn-sm    { padding:.4rem .85rem; font-size:.85rem; }
.btn-lg    { padding:.85rem 1.75rem; font-size:1.05rem; }
.btn-block { width:100%; justify-content:center; }
.btn-icon  { width:36px; height:36px; padding:0; justify-content:center; border-radius:50%; border:none; }

/* -- Badges ------------------------------------------------- */
.badge         { display:inline-block; padding:.2rem .6rem; border-radius:12px; font-size:.75rem; font-weight:600; color:#fff; }
.badge-primary { background:var(--primary); }
.badge-danger  { background:var(--danger); }
.badge-success { background:var(--secondary); }
.badge-warning { background:var(--warning); }

/* -- Forms -------------------------------------------------- */
.form-group { margin-bottom:var(--sp-3); }
.form-group label { display:flex; align-items:center; gap:.4rem; margin-bottom:.4rem; font-weight:500; font-size:.9rem; }
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="time"],
.form-group select,
.form-group textarea {
  width:100%; padding:.7rem 1rem; border:2px solid var(--border); border-radius:var(--radius);
  font-size:1rem; font-family:inherit; color:var(--text); background:var(--white);
  transition:border-color .2s, box-shadow .2s; appearance:none; -webkit-appearance:none;
}
.form-group input:focus-visible,
.form-group input:focus,
.form-group select:focus-visible,
.form-group select:focus,
.form-group textarea:focus-visible,
.form-group textarea:focus { outline:none; border-color:var(--primary); box-shadow:var(--focus-ring); }
/* Suppress ring on mouse click; keep border-color change for all browsers */
.form-group input:focus:not(:focus-visible),
.form-group select:focus:not(:focus-visible),
.form-group textarea:focus:not(:focus-visible) { box-shadow:none; }
.form-group textarea { resize:vertical; min-height:130px; }
.form-group small { display:block; margin-top:.3rem; color:var(--text-muted); font-size:.82rem; }
.form-group input[type="file"] { padding:.5rem; cursor:pointer; }
.form-group input[type="checkbox"],
.form-group input[type="radio"] { accent-color:var(--primary); width:1rem; height:1rem; cursor:pointer; }
.form-row { display:grid; grid-template-columns:1fr; gap:var(--sp-2); }
@media(min-width:640px){ .form-row { grid-template-columns:repeat(auto-fit, minmax(220px,1fr)); } }
.form-actions { display:flex; flex-wrap:wrap; gap:var(--sp-2); margin-top:var(--sp-3); }

/* Card-style form containers */
.form-card { background:var(--card); border-radius:var(--radius-lg); padding:var(--sp-3); box-shadow:var(--shadow-sm); border:1px solid var(--border); }
.form-card h2, .form-card h3 { font-size:1rem; margin-bottom:var(--sp-2); display:flex; align-items:center; gap:.4rem; }
.form-container { background:var(--card); border-radius:var(--radius-lg); padding:clamp(var(--sp-2),4vw,var(--sp-4)); box-shadow:var(--shadow-sm); border:1px solid var(--border); }
.inline-form { display:flex; flex-wrap:wrap; gap:var(--sp-2); align-items:flex-end; }
.inline-form .form-group { flex:1; min-width:160px; margin-bottom:0; }
.current-file { display:flex; align-items:center; gap:var(--sp-2); flex-wrap:wrap; padding:var(--sp-2); background:var(--bg); border-radius:var(--radius); margin-bottom:var(--sp-2); font-size:.9rem; }

/* -- Alerts ------------------------------------------------- */
.alert { display:flex; align-items:center; gap:.6rem; padding:var(--sp-2) var(--sp-3); border-radius:var(--radius); margin-bottom:var(--sp-3); font-size:.95rem; }
.alert-success { background:#d4edda; color:#155724; border-left:4px solid var(--secondary); }
.alert-error   { background:#f8d7da; color:#721c24; border-left:4px solid var(--danger); }
.alert-info    { background:#d1ecf1; color:#0c5460; border-left:4px solid var(--info); }

/* -- Cards -------------------------------------------------- */
.card { background:var(--card); border-radius:var(--radius-lg); padding:var(--sp-3); box-shadow:var(--shadow-sm); border:1px solid var(--border); }

/* -- Data table --------------------------------------------- */
.data-table { width:100%; border-collapse:collapse; font-size:.9rem; background:var(--card); border-radius:var(--radius-lg); overflow:hidden; box-shadow:var(--shadow-sm); border:1px solid var(--border); }
.data-table thead { background:var(--bg); }
.data-table th { padding:.75rem var(--sp-2); text-align:left; font-weight:600; font-size:.82rem; color:var(--text-muted); text-transform:uppercase; letter-spacing:.05em; border-bottom:2px solid var(--border); }
.data-table td { padding:.75rem var(--sp-2); border-bottom:1px solid var(--border); vertical-align:middle; }
.data-table tbody tr:last-child td { border-bottom:none; }
.data-table tbody tr:hover { background:var(--bg); }
/* Responsive table wrapper — use for any table that may overflow on small screens */
.table-scroll { overflow-x:auto; -webkit-overflow-scrolling:touch; border-radius:var(--radius-lg); }
.table-scroll .data-table { border-radius:0; box-shadow:none; border:none; min-width:520px; }

/* -- Page Header -------------------------------------------- */
.page-header { display:flex; flex-wrap:wrap; gap:var(--sp-2); justify-content:space-between; align-items:flex-start; margin-bottom:var(--sp-3); padding-bottom:var(--sp-3); border-bottom:2px solid var(--border); }
.page-header h1 { margin:0; display:flex; align-items:center; gap:.5rem; }
.page-header p  { color:var(--text-muted); margin:0; font-size:.9rem; }

/* -- Empty state -------------------------------------------- */
.empty-state { text-align:center; padding:var(--sp-4) var(--sp-2); color:var(--text-muted); }
.empty-state i  { font-size:3.5rem; opacity:.3; margin-bottom:var(--sp-2); display:block; }
.empty-state h3 { margin-bottom:.4rem; }
.empty-state p  { margin-bottom:var(--sp-2); }

/* ------------------------------------------------------------
   AUTH PAGES
   ----------------------------------------------------------- */
.auth-page { background:linear-gradient(135deg,#667eea,#764ba2); min-height:100vh; display:flex; align-items:center; justify-content:center; padding:var(--sp-3); }
.auth-box  { background:#fff; border-radius:var(--radius-lg); padding:clamp(1.5rem,5vw,2.5rem); width:100%; max-width:440px; box-shadow:var(--shadow-lg); }
.auth-header { text-align:center; margin-bottom:var(--sp-3); }
.auth-logo { height:64px; width:auto; max-width:100%; margin:0 auto .6rem; }
.auth-header h1 { font-size:1.75rem; margin-bottom:.25rem; }
.auth-header p  { color:var(--text-muted); }
.auth-footer    { text-align:center; padding-top:var(--sp-2); border-top:1px solid var(--border); margin-top:var(--sp-2); }
.auth-footer a  { color:var(--primary); font-weight:500; }
.auth-footer p  { margin:.3rem 0; font-size:.9rem; }
.auth-forgot-link { display:inline-block; margin-top:.4rem; font-size:.85rem; color:var(--primary); font-weight:500; }
.auth-container { max-width:440px; margin:0 auto; width:100%; }
.auth-form { background:var(--card); border-radius:var(--radius-lg); padding:var(--sp-3); box-shadow:var(--shadow-lg); }

/* ------------------------------------------------------------
   LANDING PAGE
   ----------------------------------------------------------- */
.landing-page  { background:linear-gradient(135deg,#667eea,#764ba2); }
.landing-nav   { background:rgba(255,255,255,.96); backdrop-filter:blur(10px); padding:var(--sp-2) 0; box-shadow:var(--shadow-md); }
.nav-actions   { display:flex; gap:var(--sp-2); }
.hero { display:grid; grid-template-columns:1fr; gap:var(--sp-4); align-items:center; padding:var(--sp-5) var(--sp-3); text-align:center; }
@media(min-width:768px){ .hero { grid-template-columns:1fr 1fr; text-align:left; } .hero-buttons { justify-content:flex-start; } }
.hero-content h1 { font-size:clamp(2rem,5vw,3.5rem); color:#fff; margin-bottom:var(--sp-2); }
.hero-subtitle   { font-size:1.1rem; color:rgba(255,255,255,.88); margin-bottom:var(--sp-3); }
.hero-buttons    { display:flex; gap:var(--sp-2); flex-wrap:wrap; justify-content:center; }
.hero-image      { font-size:10rem; color:rgba(255,255,255,.15); text-align:center; display:none; }
@media(min-width:768px){ .hero-image { display:block; } }
.features        { padding:var(--sp-5) 0; background:#fff; }
.section-title   { text-align:center; margin-bottom:var(--sp-4); }
.features-grid   { display:grid; grid-template-columns:repeat(auto-fit, minmax(260px,1fr)); gap:var(--sp-3); max-width:1200px; margin:0 auto; padding:0 var(--sp-2); }
.feature-card    { text-align:center; padding:var(--sp-3); border-radius:var(--radius-lg); border:1px solid var(--border); transition:all .3s; }
.feature-card:hover { transform:translateY(-4px); box-shadow:var(--shadow-lg); }
.feature-icon    { font-size:2.5rem; color:var(--primary); margin-bottom:var(--sp-2); }
.cta             { background:linear-gradient(135deg,#667eea,#764ba2); padding:var(--sp-5) var(--sp-2); text-align:center; }
.cta h2          { font-size:clamp(1.5rem,4vw,2.5rem); color:#fff; margin-bottom:.5rem; }
.cta p           { color:rgba(255,255,255,.88); margin-bottom:var(--sp-3); }
.landing-footer  { background:var(--dark); color:#fff; padding:var(--sp-3); text-align:center; }

/* ------------------------------------------------------------
   DASHBOARD
   ----------------------------------------------------------- */
/* .dashboard-container { max-width:1280px; margin:0 auto; padding:var(--sp-3) var(--sp-2); } */
.next-exam-banner { display:flex; align-items:center; gap:.75rem; flex-wrap:wrap; padding:var(--sp-2) var(--sp-3); background:linear-gradient(135deg,var(--primary),#667eea); color:#fff; border-radius:var(--radius-lg); margin-bottom:var(--sp-3); font-size:.95rem; box-shadow:0 4px 12px rgba(74,144,226,.3); }
.next-exam-banner i { font-size:1.2rem; flex-shrink:0; }
.stats-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:var(--sp-2); margin-bottom:var(--sp-3); }
@media(min-width:900px){ .stats-grid { grid-template-columns:repeat(4,1fr); } }
.stat-card  { background:var(--card); border-radius:var(--radius-lg); padding:var(--sp-2); box-shadow:var(--shadow-sm); display:flex; align-items:center; gap:var(--sp-2); border:1px solid var(--border); }
.stat-icon  { width:52px; height:52px; border-radius:var(--radius); display:flex; align-items:center; justify-content:center; font-size:1.5rem; color:#fff; flex-shrink:0; }
.stat-info h3 { font-size:1.5rem; margin:0; }
.stat-info p  { color:var(--text-muted); margin:0; font-size:.82rem; }
.dashboard-grid { display:grid; grid-template-columns:1fr; gap:var(--sp-3); margin-bottom:var(--sp-3); }
@media(min-width:900px){ .dashboard-grid { grid-template-columns:1fr 1fr; } }
.dashboard-section { background:var(--card); border-radius:var(--radius-lg); padding:var(--sp-3); box-shadow:var(--shadow-sm); border:1px solid var(--border); min-width:0; overflow:hidden; }
.section-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:var(--sp-2); padding-bottom:var(--sp-2); border-bottom:2px solid var(--border); }
.section-header h2 { margin:0; font-size:1.05rem; display:flex; align-items:center; gap:.4rem; }
.notes-list, .exams-list { display:flex; flex-direction:column; gap:.6rem; }
.note-item { display:flex; align-items:center; gap:var(--sp-2); padding:.75rem var(--sp-2); background:var(--bg); border-radius:var(--radius); transition:background .2s; }
.note-item:hover { background:var(--light); }
.note-subject-badge { width:44px; height:44px; border-radius:var(--radius-sm); display:flex; align-items:center; justify-content:center; color:#fff; font-weight:700; font-size:1rem; flex-shrink:0; }
.note-content      { flex:1; min-width:0; }
.note-content h4   { margin:0; font-size:.9rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.note-content-dash { flex:1; min-width:0; }
.note-content-dash h4 { margin:0; font-size:.9rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.note-meta { display:flex; gap:var(--sp-2); font-size:.78rem; color:var(--text-muted); margin:.2rem 0 0; flex-wrap:wrap; }
.exam-item { display:flex; align-items:center; gap:var(--sp-2); padding:.75rem; background:var(--bg); border-radius:var(--radius); }
.exam-date { width:52px; height:52px; background:var(--primary); color:#fff; border-radius:var(--radius); display:flex; flex-direction:column; align-items:center; justify-content:center; flex-shrink:0; }
.exam-date .day   { font-size:1.3rem; font-weight:700; line-height:1; }
.exam-date .month { font-size:.7rem; text-transform:uppercase; }
.exam-info h4 { margin:0; font-size:.9rem; }
.exam-info p  { margin:.2rem 0 0; color:var(--text-muted); font-size:.8rem; }
.exam-countdown { font-weight:700; color:var(--danger); font-size:.82rem; }
.view-all-link { display:block; text-align:center; margin-top:var(--sp-2); color:var(--primary); font-size:.9rem; font-weight:500; }
.quick-actions    { background:var(--card); border-radius:var(--radius-lg); padding:var(--sp-3); box-shadow:var(--shadow-sm); border:1px solid var(--border); }
.quick-actions h2 { font-size:1.05rem; margin-bottom:var(--sp-2); display:flex; align-items:center; gap:.4rem; }
.actions-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:var(--sp-2); }
@media(min-width:640px){ .actions-grid { grid-template-columns:repeat(4,1fr); } }
.action-card { padding:var(--sp-2); background:var(--bg); border-radius:var(--radius); text-align:center; transition:all .2s; cursor:pointer; border:1px solid var(--border); }
.action-card:hover { background:var(--primary); color:#fff; border-color:var(--primary); transform:translateY(-2px); box-shadow:var(--shadow-md); }
.action-card i  { font-size:1.6rem; margin-bottom:.4rem; display:block; }
.action-card h3 { font-size:.9rem; margin-bottom:.2rem; }
.action-card p  { font-size:.78rem; margin:0; opacity:.8; }

.checkbox-inline {
  display:flex;
  align-items:center;
  gap:.5rem;
  margin:.4rem 0;
  font-size:.9rem;
  color:var(--text);
}
.checkbox-inline input { width:1rem; height:1rem; }
.nesco-widget { margin-bottom:var(--sp-3); }
.nesco-stats-row {
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(180px,1fr));
  gap:.75rem;
}
.nesco-stat {
  background:var(--bg);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:.8rem;
}
.nesco-stat span {
  display:block;
  color:var(--text-muted);
  font-size:.8rem;
}
.nesco-stat strong {
  display:block;
  margin-top:.2rem;
  font-size:.95rem;
}

/* ================================================================
   DASHBOARD  —  bold & colorful, full dark-mode support
   All color tokens defined under :root (light) and
   [data-theme="dark"] / prefers-color-scheme: dark
   ================================================================ */

/* ── Color tokens ── */
:root {
    --db-blue:   #3B82F6;
    --db-orange: #F97316;
    --db-gold:   #EAB308;
    --db-red:    #EF4444;
    --db-green:  #22C55E;
    --db-purple: #A855F7;
    --db-teal:   #14B8A6;

    --db-blue-light:   #EFF6FF;
    --db-orange-light: #FFF7ED;
    --db-gold-light:   #FEFCE8;
    --db-red-light:    #FEF2F2;
    --db-green-light:  #F0FDF4;
    --db-purple-light: #FAF5FF;
    --db-teal-light:   #F0FDFA;

    --db-blue-dark:   #1D4ED8;
    --db-orange-dark: #C2410C;
    --db-gold-dark:   #A16207;
    --db-red-dark:    #B91C1C;
    --db-green-dark:  #15803D;
    --db-purple-dark: #7E22CE;
    --db-teal-dark:   #0F766E;

    /* Surfaces & text — light mode */
    --db-surface:       #ffffff;
    --db-surface-2:     #F8F9FB;
    --db-border:        rgba(0,0,0,.08);
    --db-border-strong: rgba(0,0,0,.14);
    --db-text:          #111827;
    --db-text-2:        #6B7280;
    --db-text-3:        #9CA3AF;
    --db-shadow-sm:     0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
    --db-shadow-md:     0 4px 12px rgba(0,0,0,.1);
    --db-shadow-lg:     0 8px 24px rgba(0,0,0,.12);
    --db-radius-sm:     8px;
    --db-radius:        12px;
    --db-radius-lg:     16px;
}

/* Dark mode overrides — via class OR system preference */
[data-theme="dark"] {
    --db-blue-light:   #1E3A5F;
    --db-orange-light: #431407;
    --db-gold-light:   #422006;
    --db-red-light:    #450A0A;
    --db-green-light:  #052E16;
    --db-purple-light: #2E1065;
    --db-teal-light:   #042F2E;

    --db-surface:       #1A1D23;
    --db-surface-2:     #13151A;
    --db-border:        rgba(255,255,255,.08);
    --db-border-strong: rgba(255,255,255,.14);
    --db-text:          #F1F5F9;
    --db-text-2:        #94A3B8;
    --db-text-3:        #64748B;
    --db-shadow-sm:     0 1px 3px rgba(0,0,0,.3);
    --db-shadow-md:     0 4px 12px rgba(0,0,0,.4);
    --db-shadow-lg:     0 8px 24px rgba(0,0,0,.5);
}
@media (prefers-color-scheme: dark) {
    :root {
        --db-blue-light:   #1E3A5F;
        --db-orange-light: #431407;
        --db-gold-light:   #422006;
        --db-red-light:    #450A0A;
        --db-green-light:  #052E16;
        --db-purple-light: #2E1065;
        --db-teal-light:   #042F2E;

        --db-surface:       #1A1D23;
        --db-surface-2:     #13151A;
        --db-border:        rgba(255,255,255,.08);
        --db-border-strong: rgba(255,255,255,.14);
        --db-text:          #F1F5F9;
        --db-text-2:        #94A3B8;
        --db-text-3:        #64748B;
        --db-shadow-sm:     0 1px 3px rgba(0,0,0,.3);
        --db-shadow-md:     0 4px 12px rgba(0,0,0,.4);
        --db-shadow-lg:     0 8px 24px rgba(0,0,0,.5);
    }
}

/* ── Wrapper ── */
.db-wrap {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    color: var(--db-text);
}

/* ── Flash ── */
.db-flash {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .8rem 1.1rem;
    border-radius: var(--db-radius-sm);
    font-size: .875rem;
    font-weight: 500;
    max-width: 1280px;
    margin: 0 auto .25rem;
    border-left: 4px solid;
}
.db-flash--success { background: var(--db-green-light);  color: var(--db-green-dark);  border-color: var(--db-green); }
.db-flash--danger  { background: var(--db-red-light);    color: var(--db-red-dark);    border-color: var(--db-red); }
.db-flash--warning { background: var(--db-gold-light);   color: var(--db-gold-dark);   border-color: var(--db-gold); }
.db-flash--info    { background: var(--db-blue-light);   color: var(--db-blue-dark);   border-color: var(--db-blue); }

/* ── Header ── */
.db-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
}
.db-header__eyebrow {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--db-blue);
    margin: 0 0 .2rem;
}
.db-header__name {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 800;
    margin: 0 0 .25rem;
    color: var(--db-text);
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: .4rem;
}
.db-header__sub { margin: 0; color: var(--db-text-2); font-size: .9rem; }

.db-wave {
    display: inline-block;
    animation: db-wave 2.2s ease-in-out infinite;
    transform-origin: 70% 75%;
}
@keyframes db-wave {
    0%,55%,100% { transform: rotate(0deg); }
    10%,30%     { transform: rotate(20deg); }
    20%         { transform: rotate(-8deg); }
    40%         { transform: rotate(10deg); }
    50%         { transform: rotate(-5deg); }
}

/* Next exam pill */
.db-next-exam {
    display: flex;
    align-items: center;
    gap: .75rem;
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
    color: #fff;
    border-radius: var(--db-radius);
    padding: .85rem 1.15rem;
    max-width: 320px;
    flex-shrink: 0;
    box-shadow: 0 4px 20px rgba(99,102,241,.35);
}
.db-next-exam__bell {
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,.2);
    border-radius: var(--db-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.db-next-exam__eyebrow {
    display: block;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    opacity: .8;
    font-weight: 600;
}
.db-next-exam__name { display: block; font-size: .9rem; font-weight: 700; line-height: 1.3; }
.db-next-exam__when { display: block; font-size: .75rem; opacity: .75; margin-top: .1rem; }

/* ── Stat cards ── */
.db-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}
@media (min-width: 860px) { .db-stats { grid-template-columns: repeat(4, 1fr); } }

.db-stat {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    border-radius: var(--db-radius);
    box-shadow: var(--db-shadow-sm);
    text-decoration: none;
    color: var(--db-text);
    transition: transform .18s, box-shadow .18s;
    border: 1px solid var(--db-border);
    background: var(--db-surface);
}
.db-stat:hover { transform: translateY(-3px); box-shadow: var(--db-shadow-lg); text-decoration: none; color: var(--db-text); }

/* Colored top stripe */
.db-stat::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: var(--db-radius) var(--db-radius) 0 0;
}
.db-stat--blue::before   { background: var(--db-blue); }
.db-stat--orange::before { background: var(--db-orange); }
.db-stat--gold::before   { background: var(--db-gold); }
.db-stat--red::before    { background: var(--db-red); }

.db-stat__icon {
    width: 48px;
    height: 48px;
    border-radius: var(--db-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
    flex-shrink: 0;
}
.db-stat--blue   .db-stat__icon { background: var(--db-blue); }
.db-stat--orange .db-stat__icon { background: var(--db-orange); }
.db-stat--gold   .db-stat__icon { background: var(--db-gold); }
.db-stat--red    .db-stat__icon { background: var(--db-red); }

.db-stat__body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.db-stat__num  { font-size: 1.75rem; font-weight: 800; line-height: 1; color: var(--db-text); }
.db-stat__label { font-size: .78rem; color: var(--db-text-2); margin-top: .2rem; font-weight: 500; }

/* Ghost watermark icon */
.db-stat__ghost {
    position: absolute;
    right: -6px;
    bottom: -8px;
    font-size: 3.5rem;
    opacity: .06;
    pointer-events: none;
}

/* ── Block breakdown ── */
.db-breakdown {
    background: var(--db-surface);
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--db-shadow-sm);
}
.db-breakdown__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.db-breakdown__title { font-size: .9rem; font-weight: 700; color: var(--db-text); display: flex; align-items: center; gap: .4rem; }
.db-breakdown__title i { color: var(--db-purple); }
.db-breakdown__total { font-size: .8rem; color: var(--db-text-3); font-weight: 500; }

.db-breakdown__bar {
    height: 12px;
    display: flex;
    gap: 3px;
    border-radius: 99px;
    overflow: hidden;
    background: var(--db-surface-2);
    border: 1px solid var(--db-border);
    margin-bottom: .9rem;
}
.db-breakdown__seg {
    height: 100%;
    border-radius: 2px;
    min-width: 6px;
    transition: opacity .2s;
}
.db-breakdown__seg:hover { opacity: .75; cursor: default; }

.db-breakdown__chips { display: flex; flex-wrap: wrap; gap: .4rem .75rem; }
.db-breakdown__chip {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .78rem;
    color: var(--db-text-2);
    background: var(--db-surface-2);
    border: 1px solid var(--db-border);
    border-radius: 99px;
    padding: .2rem .65rem;
}
.db-breakdown__chip strong { color: var(--db-text); font-weight: 700; }
.db-breakdown__chip-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── Panel card ── */
.db-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}
@media (min-width: 860px) { .db-grid { grid-template-columns: 1fr 1fr; } }

.db-panel {
    background: var(--db-surface);
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius);
    padding: 1.35rem 1.5rem;
    box-shadow: var(--db-shadow-sm);
    min-width: 0;
    overflow: hidden;
}
.db-panel__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: .85rem;
    border-bottom: 1px solid var(--db-border);
}
.db-panel__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--db-text);
    display: flex;
    align-items: center;
    gap: .55rem;
}

/* Colored dot beside title */
.db-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.db-dot--blue   { background: var(--db-blue); }
.db-dot--red    { background: var(--db-red); }
.db-dot--gold   { background: var(--db-gold); }
.db-dot--green  { background: var(--db-green); }
.db-dot--purple { background: var(--db-purple); }

/* ── Notes list ── */
.db-note-list { display: flex; flex-direction: column; }
.db-note-row {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .7rem .4rem;
    border-radius: var(--db-radius-sm);
    transition: background .15s;
}
.db-note-row:hover { background: var(--db-surface-2); }
.db-note-row + .db-note-row { border-top: 1px solid var(--db-border); }

.db-note-row__badge {
    width: 40px; height: 40px;
    border-radius: var(--db-radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: .8rem;
    flex-shrink: 0; letter-spacing: .04em;
}
.db-note-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .12rem; }
.db-note-row__title {
    font-size: .88rem; font-weight: 600; color: var(--db-text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.db-note-row__meta {
    font-size: .74rem; color: var(--db-text-3);
    display: flex; align-items: center; gap: .3rem; flex-wrap: wrap;
}
.db-note-row__arrow {
    width: 30px; height: 30px;
    border-radius: var(--db-radius-sm);
    background: var(--db-blue-light);
    color: var(--db-blue);
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem;
    text-decoration: none;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}
.db-note-row__arrow:hover { background: var(--db-blue); color: #fff; }

/* ── Exam list ── */
.db-exam-list { display: flex; flex-direction: column; }
.db-exam-row {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .7rem .4rem;
    border-radius: var(--db-radius-sm);
    transition: background .15s;
}
.db-exam-row:hover { background: var(--db-surface-2); }
.db-exam-row + .db-exam-row { border-top: 1px solid var(--db-border); }

.db-exam-row__cal {
    width: 48px; height: 48px;
    border-radius: var(--db-radius-sm);
    background: var(--db-red-light);
    border: 1px solid rgba(239,68,68,.2);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    flex-shrink: 0;
}
.db-exam-row__day  { font-size: 1.15rem; font-weight: 800; color: var(--db-red); line-height: 1; }
.db-exam-row__mon  { font-size: .62rem; text-transform: uppercase; font-weight: 700; color: var(--db-red); opacity: .8; letter-spacing: .04em; }
.db-exam-row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.db-exam-row__name { font-size: .88rem; font-weight: 600; color: var(--db-text); }
.db-exam-row__when { font-size: .77rem; font-weight: 700; color: var(--db-red); }

/* ── View-all link ── */
.db-viewall {
    display: flex; align-items: center; justify-content: center; gap: .35rem;
    margin-top: 1rem; padding-top: .85rem;
    border-top: 1px solid var(--db-border);
    font-size: .83rem; font-weight: 600; color: var(--db-blue);
    text-decoration: none;
    transition: gap .15s;
}
.db-viewall:hover { gap: .55rem; }

/* ── Empty state ── */
.db-empty {
    display: flex; flex-direction: column; align-items: center; gap: .65rem;
    padding: 2rem 1rem; text-align: center;
}
.db-empty__icon {
    width: 54px; height: 54px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
}
.db-empty__icon { background: var(--db-surface-2); color: var(--db-text-3); border: 1px solid var(--db-border); }
.db-empty p { margin: 0; color: var(--db-text-2); font-size: .88rem; }

/* ── NESCO grid ── */
.db-nesco-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: .75rem;
}
.db-nesco-cell {
    background: var(--db-surface-2);
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius-sm);
    padding: .85rem 1rem;
}
.db-nesco-cell__label {
    display: block;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    font-weight: 700;
    color: var(--db-text-3);
    margin-bottom: .3rem;
}
.db-nesco-cell strong { font-size: .95rem; font-weight: 700; color: var(--db-text); }
.db-nesco-cell__balance { color: var(--db-green) !important; }

/* ── Buttons ── */
.db-btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .45rem .9rem;
    border-radius: var(--db-radius-sm);
    font-size: .82rem; font-weight: 700;
    text-decoration: none; cursor: pointer;
    border: none; transition: opacity .15s, transform .15s;
    white-space: nowrap;
}
.db-btn:hover   { opacity: .88; transform: translateY(-1px); }
.db-btn:active  { transform: scale(.97); }

.db-btn--blue   { background: var(--db-blue);   color: #fff; }
.db-btn--red    { background: var(--db-red);    color: #fff; }
.db-btn--green  { background: var(--db-green);  color: #fff; }
.db-btn--gold   { background: var(--db-gold);   color: #fff; }
.db-btn--ghost  { background: var(--db-surface-2); color: var(--db-text-2); border: 1px solid var(--db-border); }
.db-btn--ghost:hover { color: var(--db-text); }

/* ── Quick actions ── */
.db-actions {
    background: var(--db-surface);
    border: 1px solid var(--db-border);
    border-radius: var(--db-radius);
    padding: 1.35rem 1.5rem;
    box-shadow: var(--db-shadow-sm);
}
.db-actions__title {
    font-size: 1rem; font-weight: 700; color: var(--db-text);
    margin: 0 0 1.1rem;
    display: flex; align-items: center; gap: .4rem;
}
.db-actions__title i { color: var(--db-gold); }

.db-actions__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .85rem;
}
@media (min-width: 600px)  { .db-actions__grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .db-actions__grid { grid-template-columns: repeat(6, 1fr); } }

.db-action {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    gap: .55rem; padding: 1.1rem .75rem;
    border-radius: var(--db-radius);
    text-decoration: none;
    border: 1.5px solid var(--db-border);
    background: var(--db-surface-2);
    transition: transform .18s, box-shadow .18s, border-color .18s, background .18s;
    position: relative;
    overflow: hidden;
}
.db-action::after {
    content: '';
    position: absolute; inset: 0;
    opacity: 0;
    transition: opacity .18s;
}
.db-action:hover {
    transform: translateY(-4px);
    box-shadow: var(--db-shadow-md);
    text-decoration: none;
}

/* Per-color hover fills */
.db-action--blue:hover   { background: var(--db-blue-light);   border-color: var(--db-blue); }
.db-action--green:hover  { background: var(--db-green-light);  border-color: var(--db-green); }
.db-action--purple:hover { background: var(--db-purple-light); border-color: var(--db-purple); }
.db-action--teal:hover   { background: var(--db-teal-light);   border-color: var(--db-teal); }
.db-action--orange:hover { background: var(--db-orange-light); border-color: var(--db-orange); }
.db-action--gold:hover   { background: var(--db-gold-light);   border-color: var(--db-gold); }

.db-action__icon {
    width: 48px; height: 48px;
    border-radius: var(--db-radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; color: #fff; flex-shrink: 0;
}
.db-action--blue   .db-action__icon { background: var(--db-blue); }
.db-action--green  .db-action__icon { background: var(--db-green); }
.db-action--purple .db-action__icon { background: var(--db-purple); }
.db-action--teal   .db-action__icon { background: var(--db-teal); }
.db-action--orange .db-action__icon { background: var(--db-orange); }
.db-action--gold   .db-action__icon { background: var(--db-gold); }

.db-action__name { font-size: .83rem; font-weight: 700; color: var(--db-text); }
.db-action__hint { font-size: .72rem; color: var(--db-text-3); }

/* ── Responsive ── */
@media (max-width: 500px) {
    .db-wrap              { padding: 1.25rem .9rem; gap: 1.1rem; }
    .db-header            { flex-direction: column; }
    .db-next-exam         { max-width: 100%; }
    .db-stat__num         { font-size: 1.45rem; }
    .db-panel             { padding: 1rem 1.1rem; }
}


/* ------------------------------------------------------------
   NOTES PAGES
   ----------------------------------------------------------- */
.filters-section { background:var(--card); padding:var(--sp-2); border-radius:var(--radius-lg); box-shadow:var(--shadow-sm); margin-bottom:var(--sp-3); border:1px solid var(--border); }
.filters-form { display:flex; flex-wrap:wrap; gap:var(--sp-2); align-items:center; }
.search-wrap  { display:flex; gap:.4rem; flex:1; min-width:200px; }
.search-input { flex:1; padding:.65rem 1rem; border:2px solid var(--border); border-radius:var(--radius); font-size:.95rem; min-width:0; transition:border-color .2s; }
.search-input:focus-visible, .search-input:focus { outline:none; border-color:var(--primary); }
.filter-select { padding:.65rem 1rem; border:2px solid var(--border); border-radius:var(--radius); font-size:.95rem; background:var(--white); min-width:160px; appearance:none; -webkit-appearance:none; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%237F8C8D' d='M6 8L0 0h12z'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right .75rem center; padding-right:2rem; cursor:pointer; }
.notes-grid { display:grid; grid-template-columns:1fr; gap:var(--sp-2); }
@media(min-width:640px)  { .notes-grid { grid-template-columns:repeat(2,1fr); } }
@media(min-width:1100px) { .notes-grid { grid-template-columns:repeat(3,1fr); } }
.note-card { background:var(--card); border-radius:var(--radius-lg); box-shadow:var(--shadow-sm); border:1px solid var(--border); display:flex; flex-direction:column; transition:box-shadow .2s, transform .2s; overflow:hidden; }
.note-card:hover { box-shadow:var(--shadow-md); transform:translateY(-2px); }
.note-card-header { padding:.65rem var(--sp-2); display:flex; justify-content:space-between; align-items:center; border-bottom:1px solid var(--border); }
.note-badge { padding:.25rem .65rem; border-radius:20px; color:#fff; font-size:.75rem; font-weight:500; }
.chapter-tag { font-size:.72rem; color:var(--text-muted); border:1px solid var(--border); padding:.15rem .5rem; border-radius:20px; display:inline-flex; align-items:center; gap:.25rem; white-space:nowrap; }
.visibility-badge { display:flex; align-items:center; gap:.25rem; padding:.2rem .5rem; background:var(--info); color:#fff; border-radius:12px; font-size:.72rem; }
.note-card-body    { padding:var(--sp-2); flex:1; }
.note-card-body h3 { font-size:1rem; margin-bottom:.5rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.note-excerpt  { color:var(--text-muted); font-size:.87rem; line-height:1.5; margin-bottom:.5rem; }
.note-attachment { margin-top:.5rem; padding:.4rem .65rem; background:var(--bg); border-radius:var(--radius-sm); font-size:.8rem; color:var(--text-muted); display:flex; align-items:center; gap:.3rem; }
.note-card-footer  { padding:.75rem var(--sp-2); border-top:1px solid var(--border); display:flex; gap:.5rem; flex-wrap:wrap; }
.note-card-footer .btn { flex:1; justify-content:center; min-width:80px; }

/* Note view */
.note-view-container { max-width:860px; margin:0 auto; padding:var(--sp-3) var(--sp-2); }
.note-view-header { background:var(--card); border-radius:var(--radius-lg); padding:var(--sp-3); box-shadow:var(--shadow-sm); border:1px solid var(--border); margin-bottom:var(--sp-3); }
.note-view-header h1 { font-size:clamp(1.25rem,3vw,1.8rem); margin-bottom:var(--sp-2); }
.note-view-body { background:var(--card); border-radius:var(--radius-lg); padding:var(--sp-3) clamp(var(--sp-2),4vw,var(--sp-5)); box-shadow:var(--shadow-sm); border:1px solid var(--border); }
.note-file-card { display:flex; align-items:flex-start; gap:var(--sp-2); padding:var(--sp-2) var(--sp-3); background:var(--bg); border-radius:var(--radius-lg); border:1px solid var(--border); margin-bottom:var(--sp-3); font-size:.93rem; }
.note-file-card i { font-size:1.6rem; color:var(--primary); flex-shrink:0; margin-top:.1rem; }

/* Share banner */
.share-banner { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:var(--sp-2); padding:var(--sp-2) var(--sp-3); background:linear-gradient(135deg,var(--primary),#667eea); border-radius:var(--radius-lg); color:#fff; margin-bottom:var(--sp-3); }
.share-url-box { display:flex; align-items:center; gap:.5rem; background:rgba(255,255,255,.15); border-radius:var(--radius); padding:.4rem .75rem; flex:1; min-width:0; max-width:500px; }
.share-url-box input { background:transparent; border:none; color:#fff; font-size:.85rem; flex:1; min-width:0; outline:none; }

/* Note create/edit specific */
.chapter-row { display:none; }
.vis-cards   { display:flex; gap:.75rem; flex-wrap:wrap; }
.vis-card { flex:1; min-width:140px; border:2px solid var(--border); border-radius:var(--radius); padding:.9rem 1rem; cursor:pointer; transition:all .2s; display:flex; align-items:center; gap:.6rem; }
.vis-card:hover   { border-color:var(--primary); background:var(--primary-light); }
.vis-card input[type="radio"] { display:none; }
.vis-card.selected { border-color:var(--primary); background:var(--primary-light); }
.vis-card i { font-size:1.1rem; color:var(--primary); }
.file-drop { border:2px dashed var(--border); border-radius:var(--radius); padding:1.5rem; text-align:center; cursor:pointer; transition:all .2s; background:var(--bg); }
.file-drop:hover, .file-drop.over { border-color:var(--primary); background:var(--primary-light); }
.file-drop input { display:none; }
.quill-wrap { border:2px solid var(--border); border-radius:var(--radius); overflow:hidden; background:#fff; transition:border-color .2s; }
.quill-wrap:focus-within { border-color:var(--primary); }
.ql-toolbar.ql-snow  { border:none; border-bottom:2px solid var(--border); background:#f8fafc; }
.ql-container.ql-snow { border:none; }
#quill-editor { min-height:360px; font-family:'Noto Sans Bengali',sans-serif; font-size:1rem; line-height:1.8; }

/* Rendered note content */
.note-rendered, .note-rendered p, .note-rendered li, .note-rendered blockquote { font-family:'Noto Sans Bengali',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; font-size:1.02rem; line-height:1.9; color:var(--text); }
.note-rendered p:last-child { margin-bottom: 0; }
.note-rendered h1 { font-size:1.7rem; margin:1.4rem 0 .6rem; border-bottom:2px solid var(--border); padding-bottom:.35rem; }
.note-rendered h2 { font-size:1.35rem; margin:1.2rem 0 .5rem; }
.note-rendered h3 { font-size:1.1rem; margin:1rem 0 .4rem; }
.note-rendered blockquote { border-left:4px solid var(--primary); background:var(--primary-light); padding:.75rem 1rem; border-radius:0 var(--radius) var(--radius) 0; margin:1rem 0; color:var(--dark); }
.note-rendered code { background:#f1f3f5; border-radius:4px; padding:.15em .4em; font-family:'Fira Code','Courier New',monospace; font-size:.88em; color:#c0392b; }
.note-rendered pre { background:#1e1e2e; color:#cdd6f4; border-radius:var(--radius); padding:1rem 1.2rem; overflow-x:auto; font-size:.88rem; margin:1rem 0; }
.note-rendered pre code { background:none; color:inherit; padding:0; }
.note-rendered table { width:100%; border-collapse:collapse; margin:1rem 0; font-size:.93rem; }
.note-rendered th { background:var(--primary); color:#fff; padding:.6rem .8rem; text-align:left; }
.note-rendered td { padding:.55rem .8rem; border-bottom:1px solid var(--border); }
.note-rendered tr:nth-child(even) td { background:var(--bg); }
.note-rendered img { border-radius:var(--radius); max-width:100%; margin:1rem auto; display:block; box-shadow:var(--shadow-md); }
.note-rendered hr  { border:none; border-top:2px solid var(--border); margin:1.5rem 0; }
.note-rendered mark { background:#fff176; padding:.1em .25em; border-radius:3px; }
.note-rendered ol, .note-rendered ul { padding-left:1.5rem; margin:.5rem 0; }
.note-rendered li { margin-bottom:.2rem; }
.note-rendered a  { color:var(--primary); text-decoration:underline; }
.note-rendered .katex-display { overflow-x:auto; padding:.5rem 0; margin:.75rem 0; }
.note-rendered .katex { font-size:1.1em; }
.note-rendered pre.ql-syntax { background:#1e1e2e; color:#cdd6f4; border-radius:var(--radius); padding:1rem 1.2rem; overflow-x:auto; font-size:.88rem; margin:1rem 0; }
.note-rendered .ql-formula { background:#f5f7ff; padding:2px 8px; border-radius:4px; color:var(--primary); }
.note-rendered.ql-editor { padding:0 !important; border:none !important; }
.ql-editor { font-family:'Noto Sans Bengali',-apple-system,sans-serif; font-size:1rem; line-height:1.85; }

/* ------------------------------------------------------------
   EXAMS PAGE
   ----------------------------------------------------------- */
.exams-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(260px,1fr)); gap:var(--sp-2); }
.exam-card  { background:var(--card); border-radius:var(--radius-lg); border:1px solid var(--border); box-shadow:var(--shadow-sm); display:flex; align-items:stretch; overflow:hidden; transition:box-shadow .2s, transform .2s; }
.exam-card:hover { box-shadow:var(--shadow-md); transform:translateY(-2px); }
.exam-card.past { opacity:.75; }
.exam-card-date { display:flex; flex-direction:column; align-items:center; justify-content:center; padding:1rem .85rem; min-width:64px; flex-shrink:0; color:#fff; text-align:center; }
.exam-card-date .day   { font-size:1.6rem; font-weight:700; line-height:1; }
.exam-card-date .month { font-size:.7rem; text-transform:uppercase; margin-top:.1rem; }
.exam-card-date .year  { font-size:.65rem; opacity:.8; margin-top:.1rem; }
.exam-card-body { flex:1; padding:.85rem var(--sp-2); min-width:0; }
.exam-card-body h3 { margin:0 0 .3rem; font-size:.95rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.exam-card-actions { display:flex; flex-direction:column; justify-content:center; gap:.35rem; padding:.6rem .75rem; flex-shrink:0; }
.countdown-urgent { color:var(--danger);    font-weight:700; font-size:.85rem; }
.countdown-soon   { color:var(--warning);   font-weight:700; font-size:.85rem; }
.countdown-normal { color:var(--secondary); font-weight:700; font-size:.85rem; }

/* ------------------------------------------------------------
   TIMER PAGE
   ----------------------------------------------------------- */
.timer-container { display:grid; grid-template-columns:1fr; gap:var(--sp-3); }
@media(min-width:900px){ .timer-container { grid-template-columns:2fr 1fr; } }
.timer-main { background:var(--card); border-radius:var(--radius-lg); padding:clamp(var(--sp-2),5vw,var(--sp-5)); box-shadow:var(--shadow-sm); border:1px solid var(--border); text-align:center; }
.timer-mode-selector { display:flex; flex-wrap:wrap; gap:.5rem; margin-bottom:var(--sp-3); justify-content:center; }
.mode-btn { padding:.5rem 1rem; border:2px solid var(--border); background:transparent; border-radius:var(--radius); cursor:pointer; transition:all .2s; display:flex; align-items:center; gap:.35rem; font-size:.85rem; white-space:nowrap; }
.mode-btn:hover  { border-color:var(--primary); background:var(--primary-light); }
.mode-btn.active { background:var(--primary); color:#fff; border-color:var(--primary); }
.timer-display { margin:var(--sp-3) 0; }
.timer-circle  { position:relative; display:inline-block; }
.timer-svg     { transform:rotate(-90deg); width:clamp(200px,60vw,280px); height:clamp(200px,60vw,280px); }
.timer-track, .timer-bg { fill:none; stroke:var(--border); stroke-width:10; }
.timer-progress { fill:none; stroke:var(--primary); stroke-width:10; stroke-linecap:round; transition:stroke-dashoffset 1s linear; }
.timer-time    { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); font-size:clamp(2.5rem,10vw,4rem); font-weight:700; color:var(--dark); line-height:1; }
.timer-label   { font-size:.9rem; color:var(--text-muted); margin-top:.3rem; }
.timer-controls { display:flex; gap:var(--sp-2); justify-content:center; flex-wrap:wrap; margin:var(--sp-3) 0; }
.timer-stats    { background:var(--card); border-radius:var(--radius-lg); padding:var(--sp-3); box-shadow:var(--shadow-sm); border:1px solid var(--border); }
.timer-stats h3 { font-size:1rem; margin-bottom:var(--sp-2); display:flex; align-items:center; gap:.4rem; }
.stats-row  { display:flex; gap:var(--sp-2); }
.stat-pill  { flex:1; background:var(--bg); border-radius:var(--radius); padding:var(--sp-2); text-align:center; border:1px solid var(--border); }
.stat-num   { display:block; font-size:2rem; font-weight:700; color:var(--primary); line-height:1.1; }
.stat-label { display:block; font-size:.78rem; color:var(--text-muted); margin-top:.2rem; }
.timer-notification { position:fixed; top:80px; right:-400px; background:var(--white); padding:var(--sp-2) var(--sp-3); border-radius:var(--radius); box-shadow:var(--shadow-lg); z-index:1000; max-width:280px; transition:right .3s ease; border-left:4px solid var(--primary); }
.timer-notification.show { right:var(--sp-2); }

/* ------------------------------------------------------------
   SUBJECTS PAGE
   ----------------------------------------------------------- */
.subjects-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(220px,1fr)); gap:var(--sp-3); }
.subject-card { background:var(--card); padding:var(--sp-2) var(--sp-3); border-radius:var(--radius-lg); box-shadow:var(--shadow-sm); transition:all .2s; border:1px solid var(--border); display:flex; align-items:center; gap:var(--sp-2); }
.subject-card:hover { box-shadow:var(--shadow-md); transform:translateY(-2px); }
.subject-icon { width:50px; height:50px; flex-shrink:0; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:1rem; font-weight:700; color:#fff; }
.subject-info { flex:1; min-width:0; }
.subject-info h3 { margin:0 0 .15rem; font-size:.95rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.subject-info p  { margin:0; font-size:.82rem; color:var(--text-muted); }
.subject-stats   { margin-bottom:var(--sp-2); padding:.4rem; background:var(--bg); border-radius:var(--radius-sm); font-size:.85rem; }

/* ------------------------------------------------------------
   PROFILE PAGE
   ----------------------------------------------------------- */
.profile-container { display:grid; grid-template-columns:1fr; gap:var(--sp-3); }
@media(min-width:900px){ .profile-container { grid-template-columns:300px 1fr; } }
.profile-sidebar { background:var(--card); padding:var(--sp-3); border-radius:var(--radius-lg); box-shadow:var(--shadow-sm); text-align:center; border:1px solid var(--border); height:fit-content; }
.profile-avatar-wrap   { position:relative; width:96px; height:96px; margin:0 auto var(--sp-2); }
.profile-avatar-circle { width:96px; height:96px; border-radius:50%; background:var(--primary); color:#fff; font-size:2.5rem; font-weight:700; display:flex; align-items:center; justify-content:center; position:relative; z-index:1; box-shadow:0 4px 16px rgba(74,144,226,.35); }
.profile-avatar-ring   { position:absolute; inset:-4px; border-radius:50%; border:3px solid var(--primary); opacity:.3; animation:ringPulse 2.5s ease-in-out infinite; }
@keyframes ringPulse { 0%,100%{ transform:scale(1); opacity:.3; } 50%{ transform:scale(1.08); opacity:.12; } }
.profile-avatar  { font-size:4rem; color:var(--primary); margin-bottom:var(--sp-2); line-height:1; }
.profile-name    { font-size:1.2rem; margin:0 0 .2rem; }
.profile-email   { font-size:.85rem; color:var(--text-muted); margin-bottom:.75rem; }
.profile-badge   { display:inline-block; padding:.35rem .9rem; background:var(--primary); color:#fff; border-radius:20px; font-size:.82rem; margin-bottom:var(--sp-3); }
.profile-role-badge         { display:inline-flex; align-items:center; gap:.35rem; padding:.3rem .85rem; border-radius:20px; font-size:.8rem; font-weight:600; color:#fff; margin-bottom:var(--sp-3); }
.profile-role-badge.admin   { background:var(--danger); }
.profile-role-badge.student { background:var(--primary); }
.profile-stats-row { display:flex; align-items:center; padding:var(--sp-2) 0; border-top:1px solid var(--border); border-bottom:1px solid var(--border); margin-bottom:var(--sp-3); width:100%; }
.profile-stats { display:flex; flex-direction:column; gap:var(--sp-2); margin:var(--sp-2) 0; padding:var(--sp-2) 0; border-top:2px solid var(--border); border-bottom:2px solid var(--border); }
.profile-stats .stat { display:flex; align-items:center; gap:var(--sp-2); padding:.65rem; background:var(--bg); border-radius:var(--radius); }
.profile-stats .stat i { font-size:1.25rem; color:var(--primary); }
.profile-info  { font-size:.85rem; color:var(--text-muted); }
.pstat-item    { flex:1; text-align:center; }
.pstat-divider { width:1px; background:var(--border); align-self:stretch; }
.pstat-value   { display:block; font-size:1.1rem; font-weight:700; color:var(--dark); line-height:1.1; }
.pstat-label   { display:block; font-size:.72rem; color:var(--text-muted); margin-top:.2rem; }
.pstat-label i { margin-right:.2rem; }
.subject-breakdown { width:100%; text-align:left; }
.breakdown-title { font-size:.72rem; font-weight:700; color:var(--text-muted); text-transform:uppercase; letter-spacing:.07em; margin-bottom:.6rem; }
.breakdown-row   { display:flex; align-items:center; gap:.45rem; margin-bottom:.45rem; font-size:.82rem; }
.breakdown-dot   { width:8px; height:8px; border-radius:50%; flex-shrink:0; }
.breakdown-name  { width:110px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; flex-shrink:0; }
.breakdown-bar-wrap { flex:1; height:5px; background:var(--border); border-radius:4px; overflow:hidden; }
.breakdown-bar   { height:100%; border-radius:4px; transition:width .4s; }
.breakdown-count { font-weight:700; font-size:.82rem; width:20px; text-align:right; }
.profile-main { display:flex; flex-direction:column; gap:var(--sp-3); }
.profile-tabs { display:flex; gap:.4rem; flex-wrap:wrap; border-bottom:2px solid var(--border); margin-bottom:var(--sp-3); }
.ptab { background:none; border:none; padding:.6rem 1.1rem; font-size:.9rem; font-weight:500; cursor:pointer; color:var(--text-muted); border-bottom:2px solid transparent; margin-bottom:-2px; display:flex; align-items:center; gap:.35rem; transition:all .2s; }
.ptab:hover  { color:var(--primary); }
.ptab.active { color:var(--primary); border-bottom-color:var(--primary); }
.ptab-panel  { display:none; }
.ptab-panel.active { display:block; }
.profile-section { background:var(--card); padding:var(--sp-3); border-radius:var(--radius-lg); box-shadow:var(--shadow-sm); border:1px solid var(--border); }
.profile-section h3 { font-size:1rem; margin-bottom:var(--sp-2); padding-bottom:var(--sp-2); border-bottom:2px solid var(--border); display:flex; align-items:center; gap:.4rem; }
.profile-section-header { margin-bottom:var(--sp-3); padding-bottom:var(--sp-2); border-bottom:1px solid var(--border); }
.profile-section-header h3 { margin:0 0 .2rem; font-size:1.05rem; border:none; padding:0; }
.profile-section-header p  { margin:0; font-size:.85rem; color:var(--text-muted); }
.info-grid  { display:grid; grid-template-columns:repeat(auto-fit, minmax(160px,1fr)); gap:var(--sp-2); }
.info-item  { padding:var(--sp-2); background:var(--bg); border-radius:var(--radius); }
.info-label { display:block; font-size:.78rem; color:var(--text-muted); margin-bottom:.25rem; }
.info-value { display:block; font-weight:600; }
.pform-row  { display:grid; grid-template-columns:1fr; gap:0 var(--sp-2); }
@media(min-width:580px){ .pform-row { grid-template-columns:1fr 1fr; } }
.input-icon-wrap { position:relative; }
.input-icon-wrap input { padding-right:2.6rem; }
.eye-btn { position:absolute; right:.75rem; top:50%; transform:translateY(-50%); background:none; border:none; cursor:pointer; color:var(--text-muted); padding:.2rem; transition:color .2s; }
.eye-btn:hover { color:var(--primary); }
.strength-wrap   { margin-bottom:var(--sp-2); }
.strength-track  { height:4px; background:var(--border); border-radius:4px; overflow:hidden; margin-bottom:.3rem; }
.strength-bar    { height:100%; width:0; border-radius:4px; transition:width .3s, background .3s; }
.strength-labels { display:flex; justify-content:space-between; font-size:.78rem; }
.lang-picker { display:flex; gap:.75rem; flex-wrap:wrap; }
.lang-opt { display:flex; align-items:center; gap:.5rem; padding:.6rem 1rem; border:2px solid var(--border); border-radius:var(--radius); cursor:pointer; transition:all .2s; font-size:.9rem; }
.lang-opt input[type="radio"] { display:none; }
.lang-opt:hover    { border-color:var(--primary); background:var(--primary-light); }
.lang-opt.selected { border-color:var(--primary); background:var(--primary-light); font-weight:600; }
.lang-flag { font-size:1.1rem; }
.req { color:var(--danger); }

/* ------------------------------------------------------------
   CHAPTERS PAGE
   ----------------------------------------------------------- */
.admin-subnav { display:flex; flex-wrap:wrap; gap:.4rem; margin-bottom:var(--sp-3); padding:.5rem; background:var(--card); border-radius:var(--radius-lg); border:1px solid var(--border); box-shadow:var(--shadow-sm); }
.admin-subnav a { display:flex; align-items:center; gap:.4rem; padding:.45rem .9rem; border-radius:var(--radius-sm); font-size:.88rem; font-weight:500; color:var(--text); transition:all .15s; }
.admin-subnav a:hover  { background:var(--primary-light); color:var(--primary); }
.admin-subnav a.active { background:var(--primary); color:#fff; }
.admin-subnav a.disabled { background:var(--bg); color:var(--text-muted); border:1px dashed var(--border); opacity:.7;  cursor:not-allowed; }
.admin-subnav a.disabled:hover { background:var(--bg); color:var(--text-muted); }
.chapter-add-card { background:var(--card); border-radius:var(--radius-lg); border:1px solid var(--border); box-shadow:var(--shadow-sm); padding:var(--sp-3); margin-bottom:var(--sp-3); }
.chapter-add-header { margin-bottom:var(--sp-2); }
.chapter-add-header h3 { font-size:1rem; margin:0 0 .2rem; display:flex; align-items:center; gap:.4rem; }
.chapter-add-header p  { font-size:.85rem; color:var(--text-muted); margin:0; }
.chapter-add-form { margin-top:var(--sp-2); }
.chapter-add-fields { display:grid; grid-template-columns:repeat(auto-fit, minmax(170px,1fr)); gap:.75rem var(--sp-2); align-items:end; }
.chapter-add-fields .form-group { margin-bottom:0; }
.chapter-add-btn { display:flex; align-items:flex-end; }
.chapters-list  { display:flex; flex-direction:column; gap:var(--sp-2); }
.chapter-group-card { background:var(--card); border-radius:var(--radius-lg); border:1px solid var(--border); box-shadow:var(--shadow-sm); overflow:hidden; }
.chapter-group-header { display:flex; align-items:center; justify-content:space-between; padding:.75rem var(--sp-3); background:var(--bg); border-bottom:1px solid var(--border); }
.chapter-group-title  { display:flex; align-items:center; gap:.5rem; font-size:.95rem; }
.subject-color-dot    { width:10px; height:10px; border-radius:50%; flex-shrink:0; }
.chapter-count-badge  { font-size:.75rem; color:var(--text-muted); background:var(--card); padding:.15rem .5rem; border-radius:12px; border:1px solid var(--border); }
.chapter-rows { padding:.25rem 0; }
.chapter-row-item { border-bottom:1px solid var(--border); }
.chapter-row-item:last-child { border-bottom:none; }
.chrow-view { display:flex; align-items:center; gap:var(--sp-2); padding:.7rem var(--sp-3); transition:background .15s; }
.chrow-view:hover { background:var(--bg); }
.ch-order   { width:28px; height:28px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:.78rem; font-weight:700; flex-shrink:0; }
.ch-info    { flex:1; min-width:0; }
.ch-name    { display:block; font-weight:500; font-size:.93rem; }
.ch-desc    { display:block; font-size:.78rem; color:var(--text-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.ch-actions { display:flex; gap:.4rem; flex-shrink:0; }
.chrow-edit { padding:.75rem var(--sp-3); background:#fffbf0; border-top:1px solid #f5e79e; }
.chedit-fields { display:flex; flex-wrap:wrap; gap:.6rem var(--sp-2); align-items:flex-end; }
.chedit-fields .form-group { margin-bottom:0; }
.chedit-btns { display:flex; gap:.4rem; align-items:flex-end; padding-bottom:2px; }

/* -- Responsive --------------------------------------------- */
@media(max-width:480px){
  .page-container, .dashboard-container { padding:var(--sp-2) var(--sp-1); }
  .stats-grid { grid-template-columns:1fr 1fr; gap:var(--sp-1); }
  .stat-card  { padding:var(--sp-1) var(--sp-2); }
  .stat-icon  { width:42px; height:42px; font-size:1.25rem; }
  .stat-info h3 { font-size:1.25rem; }
  .note-card-footer { flex-direction:column; }
  .note-card-footer .btn { width:100%; }
  .timer-controls { flex-direction:column; align-items:center; }
  .timer-controls .btn { width:100%; max-width:260px; }
  .mode-btn { font-size:.78rem; padding:.4rem .7rem; }
  h1 { font-size:1.35rem; }
  .chapter-add-fields { grid-template-columns:1fr; }
  .chedit-fields { flex-direction:column; }
  .exams-grid { grid-template-columns:1fr; }
  .stats-row  { flex-direction:column; }
}

/* -- Utilities ---------------------------------------------- */
.text-muted   { color:var(--text-muted); }
.text-primary { color:var(--primary); }
.text-danger  { color:var(--danger); }
.mt-1 { margin-top:var(--sp-1); }
.mt-2 { margin-top:var(--sp-2); }
.mb-2 { margin-bottom:var(--sp-2); }
.d-flex { display:flex; }
.align-center { align-items:center; }
.gap-1 { gap:var(--sp-1); }
.gap-2 { gap:var(--sp-2); }
.w-100 { width:100%; }
.form-control { width:100%; padding:.65rem 1rem; border:2px solid var(--border); border-radius:var(--radius); font-size:.95rem; font-family:inherit; background:var(--white); }
.form-control:focus-visible, .form-control:focus { outline:none; border-color:var(--primary); }
.EasyMDEContainer .CodeMirror { font-family:'Noto Sans Bengali','SolaimanLipi',monospace; font-size:1rem; line-height:1.85; }
.EasyMDEContainer .editor-toolbar { flex-wrap:wrap !important; }
.EasyMDEContainer .editor-toolbar button { font-size:1rem !important; }
.CodeMirror { border-radius:0 0 var(--radius) var(--radius) !important; font-size:.95rem !important; }

/* SUBJECTS BROWSE (with chapters) */
.subjects-browse { display:grid; grid-template-columns:repeat(auto-fill, minmax(300px,1fr)); gap:var(--sp-3); }
.subject-browse-card { background:var(--card); border-radius:var(--radius-lg); border:1px solid var(--border); box-shadow:var(--shadow-sm); overflow:hidden; transition:box-shadow .2s; }
.subject-browse-card:hover { box-shadow:var(--shadow-md); }
.subject-browse-header { display:flex; align-items:center; gap:var(--sp-2); padding:var(--sp-2) var(--sp-3); text-decoration:none; color:inherit; border-bottom:1px solid var(--border); transition:background .15s; }
.subject-browse-header:hover { background:var(--bg); }
.subject-browse-icon { width:44px; height:44px; border-radius:var(--radius); flex-shrink:0; display:flex; align-items:center; justify-content:center; font-size:.95rem; font-weight:700; color:#fff; }
.subject-browse-info { flex:1; min-width:0; }
.subject-browse-info strong { display:block; font-size:.95rem; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.subject-browse-info span  { display:block; font-size:.8rem; color:var(--text-muted); margin-top:.1rem; }
.subject-chapters-list { padding:.25rem 0; }
.subject-chapter-link { display:flex; align-items:center; gap:.6rem; padding:.55rem var(--sp-3); text-decoration:none; color:inherit; font-size:.88rem; transition:background .15s; }
.subject-chapter-link:hover { background:var(--bg); }
.subject-chapter-num  { width:22px; height:22px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:.72rem; font-weight:700; flex-shrink:0; }
.subject-chapter-name { font-weight:500; flex-shrink:0; }
.subject-chapter-desc { color:var(--text-muted); font-size:.78rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; flex:1; min-width:0; padding-left:.25rem; }

/* ============================================================
   SUBJECTS — collapsible toggle header
   ============================================================ */
.subject-browse-header-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  min-height: 64px;
}
.subject-browse-link {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  text-decoration: none;
  color: inherit;
  transition: background .15s;
  min-width: 0;
}
.subject-browse-link:hover { background: var(--bg); }
/* Override old .subject-browse-header styles for the link portion */
.subject-browse-header-row .subject-browse-header {
  border-bottom: none;
}
.subject-toggle-btn {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem .85rem;
  margin-right: .75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: all .2s;
  flex-shrink: 0;
}
.subject-toggle-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.subject-toggle-btn .toggle-icon {
  font-size: .75rem;
  transition: transform .28s ease;
}
.subject-no-chapters {
  font-size: .78rem;
  color: var(--text-muted);
  padding: .4rem .85rem;
  margin-right: .75rem;
  white-space: nowrap;
}

/* ============================================================
   NOTE FORM — responsive subject+chapter row
   ============================================================ */
.note-subject-chapter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: var(--sp-2);
}
@media (max-width: 600px) {
  .note-subject-chapter-row {
    grid-template-columns: 1fr;
    gap: .75rem;
  }
}
.note-subject-chapter-row .form-group {
  margin-bottom: 0;
}

/* ============================================================
   NOTE CARD FOOTER — fix odd mixed-size buttons on mobile
   ============================================================ */
.note-card-footer {
  display: flex;
  gap: .5rem;
  flex-wrap: nowrap;
  align-items: center;
  padding: .65rem var(--sp-2);
}
.note-card-footer .btn {
  flex: 1;
  justify-content: center;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}
.note-card-footer form {
  flex-shrink: 0;
}
.note-card-footer form .btn {
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  justify-content: center;
}
@media (max-width: 400px) {
  .note-card-footer {
    flex-wrap: wrap;
  }
  .note-card-footer .btn,
  .note-card-footer form .btn {
    flex: 1;
    width: auto;
    height: auto;
    padding: .4rem .6rem;
    border-radius: var(--radius-sm);
    font-size: .82rem;
  }
}

/* ============================================================
   GENERAL MOBILE RESPONSIVENESS FIXES
   ============================================================ */

/* Page header wraps cleanly on small screens */
.page-header {
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.page-header h1 { font-size: clamp(1.15rem, 4vw, 1.8rem); }

/* Filters form stacks on narrow screens */
@media (max-width: 520px) {
  .filters-form {
    flex-direction: column;
    align-items: stretch;
  }
  .search-wrap { min-width: 0; }
  .filter-select { min-width: 0; width: 100%; }
}

/* Exam grid: single column on very small screens */
@media (max-width: 420px) {
  .exams-grid { grid-template-columns: 1fr; }
  .exam-card-actions { flex-direction: row; justify-content: flex-end; padding: .5rem; }
}

/* Stats grid: always 2-col even on tiny screens */
@media (max-width: 360px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: .4rem; }
  .stat-card { padding: .6rem; }
  .stat-icon { width: 36px; height: 36px; font-size: 1rem; }
  .stat-info h3 { font-size: 1.1rem; }
}

/* Admin table: horizontal scroll on mobile */
.table-responsive { overflow-x: auto; overscroll-behavior-x: contain; }

/* Form actions stack on very small screens */
@media (max-width: 400px) {
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; justify-content: center; }
}

/* Note view container full-width on mobile */
@media (max-width: 600px) {
  .note-view-container { padding: var(--sp-2) var(--sp-1); }
  .note-view-body { padding: var(--sp-2); }
}

/* Subjects browse grid: single column on narrow */
@media (max-width: 480px) {
  .subjects-browse { grid-template-columns: 1fr; }
}

/* ============================================================
   VIEW — block renderer
   ============================================================ */
.note-view-topbar {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  margin-bottom: var(--sp-2);
}
.note-view-meta {
  display: flex; flex-wrap: wrap; gap: .4rem; align-items: center;
  margin-bottom: .5rem;
}
.note-view-title { font-size: clamp(1.25rem,3vw,1.75rem); margin: .25rem 0 .35rem; }
.type-pill-row   { display: flex; flex-wrap: wrap; gap: .25rem; }
.type-pill {
  display: inline-flex; align-items: center; gap: .2rem;
  padding: .12rem .45rem; border-radius: 10px;
  font-size: .68rem; font-weight: 700; color: #fff;
}

.note-blocks-view { display: flex; flex-direction: column; gap: .6rem; margin-top: var(--sp-2); }

/* base block */
.vb {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem var(--sp-2);
  position: relative;
  transition: box-shadow .15s;
}
.vb:hover        { box-shadow: var(--shadow-sm); }
.vb.vb-starred   { border-color: #f8c200; }
.vb-star-pin     { position: absolute; top: .5rem; right: .5rem; font-size: .75rem; color: #d4ac0d; }

/* text */
.vb-text { font-size: .97rem; line-height: 1.8; white-space: pre-wrap; }

/* definition */
.vb-definition   { border-left: 3px solid #E67E22; background: #fffcf5; }
.vb-def-wrap     { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem var(--sp-2); }
.vb-term         { font-weight: 700; font-size: .97rem; color: #B7510C; flex-shrink: 0; }
.vb-sep          { color: var(--text-muted); flex-shrink: 0; }
.vb-meaning      { flex: 1; font-size: .93rem; line-height: 1.6; min-width: 160px; }

/* pair */
.vb-pair         { border-left: 3px solid #16A085; background: #f2fbf8; }
.vb-pair-row     { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .75rem; }
.vb-pair-key     { font-weight: 700; font-size: .97rem; color: #0E7668; flex-shrink: 0; }
.vb-pair-arrow   { color: var(--text-muted); flex-shrink: 0; }
.vb-pair-value   { flex: 1; font-size: .93rem; line-height: 1.6; min-width: 160px; }

/* Q&A */
.vb-qa           { border-left: 3px solid #2980B9; }
.vb-qa-q         { display: flex; align-items: flex-start; gap: .5rem; font-weight: 600; font-size: .95rem; }
.vb-qa-q i       { color: #2980B9; flex-shrink: 0; margin-top: .15rem; }
.vb-qa-a         { display: flex; align-items: flex-start; gap: .5rem; font-size: .93rem;
                   color: #155724; background: #d4edda; padding: .45rem .7rem;
                   border-radius: var(--radius-sm); margin-top: .3rem; }
.vb-qa-a i       { color: var(--secondary); flex-shrink: 0; margin-top: .15rem; }

/* highlight */
.vb-highlight    { border-left: 4px solid; background: #f8fffb; font-weight: 500; font-size: .97rem; line-height: 1.6; }

/* formula */
.vb-formula      { border-left: 3px solid #8E44AD; background: #fdf8ff; }
.vb-formula-eq   { font-family: 'Fira Code','Courier New',monospace; font-size: 1.05rem;
                   font-weight: 600; color: #6c3483;
                   background: #f3e5f5; display: inline-block;
                   padding: .3rem .75rem; border-radius: var(--radius-sm); }
.vb-formula-note { font-size: .85rem; color: var(--text-muted); margin-top: .35rem; }

/* mnemonic */
.vb-mnemonic        { border-left: 3px solid #C0392B; background: #fff8f8; }
.vb-mnemonic-title  { display: flex; align-items: center; gap: .5rem;
                       font-weight: 700; color: #922B21; font-size: .97rem; }
.vb-mnemonic-title i { color: #E74C3C; }
.vb-mnemonic-body    { font-size: .9rem; color: var(--text); margin-top: .35rem;
                        line-height: 1.6; white-space: pre-wrap; }

/* tree node */
.vb-tree_node    { border-left: 3px solid #16A085; background: #f0fbf9; }
.vb-node-wrap    { display: flex; align-items: flex-start; gap: .6rem; }
.vb-node-dot     { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: .35rem; }
.vb-node-label   { font-weight: 600; font-size: .97rem; color: var(--dark); }
.vb-node-note    { font-size: .85rem; color: var(--text-muted); margin-top: .2rem; }

/* table */
.vb-table-wrap   { overflow-x: auto; }
.vb-table        { width: 100%; border-collapse: collapse; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.vb-table th     { border: 1px solid var(--border); padding: .45rem .55rem; font-size: .92rem; line-height: 1.5; min-width: 96px; vertical-align: top; background: #eef5ff; font-weight: 700; text-align: left; }
.vb-table td     { border: 1px solid var(--border); padding: .45rem .55rem; font-size: .92rem; line-height: 1.5; min-width: 96px; vertical-align: top; background: var(--white); }
.vb-table tr:nth-child(even) td { background: #fafcff; }

.be-table-wrap   { display: flex; flex-direction: column; gap: .45rem; }
.be-table-hd     { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between; align-items: center; }
.be-table-meta   { font-size: .82rem; font-weight: 700; color: var(--text-muted); display: inline-flex; align-items: center; gap: .35rem; }
.be-table-actions{ display: flex; flex-wrap: wrap; gap: .45rem; }
.be-table-actions .be-btn {
  width: auto;
  min-height: 32px;
  padding: .3rem .65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--white);
  color: var(--text);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .01em;
  box-shadow: 0 1px 1px rgba(0,0,0,.03);
}
.be-table-actions .be-btn i { font-size: .76rem; }
.be-table-actions .be-btn:hover {
  background: var(--bg);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.be-table-actions .be-btn:active {
  transform: translateY(0);
  box-shadow: none;
}
.be-table-toggle-header {
  background: #f4f8ff;
  color: var(--primary);
  border-color: rgba(44,123,229,.18);
}
.be-table-add-row-above,
.be-table-add-row-below {
  background: rgba(44,123,229,.08);
  color: var(--primary-dark);
  border-color: rgba(44,123,229,.16);
}
.be-table-add-col-left,
.be-table-add-col-right {
  background: rgba(22,160,133,.08);
  color: #138a72;
  border-color: rgba(22,160,133,.18);
}
.be-table-del-row,
.be-table-del-col {
  background: rgba(231,76,60,.08);
  color: var(--danger);
  border-color: rgba(231,76,60,.18);
}
.be-table-editor { width: 100%; border-collapse: collapse; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.be-table-editor td { border: 1px solid var(--border); padding: .12rem; background: var(--white); }
.be-table-editor th { border: 1px solid var(--border); padding: .12rem; background: #eef5ff; }
.be-table-header-row .be-table-cell { font-weight: 700; background: #f4f8ff; }
.be-table-cell   { width: 100%; min-width: 72px; border: none !important; border-radius: 0 !important; padding: .45rem .5rem; font-size: .9rem; box-shadow: none !important; }
.be-table-cell:focus { outline: none; box-shadow: inset 0 0 0 1px var(--primary); }
.be-table-row-header { background: #f7fff6; font-weight: 700; }
.be-table-row-header .be-table-cell { background: transparent; }

.svb-table-wrap  { overflow-x: auto; margin-top: .25rem; }
.svb-table       { width: 100%; border-collapse: collapse; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.svb-table th    { border: 1px solid var(--border); padding: .4rem .5rem; font-size: .9rem; min-width: 92px; vertical-align: top; background: #eef5ff; font-weight: 700; text-align: left; }
.svb-table td    { border: 1px solid var(--border); padding: .4rem .5rem; font-size: .9rem; min-width: 92px; vertical-align: top; background: var(--white); }
.svb-table tr:nth-child(even) td { background: #fafcff; }

/* child indentation connector */
.note-blocks-view .vb[style*="margin-left"] {
  position: relative;
}

/* ============================================================
   QUICK REVIEW MODAL
   ============================================================ */
.review-modal {
  position: fixed; inset: 0; z-index: 1100;
  display: flex; align-items: center; justify-content: center; padding: var(--sp-2);
}
.review-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.52); backdrop-filter: blur(3px); }
.review-box {
  position: relative; z-index: 1;
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 500px; overflow: hidden;
}
.review-hdr {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .6rem var(--sp-2); background: var(--bg); border-bottom: 1px solid var(--border);
  font-size: .82rem; font-weight: 600; color: var(--text-muted);
}
.review-card {
  min-height: 160px; padding: var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.rv-body       { font-size: 1.05rem; font-weight: 600; color: var(--dark); line-height: 1.5; }
.rv-secondary  { font-size: .97rem; color: #155724; background: #d4edda;
                  padding: .6rem .8rem; border-radius: var(--radius-sm); line-height: 1.5; }
.rv-definition .rv-body { color: #B7510C; }
.rv-pair       .rv-body { color: #0E7668; }
.rv-mnemonic   .rv-body { color: #922B21; }
.review-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: .65rem var(--sp-2); border-top: 1px solid var(--border); background: var(--bg);
  gap: .5rem;
}

/* ============================================================
   SUBJECTS — chapter row with Study button
   ============================================================ */
.subject-chapter-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.subject-chapter-row:last-child { border-bottom: none; }
.subject-chapter-row .subject-chapter-link {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .75rem;
  text-decoration: none;
  color: var(--text);
  transition: background .15s;
  border-bottom: none;       /* override old link style */
}
.subject-chapter-row .subject-chapter-link:hover { background: var(--bg); }
.btn-study-chapter {
  margin: .3rem .5rem;
  flex-shrink: 0;
  background: transparent;
  border: 1.5px solid var(--secondary);
  color: var(--secondary);
  font-size: .75rem;
  padding: .3rem .65rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-weight: 600;
  transition: all .15s;
  white-space: nowrap;
}
.btn-study-chapter:hover { background: var(--secondary); color: #fff; }

/* ============================================================
   STARRED BLOCKS PAGE
   ============================================================ */
.starred-groups { display: flex; flex-direction: column; gap: var(--sp-2); }

.starred-group {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.starred-group-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem;
  padding: .6rem var(--sp-2);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
}
.sg-dot     { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.sg-subject { font-weight: 700; color: var(--dark); }
.sg-chapter { color: var(--text-muted); }
.sg-sep     { font-size: .65rem; opacity: .35; }
.sg-note-link { color: var(--primary); text-decoration: none; font-weight: 500; }
.sg-note-link:hover { text-decoration: underline; }
.sg-count   { margin-left: auto; font-size: .72rem; background: var(--border); padding: .15rem .5rem; border-radius: 10px; color: var(--text-muted); font-weight: 600; }

.starred-blocks-list { display: flex; flex-direction: column; }
.starred-block-row {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .65rem var(--sp-2);
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.starred-block-row:last-child { border-bottom: none; }
.starred-block-row:hover { background: var(--bg); }

.sbr-type {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: .78rem; margin-top: .05rem;
}
.sbr-content {
  flex: 1; display: flex; flex-direction: column; gap: .15rem; min-width: 0;
  font-size: .92rem; line-height: 1.5;
}
.sbr-term    { font-weight: 700; color: #B7510C; }
.sbr-sep     { color: var(--text-muted); }
.sbr-def     { color: var(--text); }
.sbr-q       { display: flex; align-items: flex-start; gap: .4rem; font-weight: 600; color: var(--dark); }
.sbr-q i     { color: #2980B9; flex-shrink: 0; margin-top: .18rem; }
.sbr-a       { display: flex; align-items: flex-start; gap: .4rem; color: #155724;
               background: #d4edda; padding: .35rem .6rem; border-radius: var(--radius-sm); }
.sbr-a i     { color: var(--secondary); flex-shrink: 0; margin-top: .18rem; }
.sbr-formula { font-family: 'Fira Code','Courier New',monospace; font-size: .9rem; font-weight: 600; color: #6c3483; }
.sbr-formula-note { font-size: .82rem; color: var(--text-muted); }
.sbr-mnemonic-title { font-weight: 700; color: #922B21; display: flex; align-items: center; gap: .4rem; }
.sbr-mnemonic-title i { color: #E74C3C; }
.sbr-mnemonic-body { font-size: .88rem; color: var(--text); }
.sbr-body    { color: var(--text); }
.sbr-goto {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); text-decoration: none; flex-shrink: 0;
  transition: all .15s; font-size: .78rem;
}
.sbr-goto:hover { background: var(--primary); color: #fff; }

/* ============================================================
   STUDY MODE  (notes/study/ID)
   ============================================================ */
.study-mode { padding-top: 0; }
.study-topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .6rem;
  padding: .6rem var(--sp-2);
  background: var(--white);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: var(--nav-height);
  z-index: 90;
  box-shadow: var(--shadow-sm);
}
.study-breadcrumb {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .9rem;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.study-subject-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.study-sep { font-size: .65rem; opacity: .35; }
.study-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.study-chapter-desc {
  margin: var(--sp-2) 0 0;
  padding: .65rem var(--sp-2);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  color: var(--text-muted);
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}

/* TOC */
.study-toc {
  margin: var(--sp-2) 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.study-toc-label {
  padding: .5rem var(--sp-2);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.study-toc-list { display: flex; flex-wrap: wrap; gap: .1rem; padding: .4rem; }
.study-toc-item {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .65rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  font-size: .85rem;
  transition: background .15s;
  font-weight: 500;
}
.study-toc-item:hover { background: var(--bg); color: var(--primary); }
.study-toc-num {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--border); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; flex-shrink: 0;
}
.study-toc-badge {
  font-size: .65rem;
  background: var(--primary);
  color: #fff;
  padding: .1rem .35rem;
  border-radius: 8px;
  font-weight: 700;
}

/* Note sections */
.study-scroll { display: flex; flex-direction: column; gap: var(--sp-3); padding-bottom: var(--sp-5); }
.study-note-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.study-note-header {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .65rem var(--sp-2);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.study-note-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; flex-shrink: 0;
}
.study-note-title {
  flex: 1; font-size: 1.05rem; font-weight: 700; margin: 0; color: var(--dark);
}
.study-note-actions { display: flex; gap: .3rem; }
.study-note-empty {
  padding: var(--sp-2) var(--sp-2);
  font-size: .9rem;
  color: var(--text-muted);
}

/* Block renderer inside study (svb = study view block) */
.study-blocks {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  padding: var(--sp-2);
}
.svb {
  border-radius: var(--radius-sm);
  padding: .55rem .75rem;
  border-left: 3px solid var(--border);
  position: relative;
  font-size: .93rem;
  line-height: 1.65;
}
.svb-star { position: absolute; top: .4rem; right: .5rem; font-size: .72rem; color: #d4ac0d; }

.svb-text       { border-color: #bdc3c7; }
.svb-definition { border-color: #E67E22; background: #fffcf5; }
.svb-pair       { border-color: #16A085; background: #f2fbf8; }
.svb-qa         { border-color: #2980B9; background: #f5f9ff; }
.svb-highlight  { border-color: currentColor; background: #f0fbf6; font-weight: 500; }
.svb-formula    { border-color: #8E44AD; background: #fdf8ff; }
.svb-mnemonic   { border-color: #C0392B; background: #fff8f8; }
.svb-tree_node  { border-color: #16A085; background: #f0fbf9; }
.svb-table      { border-color: #2C7BE5; background: #f7fbff; }

.svb-text     { white-space: normal; }
.svb-def-row  { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .65rem; }
.svb-term     { font-weight: 700; color: #B7510C; }
.svb-sep      { color: var(--text-muted); }
.svb-meaning  { color: var(--text); }

.svb-pair-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .65rem; }
.svb-pair-key { font-weight: 700; color: #0E7668; }
.svb-pair-arrow { color: var(--text-muted); }
.svb-pair-value { color: var(--text); }

.svb-qa-q     { display: flex; align-items: flex-start; gap: .45rem; font-weight: 600; color: var(--dark); }
.svb-qa-q i   { color: #2980B9; flex-shrink: 0; margin-top: .15rem; }
.svb-qa-a     { display: flex; align-items: flex-start; gap: .45rem; color: #155724;
                background: #d4edda; padding: .35rem .6rem; border-radius: var(--radius-sm); margin-top: .3rem; }
.svb-qa-a i   { color: var(--secondary); flex-shrink: 0; margin-top: .15rem; }

.svb-highlight { white-space: normal; }

.svb-formula        { display: flex; flex-direction: column; gap: .25rem; }
.svb-formula-eq     { font-family: 'Fira Code','Courier New',monospace; font-size: 1rem; font-weight: 700; color: #6c3483;
                       background: #f3e5f5; padding: .25rem .6rem; border-radius: var(--radius-sm); display: inline-block; }
.svb-formula-note   { font-size: .82rem; color: var(--text-muted); }

.svb-mnemonic       { display: flex; align-items: flex-start; gap: .55rem; }
.svb-mnemonic i     { color: #E74C3C; font-size: 1rem; margin-top: .15rem; flex-shrink: 0; }
.svb-mnemonic-title { font-weight: 700; color: #922B21; font-size: .95rem; }
.svb-mnemonic-body  { font-size: .88rem; color: var(--text); margin-top: .2rem; white-space: pre-wrap; }

.svb-node           { display: flex; align-items: flex-start; gap: .55rem; }
.svb-node-dot       { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; margin-top: .38rem; }
.svb-node-label     { font-weight: 600; color: var(--dark); }
.svb-node-note      { font-size: .84rem; color: var(--text-muted); margin-top: .15rem; }

/* ── Responsive tweaks ── */
@media (max-width: 600px) {
  .bsr-item { grid-template-columns: auto 1fr; }
  .bsr-note-info { grid-column: 1 / -1; }
  .study-topbar { gap: .4rem; }
  .study-breadcrumb { font-size: .8rem; }
  .btn-study-chapter span { display: none; }
}

/* ============================================================
   DASHBOARD — block breakdown bar
   ============================================================ */
.dash-blocks-breakdown {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.dbb-label {
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .65rem;
}
.dbb-bar-wrap {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: .6rem;
  background: var(--bg);
}
.dbb-seg { transition: width .4s ease; cursor: default; }
.dbb-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem .75rem;
}
.dbb-leg-item {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
  color: var(--text-muted);
}
.dbb-leg-item i   { font-size: .75rem; }
.dbb-leg-item strong { color: var(--dark); font-weight: 700; }

/* ============================================================
   MCQ — subject picker
   ============================================================ */
.mcq-subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.mcq-subject-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow .15s, border-color .15s;
}
.mcq-subject-card:hover { box-shadow: var(--shadow); border-color: #b8cce0; }
.mcq-card-empty { opacity: .65; }
.mcq-card-accent { height: 4px; }
.mcq-card-body   { padding: var(--sp-2); }
.mcq-card-top    { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.mcq-subject-name { font-weight: 700; font-size: 1rem; color: var(--dark); }
.mcq-count-badge {
  padding: .2rem .6rem; border-radius: 12px;
  font-size: .72rem; font-weight: 700;
}
.mcq-card-controls { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; }
.mcq-card-none { font-size: .85rem; color: var(--text-muted); }
.mcq-admin-hint {
  margin-top: var(--sp-2);
  padding: .75rem var(--sp-2);
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: var(--radius);
  font-size: .88rem;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}
.mcq-admin-hint i { color: #F39C12; flex-shrink: 0; margin-top: .1rem; }

/* ============================================================
   MCQ — practice quiz
   ============================================================ */
.mcq-practice-wrap { max-width: 680px; margin: 0 auto; }
.mcq-quiz-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .65rem;
  padding: .6rem 0 var(--sp-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-2);
}
.mcq-quiz-title {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex: 1;
  font-size: .95rem;
}
.mcq-subject-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.mcq-quiz-total  { font-size: .78rem; color: var(--text-muted); }
.mcq-exam-timer {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .85rem;
  font-weight: 700;
  color: #1f2937;
  background: #e9f2ff;
  border: 1px solid #c7dcfb;
  border-radius: 999px;
  padding: .35rem .65rem;
}
.mcq-exam-timer.is-warning { background: #fff7e8; border-color: #f7d08a; color: #92400e; }
.mcq-exam-timer.is-danger  { background: #fde8e8; border-color: #f3b5b5; color: #991b1b; }
.mcq-progress-wrap {
  display: flex; align-items: center; gap: .5rem;
  min-width: 160px;
}
.mcq-progress-bar  { flex: 1; height: 7px; background: var(--bg); border-radius: 4px; overflow: hidden; border: 1px solid var(--border); }
.mcq-progress-fill { height: 100%; border-radius: 4px; transition: width .3s ease; }
.mcq-progress-label { font-size: .75rem; color: var(--text-muted); white-space: nowrap; }

.mcq-score-strip {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  padding: .5rem var(--sp-2);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: var(--sp-2);
  font-size: .88rem; font-weight: 600;
}
.mcq-score-correct { color: var(--secondary); display: flex; align-items: center; gap: .3rem; }
.mcq-score-wrong   { color: var(--danger);    display: flex; align-items: center; gap: .3rem; }
.mcq-score-pct     { margin-left: auto; font-size: 1rem; font-weight: 800; color: var(--dark); }

.mcq-question-area { display: flex; flex-direction: column; gap: var(--sp-2); }
.mcq-q-num   { font-size: .78rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.mcq-q-text  { font-size: 1.1rem; font-weight: 600; line-height: 1.55; color: var(--dark); }

.mcq-options { display: flex; flex-direction: column; gap: .4rem; }
.mcq-option {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem .9rem;
  background: var(--white); border: 2px solid var(--border);
  border-radius: var(--radius); cursor: pointer; text-align: left;
  font-size: .95rem; font-family: inherit; color: var(--text);
  transition: all .15s;
}
.mcq-option:hover:not(:disabled) { border-color: var(--primary); background: #f0f6ff; }
.mcq-option:disabled { cursor: default; }
.mcq-option.mcq-opt-correct { border-color: var(--secondary); background: #d4edda; color: #155724; }
.mcq-option.mcq-opt-wrong   { border-color: var(--danger);    background: #fde8e8; color: #721c24; }
.mcq-opt-letter {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 800; flex-shrink: 0;
  text-transform: uppercase;
  transition: all .15s;
}
.mcq-opt-text { flex: 1; line-height: 1.4; }

.mcq-feedback {
  display: flex; align-items: flex-start; gap: .5rem;
  padding: .65rem .9rem; border-radius: var(--radius);
  font-size: .92rem; font-weight: 500; line-height: 1.45;
}
.mcq-fb-correct { background: #d4edda; color: #155724; }
.mcq-fb-correct i { color: var(--secondary); flex-shrink: 0; margin-top: .1rem; }
.mcq-fb-wrong   { background: #fde8e8; color: #721c24; }
.mcq-fb-wrong i { color: var(--danger); flex-shrink: 0; margin-top: .1rem; }
.mcq-next-btn   { align-self: flex-end; }

/* results */
.mcq-results {
  flex-direction: column; align-items: center;
  gap: var(--sp-2); text-align: center; padding: var(--sp-3) 0;
}
.mcq-results-icon { font-size: 3.5rem; line-height: 1; }
.mcq-results h2   { font-size: 1.5rem; font-weight: 800; }
.mcq-results-score { font-size: 1.1rem; color: var(--dark); font-weight: 600; }
.mcq-results-bar-wrap { width: 100%; max-width: 340px; }
.mcq-results-bar {
  height: 12px; background: var(--bg); border-radius: 6px; overflow: hidden;
  border: 1px solid var(--border);
}
.mcq-results-fill { height: 100%; border-radius: 6px; transition: width .6s ease; }
.mcq-results-breakdown {
  width: 100%; text-align: left;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden;
}
.mcq-bd-title  { padding: .5rem var(--sp-2); background: var(--bg); border-bottom: 1px solid var(--border); font-size: .8rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.mcq-bd-perfect { padding: var(--sp-2); color: var(--secondary); font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.mcq-bd-item   { padding: .65rem var(--sp-2); border-bottom: 1px solid var(--border); }
.mcq-bd-item:last-child { border-bottom: none; }
.mcq-bd-q      { font-size: .9rem; font-weight: 600; color: var(--dark); margin-bottom: .35rem; }
.mcq-bd-ans    { display: flex; flex-wrap: wrap; gap: .4rem; font-size: .85rem; }
.mcq-bd-wrong  { display: inline-flex; align-items: center; gap: .25rem; background: #fde8e8; color: #721c24; padding: .2rem .55rem; border-radius: 10px; }
.mcq-bd-correct{ display: inline-flex; align-items: center; gap: .25rem; background: #d4edda; color: #155724; padding: .2rem .55rem; border-radius: 10px; }
.mcq-timeout-note { font-size: .9rem; color: var(--text-muted); }
.mcq-results-actions { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: center; }

@media (max-width: 500px) {
  .mcq-practice-wrap { max-width: 100%; }
  .mcq-q-text { font-size: 1rem; }
  .mcq-progress-wrap { min-width: 120px; }
}

/* ============================================================
   ACCESSIBILITY — reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   PRINT — general improvements
   ============================================================ */
@media print {
  .navbar, .hamburger, .nav-overlay, .landing-footer,
  .btn, .form-actions, .quick-actions, .filters-section,
  .editor-topbar, .block-toolbar, .study-topbar,
  .timer-controls, .timer-mode-selector,
  .mobile-bottom-nav, .dark-toggle { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .main-content { padding-top: 0; padding-bottom: 0 !important; }
  .page-container, .dashboard-container, .note-view-container { max-width: 100%; padding: 0; }
  .note-rendered pre, .note-rendered code { white-space: pre-wrap; }
  a[href]::after { content: " (" attr(href) ")"; font-size: .8em; }
}

/* ============================================================
   DARK MODE TOGGLE BUTTON
   ============================================================ */
.dark-toggle {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .92rem;
  transition: all .2s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.dark-toggle:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* Smooth transition when theme changes */
.theme-transitioning,
.theme-transitioning *,
.theme-transitioning *::before,
.theme-transitioning *::after {
  transition:
    background-color .25s ease,
    border-color .25s ease,
    color .2s ease,
    box-shadow .25s ease !important;
}

/* ============================================================
   TOOLTIP SYSTEM  (JS-positioned floating tooltip)
   – The #sh-tip div is injected by script.js
   – Use data-tooltip="…" on any element
   ============================================================ */
#sh-tip {
  position: fixed;
  z-index: 99999;
  background: rgba(15, 20, 32, .93);
  color: #fff;
  font-size: .72rem;
  font-weight: 500;
  line-height: 1.4;
  padding: .3rem .65rem;
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
  max-width: 220px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.3);
  transition: opacity .15s ease;
  opacity: 0;
}
#sh-tip.sh-tip-visible { opacity: 1; }

/* ============================================================
   MOBILE BOTTOM NAVIGATION
   ============================================================ */
.mobile-bottom-nav { display: none; }

@media (max-width: 767px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 996;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -2px 16px rgba(0,0,0,.09);
  }
  /* Offset main content so bottom-nav doesn't cover it */
  .main-content  { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
}

.mbn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: .5rem .25rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: .59rem;
  font-weight: 600;
  letter-spacing: .01em;
  transition: color .15s;
  min-width: 44px;
  min-height: 56px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.mbn-item i { font-size: 1.15rem; display: block; transition: transform .2s; }
.mbn-item.active       { color: var(--primary); }
.mbn-item.active i     { transform: scale(1.1); }
.mbn-item:active i     { transform: scale(.88); }
/* Active top-bar indicator */
.mbn-item.active::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 28px; height: 3px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
}
/* FAB (floating action button) — new-note */
.mbn-fab {
  flex: 0 0 auto;
  width: 50px; height: 50px;
  background: var(--primary);
  color: #fff !important;
  border-radius: 50%;
  margin: auto .35rem;
  box-shadow: 0 4px 14px rgba(74,144,226,.45);
  font-size: 1.2rem !important;
  gap: 0;
  align-self: center;
  transition: transform .2s, box-shadow .2s, background .2s;
  min-height: unset;
  padding: 0;
}
.mbn-fab:hover        { background: var(--primary-dark); box-shadow: 0 6px 18px rgba(74,144,226,.55); }
.mbn-fab:active       { transform: scale(.9); box-shadow: none; }
.mbn-fab.active::before { display: none; }

/* ============================================================
   DARK MODE — CSS variable overrides
   ============================================================ */
[data-theme="dark"] {
  --primary:        #60A5FA;
  --primary-dark:   #3B82F6;
  --primary-light:  rgba(96,165,250,.1);
  --secondary:      #34D399;
  --danger:         #F87171;
  --warning:        #FBBF24;
  --info:           #60A5FA;
  --dark:           #E2E8F0;
  --gray:           #8B9AB5;
  --light:          #252D40;
  --white:          #1A1F2E;
  --bg:             #0F1117;
  --card:           #1A1F2E;
  --text:           #E2E8F0;
  --text-muted:     #8B9AB5;
  --border:         #2A3347;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.4);
  --shadow-md:      0 4px 12px rgba(0,0,0,.5);
  --shadow-lg:      0 10px 24px rgba(0,0,0,.6);
  --focus-ring:     0 0 0 3px rgba(96,165,250,.25);
  color-scheme:     dark;
}

/* ── Dark mode: hardcoded light colours that need overrides ── */

/* Auth / landing */
[data-theme="dark"] .auth-box    { background: var(--card); }
[data-theme="dark"] .auth-form   { background: var(--card); }
[data-theme="dark"] .features    { background: var(--bg); }
[data-theme="dark"] .feature-card { background: var(--card); border-color: var(--border); }
[data-theme="dark"] .landing-footer { background: var(--card); }

/* Rich text editor */
[data-theme="dark"] .quill-wrap            { background: var(--card); }
[data-theme="dark"] .ql-toolbar.ql-snow    { background: var(--bg); border-bottom-color: var(--border); }
[data-theme="dark"] .ql-editor             { color: var(--text); }

/* Alerts */
[data-theme="dark"] .alert-success { background: rgba(52,211,153,.1);   color: #34D399; }
[data-theme="dark"] .alert-error   { background: rgba(248,113,113,.1);  color: #F87171; }
[data-theme="dark"] .alert-info    { background: rgba(96,165,250,.1);   color: #60A5FA; }

/* Note rendered content */
[data-theme="dark"] .note-rendered code               { background: rgba(255,255,255,.07); color: #F87171; }
[data-theme="dark"] .note-rendered mark               { background: rgba(255,241,118,.18); color: #FEF08A; }
[data-theme="dark"] .note-rendered td                 { border-bottom-color: var(--border); }
[data-theme="dark"] .note-rendered tr:nth-child(even) td { background: rgba(255,255,255,.03); }
[data-theme="dark"] .note-rendered blockquote { background: var(--primary-light); border-left-color: var(--primary); }

/* Block view backgrounds (vb-* classes) */
[data-theme="dark"] .vb-definition  { background: rgba(230,126, 34,.07); }
[data-theme="dark"] .vb-pair        { background: rgba( 22,160,133,.07); }
[data-theme="dark"] .vb-qa-a        { background: rgba(52,211,153,.1); color: #34D399; }
[data-theme="dark"] .vb-qa-a i      { color: var(--secondary); }
[data-theme="dark"] .vb-formula     { background: rgba(142, 68,173,.07); }
[data-theme="dark"] .vb-formula-eq  { background: rgba(142, 68,173,.18); color: #C77DFF; }
[data-theme="dark"] .vb-mnemonic    { background: rgba(192, 57, 43,.07); }
[data-theme="dark"] .vb-tree_node   { background: rgba( 22,160,133,.07); }
[data-theme="dark"] .vb.vb-rich_text { background: rgba( 36,113,163,.07); }
[data-theme="dark"] .vb.vb-list_block { background: rgba( 26, 82,118,.07); }
[data-theme="dark"] .vb.vb-diagram  { background: rgba(125, 60,152,.07); }
[data-theme="dark"] .vb.vb-table    { background: rgba( 44,123,229,.07); }
[data-theme="dark"] .vb-highlight   { background: rgba( 39,174, 96,.07); }

/* Study view block backgrounds (svb-*) */
[data-theme="dark"] .svb-definition  { background: rgba(230,126, 34,.07); }
[data-theme="dark"] .svb-pair        { background: rgba( 22,160,133,.07); }
[data-theme="dark"] .svb-qa          { background: rgba( 41,128,185,.07); }
[data-theme="dark"] .svb-qa-a        { background: rgba(52,211,153,.1); color: #34D399; }
[data-theme="dark"] .svb-qa-a i      { color: var(--secondary); }
[data-theme="dark"] .svb-formula     { background: rgba(142, 68,173,.07); }
[data-theme="dark"] .svb-formula-eq  { background: rgba(142, 68,173,.18); color: #C77DFF; }
[data-theme="dark"] .svb-mnemonic    { background: rgba(192, 57, 43,.07); }
[data-theme="dark"] .svb-tree_node   { background: rgba( 22,160,133,.07); }
[data-theme="dark"] .svb-table       { background: rgba( 44,123,229,.07); }
[data-theme="dark"] .vb-table th,
[data-theme="dark"] .svb-table th,
[data-theme="dark"] .be-table-editor th,
[data-theme="dark"] .be-table-header-row .be-table-cell { background: rgba( 44,123,229,.14); }
[data-theme="dark"] .be-table-row-header { background: rgba(34,197,94,.06); }
[data-theme="dark"] .be-table-row-header .be-table-cell { background: transparent; }
[data-theme="dark"] .be-sci-toolbar { background: rgba(255,255,255,.03); }
[data-theme="dark"] .be-sci-btn { background: rgba(255,255,255,.02); color: #cbd5e1; border-color: rgba(148,163,184,.35); }
[data-theme="dark"] .be-sci-btn:hover { background: rgba(66,133,244,.16); color: #9ec3ff; border-color: rgba(96,165,250,.65); }
[data-theme="dark"] .be-table-actions .be-btn {
  background: rgba(255,255,255,.04);
  color: var(--text);
  border-color: rgba(255,255,255,.08);
  box-shadow: none;
}
[data-theme="dark"] .be-table-actions .be-btn:hover {
  background: rgba(255,255,255,.08);
  color: var(--text);
}
[data-theme="dark"] .be-table-toggle-header {
  background: rgba(44,123,229,.14);
  color: #8AB4FF;
  border-color: rgba(44,123,229,.25);
}
[data-theme="dark"] .be-table-add-row-above,
[data-theme="dark"] .be-table-add-row-below {
  background: rgba(44,123,229,.12);
  color: #8AB4FF;
  border-color: rgba(44,123,229,.22);
}
[data-theme="dark"] .be-table-add-col-left,
[data-theme="dark"] .be-table-add-col-right {
  background: rgba(22,160,133,.12);
  color: #7CE0C8;
  border-color: rgba(22,160,133,.22);
}
[data-theme="dark"] .be-table-del-row,
[data-theme="dark"] .be-table-del-col {
  background: rgba(231,76,60,.12);
  color: #FF9B93;
  border-color: rgba(231,76,60,.22);
}

/* Starred blocks viewer */
[data-theme="dark"] .sbr-a  { background: rgba(52,211,153,.1); color: #34D399; }
[data-theme="dark"] .sbr-a i { color: var(--secondary); }

/* Quick review modal */
[data-theme="dark"] .rv-secondary { background: rgba(52,211,153,.1); color: #34D399; }

/* MCQ correct / wrong */
[data-theme="dark"] .mcq-option.mcq-opt-correct { background: rgba(52,211,153,.1);  color: #34D399; border-color: #34D399; }
[data-theme="dark"] .mcq-option.mcq-opt-wrong   { background: rgba(248,113,113,.1); color: #F87171; border-color: #F87171; }
[data-theme="dark"] .mcq-fb-correct             { background: rgba(52,211,153,.1);  color: #34D399; }
[data-theme="dark"] .mcq-fb-wrong               { background: rgba(248,113,113,.1); color: #F87171; }
[data-theme="dark"] .mcq-bd-wrong               { background: rgba(248,113,113,.12); color: #F87171; }
[data-theme="dark"] .mcq-bd-correct             { background: rgba(52,211,153,.12);  color: #34D399; }
[data-theme="dark"] .mcq-admin-hint             { background: rgba(251,191, 36,.06); border-color: rgba(251,191,36,.2); }
[data-theme="dark"] .mcq-exam-timer             { background: rgba(59,130,246,.16); border-color: rgba(59,130,246,.35); color: #bfdbfe; }
[data-theme="dark"] .mcq-exam-timer.is-warning  { background: rgba(245,158,11,.15); border-color: rgba(245,158,11,.45); color: #fcd34d; }
[data-theme="dark"] .mcq-exam-timer.is-danger   { background: rgba(239,68,68,.15); border-color: rgba(239,68,68,.45); color: #fca5a5; }

/* Chapter edit row */
[data-theme="dark"] .chrow-edit {
  background: rgba(245,231,158,.04);
  border-top-color: rgba(245,231,158,.12);
}

/* Dropdown / logout hover */
[data-theme="dark"] .logout-link:hover  { background: rgba(248,113,113,.12) !important; }
[data-theme="dark"] .be-del:hover       { background: rgba(248,113,113,.15); color: var(--danger); }
[data-theme="dark"] .be-star:hover      { background: rgba(251,191, 36,.1); }

/* Filter select chevron SVG (uses light grey arrow — change to match dark text-muted) */
[data-theme="dark"] .filter-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238B9AB5' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
}

/* Mobile bottom-nav stays readable in dark mode (already uses CSS vars — just bump shadow) */
[data-theme="dark"] .mobile-bottom-nav { box-shadow: 0 -2px 20px rgba(0,0,0,.45); }
[data-theme="dark"] .mbn-fab           { box-shadow: 0 4px 14px rgba(96,165,250,.35); }

/* ══ Chapter References ══════════════════════════════════════ */
/* ══ Reference System ══════════════════════════════════════════════ */

.chapter-references-section {
    margin: var(--sp-4) 0 var(--sp-3);
    border-top: 2px solid var(--border);
    padding-top: var(--sp-3);
}

.chapter-references-heading {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    margin-bottom: var(--sp-2);
}

.chapter-references-heading i {
    color: #2980B9;
    font-size: .9rem;
}

.chapter-references-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
}

.chapter-references-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.chapter-ref-item {
    display: flex;
    align-items: flex-start;
    gap: .85rem;
    padding: .85rem 1rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    position: relative;
    transition: border-color .15s, box-shadow .15s;
}

.chapter-ref-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.chapter-ref-icon {
    flex-shrink: 0;
    font-size: 1.05rem;
    padding-top: .15rem;
    width: 22px;
    text-align: center;
}

.chapter-ref-body {
    flex: 1;
    min-width: 0;
}

.chapter-ref-type {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    margin-bottom: .2rem;
    opacity: .85;
}

.chapter-ref-title {
    font-size: .95rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
}

.chapter-ref-link {
    color: var(--text);
    text-decoration: none;
    transition: color .12s;
}

.chapter-ref-link:hover {
    color: var(--primary);
}

.chapter-ref-ext {
    font-size: .65rem;
    margin-left: .35rem;
    opacity: .6;
    vertical-align: middle;
}

.chapter-ref-citation {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: .25rem;
    line-height: 1.4;
}

.chapter-ref-page {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: .25rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: .1rem .5rem;
}

.chapter-ref-page i {
    font-size: .65rem;
    color: var(--primary);
}

.chapter-ref-num {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
    font-size: .7rem;
    font-weight: 700;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-start;
    margin-top: .1rem;
}

/* Dark mode overrides */
[data-theme="dark"] .chapter-ref-item {
    background: var(--card);
}

[data-theme="dark"] .chapter-ref-item:hover {
    border-color: var(--primary);
}

[data-theme="dark"] .chapter-ref-link {
    color: var(--text);
}

[data-theme="dark"] .chapter-ref-link:hover {
    color: var(--primary);
}

/* Dropdown logout button — matches .logout-link anchor style but as <button> */
.dropdown-logout-btn {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .65rem 1rem;
    font-size: .9rem;
    font-family: inherit;
    color: var(--danger);
    transition: background .15s;
}
.dropdown-logout-btn:hover { background: #fff5f5; }
[data-theme="dark"] .dropdown-logout-btn:hover { background: rgba(248,113,113,.12); }
