/* v8 cache buster */
@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,500;0,600;1,400&family=DM+Sans:wght@400;500;600;700&display=swap');

/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: 'DM Sans', sans-serif; background: #FBF8F1; color: #1A1A1A; min-height: 100vh; }
a { text-decoration: none; color: inherit; }
button, input, textarea, select { font-family: inherit; }
img { max-width: 100%; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }

/* ── CSS Variables ────────────────────────────────────── */
:root {
  --navy:   #0F2D5E;
  --navy2:  #1A3F7A;
  --gold:   #C8991A;
  --cream:  #FBF8F1;
  --white:  #FFFFFF;
  --border: rgba(0,0,0,0.08);
  --text-primary:   #1A1A1A;
  --text-secondary: #5A5A5A;
  --text-muted:     #909090;
  --success: #1D9E75;
  --danger:  #D85A30;
  --info:    #185FA5;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.07);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.14);
  --radius:    10px;
  --radius-sm: 6px;
  --sidebar-w: 220px;
  --topnav-h:  56px;
}

/* ── Layout Shell ─────────────────────────────────────── */
.app-shell { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.app-body  { display: flex; flex: 1; overflow: hidden; }
.app-main  { flex: 1; overflow-y: auto; padding: 1.5rem; min-width: 0; }
.app-main.no-pad { padding: 0; overflow: hidden; }

/* ── Top Nav ──────────────────────────────────────────── */
.topnav {
  height: var(--topnav-h);
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.topnav-brand { display: flex; align-items: center; gap: 10px; }
.topnav-brand-icon { font-size: 22px; color: var(--gold); }
.topnav-brand-text { font-family: 'Lora', serif; font-size: 18px; font-weight: 600; }
.topnav-right { display: flex; align-items: center; gap: 8px; }
.topnav-meet {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 13px;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}
.topnav-meet:hover { background: rgba(255,255,255,0.2); }
.topnav-user {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  cursor: pointer;
  font-size: 13px;
  color: #fff;
}
.topnav-user:hover { background: rgba(255,255,255,0.14); }
.topnav-dropdown {
  position: absolute;
  right: 0; top: calc(100% + 8px);
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  z-index: 200;
  overflow: hidden;
  display: none;
}
.topnav-dropdown.open { display: block; }
.topnav-dropdown-header { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.topnav-dropdown-header .name { font-size: 13px; font-weight: 600; }
.topnav-dropdown-header .email { font-size: 12px; color: var(--text-muted); }
.topnav-dropdown a, .topnav-dropdown button {
  display: block; width: 100%; text-align: left;
  padding: 10px 14px; font-size: 13px; border: none;
  background: none; cursor: pointer;
}
.topnav-dropdown a:hover, .topnav-dropdown button:hover { background: var(--cream); }
.topnav-dropdown .logout { color: var(--danger); }
.hamburger { display: none; background: rgba(255,255,255,0.1); border: none; color: #fff; font-size: 20px; width: 36px; height: 36px; border-radius: var(--radius-sm); cursor: pointer; align-items: center; justify-content: center; }

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform 0.25s ease;
}
.sidebar-nav { flex: 1; padding-top: 0.5rem; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 1.25rem;
  font-size: 14px; font-weight: 400;
  color: var(--text-secondary);
  border-left: 3px solid transparent;
  transition: all 0.15s;
  cursor: pointer;
  text-decoration: none;
  width: 100%;
  background: none;
  border-top: none; border-right: none; border-bottom: none;
}
.sidebar-link:hover { background: #F5F7FD; color: var(--navy); }
.sidebar-link.active { font-weight: 600; color: var(--navy); background: #EEF2FA; border-left-color: var(--navy); }
.sidebar-link svg { width: 17px; height: 17px; flex-shrink: 0; }
.sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); }
.sidebar-user { display: flex; align-items: center; gap: 8px; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 150; }

/* ── Avatar ───────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; flex-shrink: 0; font-size: 13px;
  background: #E6F1FB; color: #0C447C;
}
.avatar-sm  { width: 28px; height: 28px; font-size: 11px; }
.avatar-md  { width: 36px; height: 36px; font-size: 13px; }
.avatar-lg  { width: 48px; height: 48px; font-size: 16px; }
.avatar-xl  { width: 64px; height: 64px; font-size: 20px; }

/* ── Badge ────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-blue   { background: #E6F1FB; color: #185FA5; }
.badge-green  { background: #EAF3DE; color: #3B6D11; }
.badge-amber  { background: #FAEEDA; color: #854F0B; }
.badge-navy   { background: #E6EBF5; color: #0F2D5E; }
.badge-gold   { background: #FEF9E7; color: #9A7200; }
.badge-purple { background: #EEEDFE; color: #3C3489; }
.badge-teal   { background: #E1F5EE; color: #085041; }
.badge-red    { background: #FCEBEB; color: #A32D2D; }

/* ── Card ─────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.card-navy { background: linear-gradient(135deg, var(--navy) 0%, var(--navy2) 100%); border: none; }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; border: none; cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover:not(:disabled) { opacity: 0.88; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary   { background: var(--navy);    color: #fff; }
.btn-secondary { background: transparent;    color: var(--navy);    border: 1px solid var(--navy); }
.btn-gold      { background: var(--gold);    color: #fff; }
.btn-danger    { background: var(--danger);  color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-ghost     { background: transparent;    color: var(--text-secondary); border: 1px solid var(--border); }
.btn-info      { background: #E6F1FB;        color: var(--info); border: 1px solid var(--info); }
.btn-sm  { padding: 5px 12px; font-size: 12px; }
.btn-lg  { padding: 11px 24px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px; width: 32px; height: 32px; }

/* ── Forms ────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 5px; }
.form-label.gold { color: var(--gold); font-weight: 600; }
.form-control {
  width: 100%; padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 14px; background: var(--cream);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(15,45,94,0.1); }
.form-control.gold-border { border-color: var(--gold); border-width: 1.5px; }
textarea.form-control { resize: vertical; }
select.form-control { cursor: pointer; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.invalid-feedback { color: var(--danger); font-size: 12px; margin-top: 4px; display: block; }

/* ── Alert ────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 1rem; }
.alert-success { background: #EAF3DE; color: #3B6D11; border: 1px solid #B8D89A; }
.alert-danger  { background: #FCEBEB; color: #A32D2D; border: 1px solid #F7C1C1; }
.alert-info    { background: #E6F1FB; color: #185FA5; border: 1px solid #B3D0F5; }
.alert-warning { background: #FEF3DC; color: #854F0B; border: 1px solid #F5D9A0; }

/* ── Progress Bar ─────────────────────────────────────── */
.progress { height: 6px; background: #EEE; border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; transition: width 0.4s ease; background: var(--navy); }
.progress-lg { height: 10px; }

/* ── Category Color Bands ─────────────────────────────── */
.cat-0 { --cat-bg:#E6F1FB; --cat-border:#185FA5; --cat-text:#0C447C; --cat-badge:#185FA5; }
.cat-1 { --cat-bg:#E1F5EE; --cat-border:#1D9E75; --cat-text:#085041; --cat-badge:#1D9E75; }
.cat-2 { --cat-bg:#FAEEDA; --cat-border:#C8991A; --cat-text:#633806; --cat-badge:#C8991A; }
.cat-3 { --cat-bg:#EEEDFE; --cat-border:#534AB7; --cat-text:#3C3489; --cat-badge:#534AB7; }
.cat-4 { --cat-bg:#FAECE7; --cat-border:#D85A30; --cat-text:#712B13; --cat-badge:#D85A30; }
.cat-5 { --cat-bg:#EAF3DE; --cat-border:#3B6D11; --cat-text:#27500A; --cat-badge:#3B6D11; }
.cat-band { background: var(--cat-bg); border-left: 4px solid var(--cat-badge); border-radius: var(--radius); padding: 1rem 1.25rem; }
.cat-band-text { color: var(--cat-text); }

/* ── Table ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { border-bottom: 1px solid var(--border); }
th { padding: 8px 12px; text-align: left; font-weight: 600; color: var(--text-secondary); font-size: 12px; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFAFA; }

/* ── Modal ────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 300;
  align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white); border-radius: var(--radius);
  width: 100%; max-width: 580px; max-height: 92vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity:0; transform:scale(0.95) translateY(-10px); } to { opacity:1; transform:scale(1) translateY(0); } }
.modal-lg { max-width: 720px; }
.modal-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close { font-size: 22px; color: var(--text-muted); background: none; border: none; cursor: pointer; line-height: 1; }
.modal-body { padding: 1.25rem; overflow-y: auto; }
.modal-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0; }

/* ── Tabs ─────────────────────────────────────────────── */
.tab-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 1.25rem; }
.tab-btn {
  padding: 7px 16px; border-radius: 20px;
  font-size: 13px; font-weight: 400;
  background: var(--white); color: var(--text-secondary);
  border: 1.5px solid var(--border);
  cursor: pointer; transition: all 0.15s;
}
.tab-btn.active { font-weight: 600; color: #fff; }
.tab-btn:hover:not(.active) { border-color: var(--navy); color: var(--navy); }

/* ── Rich Text Editor Toolbar ─────────────────────────── */
.rte-wrap { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.rte-toolbar { display: flex; gap: 4px; padding: 6px 8px; background: #F8F8F8; border-bottom: 1px solid var(--border); flex-wrap: wrap; align-items: center; }
.rte-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 28px; border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.12); background: #fff; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  transition: background 0.1s;
}
.rte-btn:hover { background: #f0f0f0; }
.rte-btn.img-btn { width: auto; padding: 0 8px; gap: 4px; font-size: 11px; color: var(--info); border-color: var(--info); }
.rte-divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
#rte-content {
  min-height: 200px; padding: 10px 12px;
  font-size: 14px; line-height: 1.7; outline: none; background: var(--cream);
}
#rte-content:empty:before { content: attr(data-placeholder); color: #aaa; pointer-events: none; }

/* ── Lesson Content Rendering ─────────────────────────── */
.lesson-body { font-size: 15px; line-height: 1.8; color: var(--text-secondary); }
.lesson-body b, .lesson-body strong { font-weight: 700; }
.lesson-body i, .lesson-body em { font-style: italic; }
.lesson-body u { text-decoration: underline; }
.lesson-body img { max-width: 100%; border-radius: 8px; margin: 8px 0; }
.lesson-body ul { padding-left: 1.5rem; margin: 0.5rem 0; }
.lesson-body ol { padding-left: 1.5rem; margin: 0.5rem 0; }
.lesson-body li { margin-bottom: 4px; }

/* ── Highlighting ─────────────────────────────────────── */
.hl-yellow { background: #FFF176; border-bottom: 2px solid #F9A825; border-radius: 2px; padding: 0 1px; cursor: pointer; }
.hl-green  { background: #C8E6C9; border-bottom: 2px solid #388E3C; border-radius: 2px; padding: 0 1px; cursor: pointer; }
.hl-pink   { background: #F8BBD0; border-bottom: 2px solid #C2185B; border-radius: 2px; padding: 0 1px; cursor: pointer; }
.hl-blue   { background: #BBDEFB; border-bottom: 2px solid #1976D2; border-radius: 2px; padding: 0 1px; cursor: pointer; }
.hl-yellow:hover, .hl-green:hover, .hl-pink:hover, .hl-blue:hover { opacity: 0.75; }
.hl-toolbar {
  position: fixed; z-index: 500;
  background: #1A1A1A; color: #fff;
  border-radius: 8px; padding: 6px 10px;
  display: flex; align-items: center; gap: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  animation: popIn 0.12s ease;
}
@keyframes popIn { from { opacity:0; transform:scale(0.9) translateY(4px); } to { opacity:1; transform:scale(1) translateY(0); } }
.hl-swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; transition: transform 0.1s; flex-shrink: 0; }
.hl-swatch:hover, .hl-swatch.sel { transform: scale(1.2); border-color: #fff; }
.hl-do-btn { background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3); border-radius: 4px; padding: 3px 9px; color: #fff; font-size: 12px; font-weight: 600; cursor: pointer; }
.hl-divider { width: 1px; height: 16px; background: rgba(255,255,255,0.2); }
.note-popup {
  position: fixed; z-index: 501;
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
  box-shadow: var(--shadow-lg); width: 260px;
  animation: popIn 0.12s ease;
}
.note-color-bar { height: 4px; margin: -12px -12px 10px; border-radius: 8px 8px 0 0; }

/* ── Stat Card ────────────────────────────────────────── */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 12px; margin-bottom: 1.5rem; }
.stat-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow-sm); }
.stat-val { font-size: 24px; font-weight: 700; margin-top: 8px; }
.stat-lbl { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ── Chat ─────────────────────────────────────────────── */
.chat-layout { display: flex; height: 100%; overflow: hidden; }
.chat-sidebar { width: 200px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--white); overflow-y: auto; }
.chat-sidebar-section { padding: 10px 14px 4px; font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.chat-channel {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; font-size: 13px; cursor: pointer;
  transition: background 0.12s; border: none; background: none; width: 100%; text-align: left;
  text-decoration: none; color: var(--text-secondary);
}
.chat-channel:hover { background: #F5F7FD; }
.chat-channel.active { background: #EEF2FA; color: var(--navy); font-weight: 600; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.chat-header { padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--white); font-size: 14px; font-weight: 600; flex-shrink: 0; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-empty { text-align: center; color: var(--text-muted); font-size: 14px; margin-top: 40px; }
.chat-msg { display: flex; gap: 10px; }
.chat-msg.me { flex-direction: row-reverse; }
.chat-bubble-wrap { max-width: 70%; display: flex; flex-direction: column; }
.chat-msg.me .chat-bubble-wrap { align-items: flex-end; }
.chat-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 3px; display: flex; gap: 8px; }
.chat-meta .sender { font-weight: 600; color: var(--text-secondary); }
.chat-bubble { padding: 8px 12px; border-radius: 12px; font-size: 14px; line-height: 1.5; word-break: break-word; background: var(--cream); color: var(--text-primary); }
.chat-msg.me .chat-bubble { background: var(--navy); color: #fff; }
.chat-input-bar { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--white); display: flex; gap: 8px; flex-shrink: 0; }
.chat-input { flex: 1; padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: 14px; outline: none; background: var(--cream); min-width: 0; }
.chat-input:focus { border-color: var(--navy); }

/* ── Login Page ───────────────────────────────────────── */
.login-bg {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, #1E4A8C 60%, #2A5FA0 100%);
  padding: 1rem;
}
.login-card { background: var(--white); border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo-icon { width: 72px; height: 72px; border-radius: 50%; background: rgba(255,255,255,0.12); border: 2px solid rgba(255,255,255,0.3); display: flex; align-items: center; justify-content: center; margin: 0 auto 1rem; font-size: 36px; }
.login-logo h1 { font-family: 'Lora', serif; color: #fff; font-size: 28px; font-weight: 600; }
.login-logo p { color: rgba(255,255,255,0.6); font-size: 14px; margin-top: 4px; }

/* ── Section headings ─────────────────────────────────── */
.page-title { font-family: 'Lora', serif; font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.page-subtitle { color: var(--text-secondary); font-size: 14px; margin-bottom: 1.5rem; }
h2.section-title { font-family: 'Lora', serif; font-size: 18px; font-weight: 600; margin-bottom: 1rem; }
h3.sub-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; color: var(--text-secondary); }

/* ── Lesson card ──────────────────────────────────────── */
.lesson-card { cursor: pointer; transition: box-shadow 0.15s, transform 0.1s; }
.lesson-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.lesson-num { width: 40px; height: 40px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex-shrink: 0; }

/* ── Reorder arrows ───────────────────────────────────── */
.reorder-btns { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; padding-top: 4px; }
.reorder-btn { width: 28px; height: 28px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--white); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 14px; transition: background 0.1s; }
.reorder-btn:hover:not(:disabled) { background: var(--cream); }
.reorder-btn:disabled { opacity: 0.25; cursor: not-allowed; }

/* ── Banner callout ───────────────────────────────────── */
.callout { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; display: flex; align-items: flex-start; gap: 8px; }
.callout-amber { background: #FEF3DC; border: 1px solid #F5D9A0; color: #7B5800; }
.callout-blue  { background: #E6F1FB; border: 1px solid #B3D0F5; color: #185FA5; }
.callout-green { background: #EAF3DE; border: 1px solid #B8D89A; color: #3B6D11; }

/* ── Spinner ──────────────────────────────────────────── */
.spinner { display: inline-block; width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--navy); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Floating highlight tip ───────────────────────────── */
.hl-tip { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: #FFF9E6; border: 1px solid #F9A825; border-radius: var(--radius-sm); font-size: 12px; color: #7B5800; margin-bottom: 12px; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { position: fixed; top: var(--topnav-h); left: 0; bottom: 0; z-index: 160; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .hamburger { display: flex; }
  .hide-mobile { display: none !important; }
  .chat-sidebar { width: 56px; }
  .chat-channel span { display: none; }
  .app-main { padding: 1rem; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 769px) {
  .hamburger { display: none !important; }
}

/* ── PWA Install Banner ───────────────────────────────── */
.install-banner { display: none; position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 20px; border-radius: 30px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-md); z-index: 400; align-items: center; gap: 12px; }
.install-banner.show { display: flex; }
.install-banner button { background: var(--gold); color: #fff; border: none; border-radius: var(--radius-sm); padding: 4px 12px; font-size: 12px; font-weight: 600; cursor: pointer; }

/* ── Helpers ──────────────────────────────────────────── */
.flex { display: flex; } .flex-col { flex-direction: column; } .items-center { align-items: center; }
.justify-between { justify-content: space-between; } .gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.flex-1 { flex: 1; } .min-w-0 { min-width: 0; } .flex-wrap { flex-wrap: wrap; } .flex-shrink-0 { flex-shrink: 0; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.mr-2 { margin-right: 8px; } .text-muted { color: var(--text-muted); } .text-secondary { color: var(--text-secondary); }
.text-navy { color: var(--navy); } .text-gold { color: var(--gold); } .text-danger { color: var(--danger); } .text-success { color: var(--success); }
.text-sm { font-size: 12px; } .text-xs { font-size: 11px; } .font-bold { font-weight: 700; } .font-semibold { font-weight: 600; }
.lora { font-family: 'Lora', serif; } .text-center { text-align: center; }
.w-full { width: 100%; } .d-none { display: none; } .d-flex { display: flex; }

.btn-warning { background:#FFF8E1; color:#E65100; border:1px solid #F9A825; }
.btn-danger  { background:#FCEBEB; color:#C62828; border:1px solid #E53935; }

/* ── Mobile highlighting toolbar (fixed bottom) ──────────── */
.hl-toolbar-mobile {
  bottom: 16px !important;
  left: 50% !important;
  top: auto !important;
  transform: translateX(-50%) !important;
  position: fixed !important;
  max-width: calc(100vw - 24px);
  z-index: 9999;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  padding: 10px 14px;
}

.hl-toolbar-mobile .hl-swatch {
  width: 28px;
  height: 28px;
  margin: 0 3px;
}

.hl-toolbar-mobile .hl-do-btn {
  font-size: 14px;
  padding: 8px 14px;
}

/* ── Mobile note popup (centered modal) ─────────────────── */
.note-popup-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease-out;
}

.note-popup-modal-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  position: relative;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Top nav logo ────────────────────────────────────────── */
.topnav-brand-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  display: block;
}

/* ── Rich Text Editor toolbar ────────────────────────────── */
.rte-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px;
  background: #fafafa;
  border: 1px solid #ddd;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  align-items: center;
}

.rte-btn {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 3px;
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
  color: #333;
  min-width: 32px;
  text-align: center;
  transition: background 0.1s;
}

.rte-btn:hover {
  background: #e8f1fb;
  border-color: #0C447C;
}

.rte-btn:active {
  background: #d4e6f7;
}

.rte-sep {
  width: 1px;
  height: 22px;
  background: #ddd;
  margin: 0 4px;
}

/* ── RTE editable content area ───────────────────────────── */
.rte-content {
  min-height: 200px;
  max-height: 480px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 0 0 4px 4px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.6;
  background: #fff;
  outline: none;
}

.rte-content:focus {
  border-color: #0C447C;
  box-shadow: 0 0 0 2px rgba(12,68,124,0.12);
}

.rte-content:empty::before {
  content: attr(data-placeholder);
  color: #aaa;
  pointer-events: none;
}

.rte-content h2 { font-size: 18px; font-weight: 700; margin: 14px 0 8px 0; }
.rte-content h3 { font-size: 16px; font-weight: 700; margin: 12px 0 6px 0; }
.rte-content blockquote {
  border-left: 4px solid #F9A825;
  background: #FFF8E1;
  margin: 12px 0;
  padding: 8px 14px;
  font-style: italic;
}
.rte-content ul, .rte-content ol { margin: 8px 0 8px 24px; }
.rte-content p { margin: 6px 0; }
.rte-content a { color: #0C447C; text-decoration: underline; }
.rte-content img { max-width: 100%; height: auto; margin: 8px 0; }

/* Video embeds in lesson display */
.video-embed {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  margin: 1rem 0;
}
.video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Responsive — slimmer padding on mobile */
@media (max-width: 768px) {
  .rte-btn { padding: 6px 8px; font-size: 12px; }
  .rte-toolbar { padding: 6px; }
}

/* ── Modal sizing & internal scroll ────────────────────── */
/* Make modals never exceed viewport height; scroll inside */
.modal-overlay .modal {
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-overlay .modal-header {
  flex-shrink: 0;
}

.modal-overlay .modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-overlay .modal-footer {
  flex-shrink: 0;
  border-top: 1px solid #eee;
  padding-top: 12px;
}

/* On mobile, claim more vertical space and use full-screen-ish layout */
@media (max-width: 768px) {
  .modal-overlay .modal {
    max-height: 95vh;
    margin: 8px;
    width: calc(100vw - 16px);
  }
  .rte-content {
    max-height: 240px; /* shorter on mobile so buttons stay reachable */
  }
}

/* ── Help / User Manual content styling ─────────────────── */
.help-content {
  max-width: 820px;
  line-height: 1.6;
  font-size: 15px;
}

.help-content h1 {
  font-size: 26px;
  margin: 0 0 8px 0;
  color: #0F2D5E;
}

.help-content h2 {
  font-size: 22px;
  margin: 28px 0 12px 0;
  padding-top: 12px;
  border-top: 1px solid #eee;
  color: #0F2D5E;
}

.help-content h2:first-of-type {
  border-top: none;
  padding-top: 0;
}

.help-content h3 {
  font-size: 17px;
  margin: 20px 0 8px 0;
  color: #333;
}

.help-content p {
  margin: 8px 0 12px 0;
}

.help-content ul,
.help-content ol {
  margin: 8px 0 12px 24px;
}

.help-content li {
  margin: 4px 0;
}

.help-content code {
  background: #f5f5f5;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 13px;
  color: #c7254e;
}

.help-content blockquote {
  border-left: 4px solid #F9A825;
  background: #FFF8E1;
  margin: 12px 0;
  padding: 8px 14px;
  font-style: italic;
}

.help-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 14px;
}

.help-content th,
.help-content td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #e5e5e5;
}

.help-content th {
  background: #fafafa;
  font-weight: 600;
}

.help-content hr {
  border: none;
  border-top: 1px solid #e5e5e5;
  margin: 24px 0;
}

.help-content strong {
  color: #0F2D5E;
}

.help-content a {
  color: #0C447C;
  text-decoration: underline;
}

@media (max-width: 768px) {
  .help-content { font-size: 14px; }
  .help-content h1 { font-size: 22px; }
  .help-content h2 { font-size: 18px; }
}