/* =============================================
   MCQ TRAINER — Global Design System v2.0
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* --- Design Tokens --- */
:root {
  --bg: #f0f4f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --border: #e2e8f0;
  --border-2: #cbd5e1;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-glow: rgba(37, 99, 235, 0.25);
  --primary-rgb: 37, 99, 235;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.03);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.08), 0 10px 10px -5px rgba(0,0,0,0.02);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --input-bg: #ffffff;
  --nav-bg: #ffffff;
  --card-shadow: var(--shadow);
  /* Legacy aliases */
  --card-bg: var(--surface);
  --hover-bg: var(--surface-2);
  --table-hover: var(--surface-2);
  --explanation-bg: var(--surface-2);
  --choices-border: var(--border);
  --text-secondary: var(--text-2);
  --header-bg: var(--primary);
  --header-text: #ffffff;
}

[data-theme="dark"] {
  --bg: #0b0f1a;
  --surface: #141b2d;
  --surface-2: #1a2340;
  --text: #f1f5f9;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --border: #1e2d45;
  --border-2: #253554;
  --primary-light: #1e2d45;
  --primary-glow: rgba(96, 165, 250, 0.2);
  --primary-rgb: 96, 165, 250;
  --success-bg: #052e16;
  --success-border: #14532d;
  --danger-bg: #450a0a;
  --danger-border: #7f1d1d;
  --warning-bg: #451a03;
  --warning-border: #78350f;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 4px 6px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
  --shadow-md: 0 10px 15px rgba(0,0,0,0.4), 0 4px 6px rgba(0,0,0,0.3);
  --shadow-lg: 0 20px 25px rgba(0,0,0,0.5), 0 10px 10px rgba(0,0,0,0.3);
  --input-bg: #0b0f1a;
  --nav-bg: #141b2d;
  --card-bg: var(--surface);
  --hover-bg: var(--surface-2);
  --table-hover: var(--surface-2);
  --explanation-bg: var(--surface-2);
  --choices-border: var(--border);
  --text-secondary: var(--text-2);
  --header-bg: #141b2d;
  --header-text: #f1f5f9;
}

/* --- Reset & Base --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video, iframe { max-width: 100%; height: auto; }

/* --- Layout --- */
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
.page-wrap { max-width: 900px; margin: 40px auto; padding: 0 20px; }
.page-wrap-lg { max-width: 1100px; margin: 40px auto; padding: 0 20px; }

/* --- Navigation Header --- */
/* z-index layering: header=1000, user-dropdown=9999, notif=3000, emoji-picker=10000, toast=99999, connLost=5000 */
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.12);
  position: sticky;
  top: 0;
  z-index: 1000;
}
.header h1 { font-size: 18px; font-weight: 800; letter-spacing: -0.5px; }
.header h1 a { color: var(--header-text) !important; text-decoration: none !important; }
.header .user-info {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  overflow: visible;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.header .user-info::-webkit-scrollbar { display: none; }
.header .user-info .username {
  font-weight: 700;
  font-size: 13px;
  margin-right: 8px;
  border-right: 1px solid rgba(255,255,255,0.25);
  padding-right: 12px;
  opacity: 0.9;
  cursor: pointer;
}
.user-dropdown { position: relative; display: inline-block; }
.user-dropdown-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; cursor: pointer; border-radius: var(--radius-sm);
  transition: background .15s; text-decoration: none !important;
  color: rgba(255,255,255,0.85);
}
.user-dropdown-trigger:hover { background: rgba(255,255,255,0.1); color: #fff; }
.user-dropdown-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; color: #fff;
  background: var(--primary);
}
.user-dropdown-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.user-dropdown-name { font-size: 13px; font-weight: 500; }
.user-dropdown-caret { font-size: 8px; opacity: .6; transition: transform .2s; }
.user-dropdown.open .user-dropdown-caret { transform: rotate(180deg); }
.user-dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--surface);
  min-width: 220px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  z-index: 9999;
  padding: 6px;
  animation: dropIn .15s ease;
}
.user-dropdown-content::before {
  content:''; position:absolute; top:-6px; right:22px;
  width:10px; height:10px; background:var(--surface);
  border-left:1px solid var(--border); border-top:1px solid var(--border);
  transform:rotate(45deg);
}
@keyframes dropIn { from { opacity:0; transform:translateY(-6px) scale(.96); } to { opacity:1; transform:translateY(0) scale(1); } }
.user-dropdown.open .user-dropdown-content,
.user-dropdown:hover .user-dropdown-content { display: block; }

.user-dropdown-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px 10px; border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.user-dropdown-header .user-dropdown-avatar {
  width: 40px; height: 40px; font-size: 16px; flex-shrink: 0;
}
.user-dropdown-header-info { min-width: 0; }
.user-dropdown-header-name { font-weight: 600; font-size: 14px; color: #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-theme="dark"] .user-dropdown-header-name { color: var(--text); }
.user-dropdown-header-sub {
  font-size: 11px; color: var(--text-3); margin-top: 1px;
  display: flex; align-items: center; gap: 4px;
}

.user-dropdown-item {
  display: flex !important; align-items: center; gap: 10px;
  padding: 9px 14px !important;
  color: var(--text) !important; font-size: 13px !important;
  border-radius: var(--radius-sm) !important;
  white-space: nowrap; transition: background .12s;
  text-decoration: none !important; cursor: pointer;
}
.user-dropdown-item:hover { background: var(--surface-2) !important; color: var(--primary) !important; }
.user-dropdown-item .item-icon { width: 20px; text-align: center; flex-shrink: 0; font-size: 14px; }
.user-dropdown-divider { height:1px; background:var(--border); margin:4px 8px; }
.user-dropdown-footer { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }

.header .user-info a {
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 6px;
  transition: all 0.15s;
  text-decoration: none !important;
}
.header .user-info a:hover { color: #fff; background: rgba(255,255,255,0.12); }
.header .user-info .notif-bell { color: rgba(255,255,255,0.85); padding: 5px 8px; }
.header .user-info .notif-bell:hover { color: #fff; }

/* --- Notification Bell --- */
.notif-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text-2);
  transition: color .2s;
}
.notif-bell:hover { color: var(--text); }
.notif-icon { font-size: 18px; line-height: 1; }
.notif-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  background: var(--danger, #e74c3c);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  padding: 0 4px;
  pointer-events: none;
}
/* --- Notification Dropdown --- */
.notif-dropdown {
  display: none;
  position: fixed;
  top: 62px;
  right: 12px;
  width: 380px;
  max-height: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  z-index: 3000;
  flex-direction: column;
  overflow: hidden;
}
.notif-dropdown.open { display: flex; }
.notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.notif-mark-all {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.notif-mark-all:hover { background: var(--surface-2); }
.notif-list {
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
}
.notif-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
  position: relative;
}
.notif-item:hover { background: var(--surface-2); }
.notif-unread { background: rgba(var(--primary-rgb, 99,102,241), 0.08); }
.notif-msg { flex: 1; font-size: 13px; line-height: 1.4; color: var(--text); }
.notif-time { font-size: 11px; color: var(--text-3); white-space: nowrap; margin-top: 2px; }
.notif-mark-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
}
.notif-mark-btn:hover { opacity: .8; }
/* --- Arena Popup --- */
.arena-popup {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 5000;
  transform: translateY(120px);
  opacity: 0;
  transition: transform .4s cubic-bezier(.34,1.56,.64,1), opacity .4s ease;
}
.arena-popup.show {
  transform: translateY(0);
  opacity: 1;
}
.arena-popup-content {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, var(--primary), #6c5ce7);
  color: #fff;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
  max-width: 360px;
}
.arena-popup-icon { font-size: 28px; }
.arena-popup-msg { flex: 1; font-size: 14px; font-weight: 500; line-height: 1.4; }
.arena-popup-btn {
  background: rgba(255,255,255,.2);
  border: 1px solid rgba(255,255,255,.4);
  color: #fff;
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .2s;
}
.arena-popup-btn:hover { background: rgba(255,255,255,.35); }
.arena-popup-close {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
}
/* --- Toast Notifications --- */
#toastContainer {
  position: fixed;
  top: 70px;
  right: 16px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 380px;
  width: calc(100% - 32px);
}
.toast {
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  transition: opacity 0.3s, transform 0.3s;
}
.toast-removing {
  opacity: 0;
  transform: translateX(80px);
}
.toast-icon { font-size: 22px; flex-shrink: 0; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: 12px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.04em; }
.toast-msg { font-size: 13px; color: var(--text); line-height: 1.4; margin-top: 1px; word-wrap: break-word; }
.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  font-size: 14px;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.toast-close:hover { color: var(--text); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(60px); }
  to { opacity: 1; transform: translateX(0); }
}
@media (max-width: 640px) {
  #toastContainer { top: 60px; right: 8px; width: calc(100% - 16px); max-width: none; }
  .toast { padding: 10px 12px; }
}
/* --- Toggle Switch --- */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 24px;
  transition: .2s;
}
.switch-slider::before {
  content: '';
  position: absolute;
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .2s;
}
.switch input:checked + .switch-slider { background: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }

/* --- Cards --- */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.card h2 { font-size: 20px; font-weight: 700; margin-bottom: 20px; color: var(--text); }
.card h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; color: var(--text); }

/* --- Forms --- */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-control,
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
  background: var(--input-bg);
  color: var(--text);
}
.form-control:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 22px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none !important;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px var(--primary-glow); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 6px 16px var(--primary-glow); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); border-color: var(--border-2); transform: translateY(-1px); }
.btn-success { background: var(--success); color: #fff; box-shadow: 0 4px 12px rgba(22,163,74,0.3); }
.btn-success:hover:not(:disabled) { background: #15803d; transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 4px 12px rgba(220,38,38,0.3); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; transform: translateY(-1px); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover:not(:disabled) { background: #b45309; transform: translateY(-1px); }
.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-lg { padding: 14px 32px; font-size: 16px; border-radius: var(--radius-lg); }

.no-data { text-align:center; padding:40px; color:var(--text-3); font-size:14px; }

/* --- Alerts --- */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; border: 1px solid; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.alert-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.alert-info { background: var(--primary-light); color: var(--primary); border-color: #bfdbfe; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }

/* --- Modals --- */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  overflow-y: auto;
}
.modal-content {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 760px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  position: relative;
  color: var(--text);
  border: 1px solid var(--border);
}
.modal-close {
  position: absolute; top: 16px; right: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px; height: 32px;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }
.choice-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.choice-row input { flex: 1; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--input-bg); color: var(--text); font-family: inherit; font-size: 14px; }
.choice-row .remove-btn { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 22px; padding: 2px 6px; border-radius: 6px; transition: background 0.15s; }
.choice-row .remove-btn:hover { background: var(--danger-bg); }
.hidden { display: none !important; }

/* --- Tables --- */
.history-table { width: 100%; border-collapse: collapse; }
.history-table th, .history-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.history-table th { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-2); background: var(--surface-2); }
.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }

/* --- Pagination --- */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; }
.page-btn {
  padding: 8px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: all 0.15s;
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* --- Stats Grid --- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-3px); }
.stat-card .stat-value { font-size: 32px; font-weight: 800; color: var(--primary); }
.stat-card .stat-label { font-size: 12px; font-weight: 600; color: var(--text-2); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }

/* --- Controls Bar --- */
.controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 24px; }
.controls select, .controls input {
  padding: 9px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; background: var(--surface); color: var(--text); font-family: inherit;
}

/* --- Question Navigation Panel --- */
.question-nav {
  width: 220px; flex-shrink: 0;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: sticky;
  top: 80px;
}
.nav-header { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; color: var(--text-2); }
.nav-timer { font-size: 26px; font-weight: 800; text-align: center; padding: 10px 0; color: var(--primary); font-variant-numeric: tabular-nums; }
.nav-timer-sub { font-size: 11px; text-align: center; color: var(--text-2); margin-bottom: 16px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.nav-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-bottom: 16px; }
.nav-item {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; border-radius: 6px; cursor: pointer;
  transition: all 0.15s; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text-2);
}
.nav-item:hover { transform: scale(1.12); }
.nav-item.current { border-color: var(--primary); border-width: 2px; color: var(--primary); background: var(--primary-light); }
.nav-item.answered { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.nav-item.review { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.nav-legend { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: var(--text-2); }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.legend-dot.answered { background: var(--success-bg); border: 1px solid var(--success-border); }
.legend-dot.unanswered { background: var(--surface); border: 1px solid var(--border); }
.legend-dot.review { background: var(--warning-bg); border: 1px solid var(--warning-border); }
.legend-dot.current { background: var(--primary-light); border: 2px solid var(--primary); }

/* --- Training / Question display --- */
.question-card { background: var(--surface); border-radius: var(--radius-lg); padding: 28px; margin-bottom: 20px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.question-number { font-size: 12px; font-weight: 700; color: var(--text-2); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.question-text { font-size: 17px; font-weight: 600; line-height: 1.65; margin-bottom: 24px; color: var(--text); }
.choices { list-style: none; display: grid; gap: 10px; }
.choices li { }
.choices label {
  display: flex; align-items: flex-start;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.18s;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 500;
}
.choices label:hover { border-color: var(--primary); background: var(--primary-light); }
.choices input[type="radio"] { margin-right: 12px; margin-top: 2px; flex-shrink: 0; }
.choices .selected { border-color: var(--primary); background: var(--primary-light); }
.choices .correct { border-color: var(--success); background: var(--success-bg); color: var(--success); font-weight: 700; }
.choices .wrong { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.choices .choice-prefix { font-weight: 700; margin-right: 8px; }
.question-nav-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding: 14px 20px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.quiz-progress { font-size: 13px; color: var(--text-2); font-weight: 600; }
.training-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; gap: 12px; }

/* --- Explanation --- */
.explanation, .explanation-text {
  background: var(--surface-2);
  border-left: 5px solid var(--primary);
  padding: 24px;
  margin-top: 24px;
  border-radius: var(--radius);
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
  overflow-wrap: break-word;
  white-space: pre-wrap;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}
.explanation-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 24px;
  margin-bottom: -16px;
  position: relative;
  z-index: 1;
  padding-left: 12px;
}
.explanation-text { margin-top: 0; }
.explanation h4 { margin-bottom: 12px; color: var(--primary); font-weight: 800; }

/* --- Category bars (Dashboard) --- */
.category-bar-container { margin-bottom: 14px; }
.category-bar-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; font-weight: 500; }
.category-bar-track { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; }
.category-bar-fill { height: 100%; border-radius: 99px; transition: width 0.6s ease; }

/* --- Chart container --- */
.chart-container { position: relative; width: 100%; height: 200px; margin-bottom: 20px; }
.chart-container canvas { width: 100% !important; height: 100% !important; }

/* --- Quiz Summary / Results --- */
.quiz-summary { text-align: center; padding: 48px 24px; }
.quiz-summary .score { font-size: 56px; font-weight: 900; color: var(--primary); }
.quiz-summary .score-label { font-size: 18px; color: var(--text-2); margin-top: 8px; font-weight: 500; }
.result-stats-grid { display: flex; justify-content: center; gap: 32px; margin-top: 28px; flex-wrap: wrap; font-size: 14px; color: var(--text-2); }
.result-stats-grid strong { font-size: 22px; color: var(--text); display: block; margin-bottom: 4px; font-weight: 800; }

/* --- Reveal section --- */
.reveal-section { overflow: hidden; max-height: 0; opacity: 0; transition: max-height .35s ease, opacity .25s ease, margin .25s ease; margin-top: 0; }
.reveal-section.open { max-height: 1200px; opacity: 1; margin-top: 12px; }

/* --- Auth pages --- */
.auth-page { display: flex; justify-content: center; align-items: center; min-height: calc(100vh - 60px); padding: 20px; }
.auth-card { background: var(--surface); border-radius: var(--radius-xl); padding: 40px; width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.auth-card h2 { margin-bottom: 8px; font-size: 26px; font-weight: 800; color: var(--text); }
.auth-card .btn { width: 100%; }
.auth-card .footer-text { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-2); }

/* --- Utility --- */
.text-center { text-align: center; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.quiz-setup-grid { max-width: 500px; }

/* --- Animations --- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes toastSlideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
.animate-fade-up { animation: fadeUp 0.35s ease-out both; }
/* =============================================
   RESPONSIVE DESIGN
   ============================================= */

/* Phones < 640px */
@media (max-width: 640px) {
  .header { padding: 10px 14px; height: auto; min-height: 52px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .header-row { width: 100%; }
  .header h1 { font-size: 16px; }
  .header .user-info { 
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 4px;
    padding-bottom: 4px;
  }
  .header .user-info::-webkit-scrollbar { display: none; }
  .header .user-info a { font-size: 12px; padding: 6px 10px; margin-left: 0; white-space: nowrap; }
  .user-dropdown-trigger { padding: 4px 8px; }
  .user-dropdown-name { display: none; }
  .user-dropdown-avatar { width: 24px; height: 24px; font-size: 11px; }
  .user-dropdown-caret { display: none; }
  .user-dropdown-overlay { display: none; position: fixed; inset:0; background: rgba(0,0,0,.4); z-index:9998; }
  .user-dropdown.open .user-dropdown-overlay { display: block; }
  .user-dropdown-content {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0;
    min-width: 0; border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 70vh; overflow-y: auto;
    padding: 8px 6px 20px;
    animation: slideUp .25s ease;
    box-shadow: 0 -4px 24px rgba(0,0,0,.2);
  }
  .user-dropdown-content::before { display:none; }
  .user-dropdown-content::after { content:''; display:block; width:36px; height:4px; background:var(--text-3); border-radius:4px; margin:0 auto 10px; opacity:.4; }
  @keyframes slideUp { from { transform:translateY(100%); } to { transform:translateY(0); } }
  .user-dropdown.open .user-dropdown-content { display: block !important; }
  .user-dropdown-header { padding: 4px 12px 10px; }
  .user-dropdown-item { padding: 12px 16px !important; font-size: 14px !important; gap: 12px; }
  .user-dropdown-divider { margin:4px 12px; }
  .user-dropdown-footer { margin-top: 2px; padding-top: 2px; }
  .page-wrap, .page-wrap-lg { margin: 16px auto; padding: 0 12px; }
  .card { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px 10px; }
  .stat-card .stat-value { font-size: 22px; }
  .question-text { font-size: 15px; }
  .choices label { padding: 12px 14px; font-size: 13px; }
  .question-nav { width: 100%; position: static; }
  .nav-grid { grid-template-columns: repeat(5, 1fr); }
  .training-nav { flex-direction: column; }
  .training-nav .btn { width: 100%; }
  .modal-overlay { padding: 12px; align-items: flex-start; }
  .modal-content { padding: 20px; border-radius: var(--radius-lg); }
  .history-table th, .history-table td { padding: 8px 10px; font-size: 12px; }
  .controls { flex-direction: column; align-items: stretch; }
  .controls select, .controls input { width: 100%; }
  .auth-card { padding: 24px 20px; }
  .result-stats-grid { flex-direction: column; align-items: center; gap: 12px; }
  .quiz-summary .score { font-size: 40px; }
  .question-nav-header { flex-direction: column; gap: 8px; }
  .explanation { padding: 12px; font-size: 13px; margin-top: 16px; border-radius: var(--radius); }
}

/* Tablets 640-900px */
@media (min-width: 641px) and (max-width: 900px) {
  .header { padding: 10px 16px; flex-wrap: wrap; height: auto; }
  .header-row { width: 100%; }
  .header h1 { margin-bottom: 0; }
  .header .user-info { 
    width: 100%; 
    overflow-x: auto; 
    overflow-y: hidden;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 6px;
  }
  .header .user-info::-webkit-scrollbar { display: none; }
  .header .user-info a { font-size: 12px; padding: 6px 10px; white-space: nowrap; }
  
  .user-dropdown { position: static; }
  .user-dropdown-content {
    top: 100%;
    right: 16px;
    margin-top: 4px;
  }
  .page-wrap, .page-wrap-lg { padding: 0 16px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .question-nav { width: 100%; position: static; margin-bottom: 16px; }
  .nav-grid { grid-template-columns: repeat(8, 1fr); }
  .modal-content { max-width: 90%; }
}

/* Small Desktop 900-1100px */
@media (min-width: 901px) and (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Topic Prefixes */
.prefix-badge { display:inline-block; padding:2px 10px; border-radius:4px; font-size:11px; font-weight:700; line-height:1.5; margin-right:8px; vertical-align:middle; }

/* Video Embeds */
.video-embed-wrapper { margin: 12px 0; border-radius: var(--radius); overflow: hidden; }
.video-embed-wrapper iframe { width: 100%; max-width: 560px; height: 315px; display: block; border-radius: var(--radius-sm); background: #000; }

/* Forum layout */
.forum-layout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }

/* Profile tabs wrap - horizontally scrollable on mobile, stretched on desktop */
.profile-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.profile-tabs::-webkit-scrollbar { display: none; }
.profile-tab {
  flex: 0 0 auto;
  padding: 10px 18px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-3);
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all .15s;
  white-space: nowrap;
}
.profile-tab:hover { color: var(--text-2); background: var(--surface-2); }
.profile-tab.active { color: var(--primary); background: var(--primary-light); }

@media (min-width: 769px) {
  .profile-tabs { flex-wrap: nowrap; }
  .profile-tab { flex: 1; }
}

/* Fix video embed on mobile */
@media (max-width: 640px) {
  .notif-dropdown { position: fixed; top: 54px; left: 8px; right: 8px; width: auto; max-height: 70vh; }
  .arena-popup { left: 12px; right: 12px; bottom: 12px; }
  .arena-popup-content { max-width: 100%; }
  .footer-theme-toggle { width: 100%; justify-content: center; backdrop-filter: none; }
  .video-embed-wrapper iframe { height: 200px; }
  .forum-layout { grid-template-columns: 1fr; }
  .profile-tab { font-size: 11px; padding: 8px 14px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .user-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .library-header { flex-direction:column; align-items:stretch !important; }
  .library-header > div:first-child { width:100%; }
  .search-container { max-width:100% !important; }
  .search-container input { width:100%; }
  .q-header-row { flex-direction:column; gap:8px; }
  .q-footer { flex-direction:column; gap:8px; align-items:stretch; }
  .q-footer .btn { width:100%; text-align:center; justify-content:center; }
  .history-layout { grid-template-columns:1fr; }
  .session-list { max-height:300px; }
  .review-q-card .q-header { flex-direction:column; gap:8px; }
  .page-header { flex-direction:column; align-items:flex-start !important; gap:8px; }
  .page-header .btn { width:100%; text-align:center; }
  .quiz-setup-grid { max-width:100%; }
  .flex-row { flex-direction:column !important; }
  .btn-group { display:flex; flex-direction:column; gap:8px; }
  .btn-group .btn { width:100%; justify-content:center; }
  [class*="q-actions"], [class*="review-q-card"] .q-header { flex-direction:column; gap:10px; }
  [class*="q-actions"] .btn { width:100%; justify-content:center; }
  .review-flag { justify-content:center; }
  .page-wrap, .page-wrap-lg { overflow-x:hidden; }

  /* Thread card adjustments for mobile */
  .thread-card { flex-direction: column; gap: 12px; padding: 16px; }
}

/* --- Footer --- */
.site-footer {
  background: linear-gradient(180deg, #0b1121 0%, #0f172a 100%);
  border-top: 1px solid rgba(99, 102, 241, 0.08);
  padding: 56px 24px 36px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
  margin-top: 64px;
  position: relative;
  overflow: hidden;
}
.site-footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.5), rgba(129, 140, 248, 0.5), transparent);
  animation: footerBorderShimmer 4s ease-in-out infinite;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(129, 140, 248, 0.1), transparent);
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.footer-links a:hover, .footer-link-btn:hover {
  color: #f1f5f9;
}
.footer-links a:active, .footer-link-btn:active {
}
.footer-divider {
  width: 48px;
  height: 3px;
  background: linear-gradient(90deg, #6366f1, #2563eb, #818cf8);
  border-radius: 4px;
  margin: 0 auto 28px;
  opacity: 0.5;
}
.prefix-badge { display:inline-block; padding:2px 10px; border-radius:4px; font-size:11px; font-weight:700; line-height:1.5; margin-right:8px; vertical-align:middle; }

/* Video Embeds */
.video-embed-wrapper { margin: 12px 0; border-radius: var(--radius); overflow: hidden; }
.video-embed-wrapper iframe { width: 100%; max-width: 560px; height: 315px; display: block; border-radius: var(--radius-sm); background: #000; }

/* Forum layout */
.forum-layout { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }

/* Profile tabs wrap - horizontally scrollable on mobile, stretched on desktop */
.profile-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.profile-tabs::-webkit-scrollbar { display: none; }
.profile-tab {
  flex: 0 0 auto;
  padding: 10px 18px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-3);
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all .15s;
  white-space: nowrap;
}
.profile-tab:hover { color: var(--text-2); background: var(--surface-2); }
.profile-tab.active { color: var(--primary); background: var(--primary-light); }

@media (min-width: 769px) {
  .profile-tabs { flex-wrap: nowrap; }
  .profile-tab { flex: 1; }
}

/* Fix video embed on mobile */
@media (max-width: 640px) {
  .notif-dropdown { position: fixed; top: 54px; left: 8px; right: 8px; width: auto; max-height: 70vh; }
  .arena-popup { left: 12px; right: 12px; bottom: 12px; }
  .arena-popup-content { max-width: 100%; }
  .video-embed-wrapper iframe { height: 200px; }
  .forum-layout { grid-template-columns: 1fr; }
  .profile-tab { font-size: 11px; padding: 8px 14px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .user-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .library-header { flex-direction:column; align-items:stretch !important; }
  .library-header > div:first-child { width:100%; }
  .search-container { max-width:100% !important; }
  .search-container input { width:100%; }
  .q-header-row { flex-direction:column; gap:8px; }
  .q-footer { flex-direction:column; gap:8px; align-items:stretch; }
  .q-footer .btn { width:100%; text-align:center; justify-content:center; }
  .history-layout { grid-template-columns:1fr; }
  .session-list { max-height:300px; }
  .review-q-card .q-header { flex-direction:column; gap:8px; }
  .page-header { flex-direction:column; align-items:flex-start !important; gap:8px; }
  .page-header .btn { width:100%; text-align:center; }
  .quiz-setup-grid { max-width:100%; }
  .flex-row { flex-direction:column !important; }
  .btn-group { display:flex; flex-direction:column; gap:8px; }
  .btn-group .btn { width:100%; justify-content:center; }
  [class*="q-actions"], [class*="review-q-card"] .q-header { flex-direction:column; gap:10px; }
  [class*="q-actions"] .btn { width:100%; justify-content:center; }
  .review-flag { justify-content:center; }
  .page-wrap, .page-wrap-lg { overflow-x:hidden; }

  /* Thread card adjustments for mobile */
  .thread-card { flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; }
  .thread-card .reply-badge { align-self: flex-start; margin-top: 4px; }
}

/* --- Footer --- */
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
  max-width: 1200px;
  margin: 0 auto 32px;
  text-align: left;
}
.footer-col-title {
  font-size: 13px;
  font-weight: 800;
  color: #e2e8f0;
  margin: 0 0 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.footer-logo-block {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}
.footer-logo-text {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
}
.footer-about-text {
  font-size: 13.5px;
  line-height: 1.7;
  color: #64748b;
  margin: 0;
}
.footer-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.footer-link-btn {
  color: #64748b;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.8;
  transition: color 0.2s;
}
.footer-link-btn:hover {
  color: #e2e8f0;
  background: none;
  transform: none;
  box-shadow: none;
}
.footer-social-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.footer-social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(148,163,184,0.08);
  transition: all 0.25s;
  text-decoration: none;
}
.footer-social-link:hover {
  background: rgba(99,102,241,0.15);
  transform: translateY(-2px);
}
.social-icon { font-size: 0; display: block; width: 20px; height: 20px; background-size: contain; background-repeat: no-repeat; background-position: center; }
.social-icon-fb { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2364748b'%3E%3Cpath d='M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z'/%3E%3C/svg%3E"); }
.social-icon-tw { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2364748b'%3E%3Cpath d='M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z'/%3E%3C/svg%3E"); }
.social-icon-ig { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2364748b'%3E%3Cpath d='M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z'/%3E%3C/svg%3E"); }
.social-icon-li { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2364748b'%3E%3Cpath d='M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z'/%3E%3C/svg%3E"); }
.social-icon-gh { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2364748b'%3E%3Cpath d='M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12'/%3E%3C/svg%3E"); }
.social-icon-yt { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2364748b'%3E%3Cpath d='M23.498 6.186a3.016 3.016 0 00-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 00.502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 002.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 002.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z'/%3E%3C/svg%3E"); }
.social-icon-gl { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2364748b'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z'/%3E%3C/svg%3E"); }
.footer-contact-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #64748b;
  margin-bottom: 8px;
}
.footer-contact-item a { color: #818cf8; text-decoration: none; font-weight: 500; }
.footer-contact-item a:hover { text-decoration: underline; }
.footer-contact-icon { flex-shrink: 0; font-size: 14px; width: 20px; text-align: center; }
.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto;
}
.footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.site-footer p {
  margin: 0;
  color: #475569;
  letter-spacing: 0.02em;
}
.footer-copyright { font-size: 13px; color: #475569; }
.footer-theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 18px;
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 20px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  background: rgba(148, 163, 184, 0.06);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.footer-theme-toggle:hover {
  color: #f1f5f9;
  border-color: rgba(99, 102, 241, 0.3);
  background: rgba(99, 102, 241, 0.08);
  transform: translateY(-2px);
}
.scroll-to-top {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(148,163,184,0.15);
  background: rgba(148,163,184,0.06);
  color: #cbd5e1;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.3s;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
}
.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.scroll-to-top:hover {
  background: rgba(99,102,241,0.15);
  border-color: rgba(99,102,241,0.3);
  color: #f1f5f9;
  transform: translateY(-2px);
}
.footer-col-extra .footer-extra-content { font-size: 13px; color: #64748b; line-height: 1.6; }

/* Footer responsive */
@media (max-width: 900px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .footer-bottom { flex-direction: column; text-align: center; }
  .footer-actions { width: 100%; justify-content: center; }
  .footer-social-row { justify-content: center; }
}

[data-theme="light"] .site-footer {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-top-color: rgba(0,0,0,0.05);
}
[data-theme="light"] .footer-links a, [data-theme="light"] .footer-link-btn {
  color: #475569;
}
[data-theme="light"] .footer-links a:hover, [data-theme="light"] .footer-link-btn:hover {
  color: #1e293b;
}
[data-theme="light"] .footer-theme-toggle {
  color: #64748b;
  border-color: rgba(0,0,0,0.08);
  background: rgba(0,0,0,0.02);
}
[data-theme="light"] .footer-theme-toggle:hover {
  color: #1e293b;
  border-color: rgba(99, 102, 241, 0.2);
  background: rgba(99, 102, 241, 0.04);
}
[data-theme="light"] .footer-col-title { color: #1e293b; }
[data-theme="light"] .footer-link-btn { color: #475569; }
[data-theme="light"] .footer-link-btn:hover { color: #1e293b; }
[data-theme="light"] .footer-contact-item { color: #475569; }
[data-theme="light"] .footer-contact-item a { color: #6366f1; }
[data-theme="light"] .footer-extra-content { color: #475569; }
[data-theme="light"] .footer-social-link { background: rgba(0,0,0,0.03); }
[data-theme="light"] .footer-social-link:hover { background: rgba(99,102,241,0.08); }
[data-theme="light"] .footer-logo-text { color: #818cf8; }
[data-theme="light"] .scroll-to-top { border-color: rgba(0,0,0,0.08); background: rgba(0,0,0,0.02); color: #64748b; }
[data-theme="light"] .scroll-to-top:hover { background: rgba(99,102,241,0.08); border-color: rgba(99,102,241,0.2); color: #1e293b; }

/* Activity Stream Mini-Block */
.as-mini { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.as-mini-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; cursor: pointer; font-size: 14px; font-weight: 700; color: var(--text); border-bottom: 1px solid var(--border); user-select: none; }
.as-mini-body { max-height: 320px; overflow-y: auto; }
.as-mini-item { display: flex; align-items: center; gap: 8px; padding: 10px 16px; font-size: 13px; border-bottom: 1px solid var(--border); }
.as-mini-item:last-child { border-bottom: none; }
.as-mini-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.as-mini-msg { flex: 1; color: var(--text-2); line-height: 1.4; min-width: 0; }
.as-mini-msg a { color: var(--text); text-decoration: none; }
.as-mini-msg a:hover { text-decoration: underline; }
.as-mini-time { font-size: 11px; color: var(--text-3); flex-shrink: 0; white-space: nowrap; }

/* =============================================
   MOBILE SIDEBAR DRAWER AND HAMBURGER MENU
   ============================================= */

/* Hamburger Button */
.hamburger-menu {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 24px;
  height: 18px;
  cursor: pointer;
  z-index: 10002;
  margin-left: 12px;
  background: transparent;
  border: none;
  padding: 0;
}
.hamburger-menu span {
  display: block;
  height: 2.5px;
  width: 100%;
  background-color: rgba(255,255,255,0.9);
  border-radius: 2px;
  transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
}
.hamburger-menu.open span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}
.hamburger-menu.open span:nth-child(2) {
  opacity: 0;
}
.hamburger-menu.open span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* Sidebar overlay */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* Sliding Sidebar Drawer */
.mobile-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 290px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25);
  z-index: 9999;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.mobile-sidebar.open {
  transform: translateX(0);
}

/* Sidebar Close Button */
.sidebar-close-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 10001;
}
.sidebar-close-btn:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Sidebar Internal elements */
.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
}
.sidebar-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.sidebar-profile-info {
  min-width: 0;
}
.sidebar-profile-name {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}
.sidebar-profile-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.sidebar-menu-links {
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}
.sidebar-link:hover, .sidebar-link.active {
  background: var(--surface-2);
  color: var(--primary);
}
.search-box {
  position: relative;
  width: 100%;
}
.search-box::before {
  content: '\1f50d';
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  opacity: 0.5;
  pointer-events: none;
  z-index: 1;
}
#searchInput {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 2px solid var(--border, #e2e8f0);
  border-radius: 12px;
  font-size: 0.9rem;
  background: var(--surface, #fff);
  color: var(--text-1, #1e293b);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}
#searchInput:focus {
  border-color: var(--primary, #6366f1);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
#searchInput::placeholder {
  color: var(--text-3, #94a3b8);
}

.sidebar-link.active {
  border-left: 3px solid var(--primary);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  padding-left: 13px;
}
.sidebar-link .link-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 16px 8px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface-2);
}

/* Responsive adjustment for Mobile Header */
@media (max-width: 768px) {
  .hamburger-menu {
    display: flex;
  }
  .header .user-info a:not(.notif-bell):not(.user-dropdown-trigger) {
    display: none !important;
  }
  .user-dropdown {
    display: none !important;
  }
}

/* ── Question Image Display ── */
.question-image {
  margin: 16px auto;
  max-width: 100%;
  text-align: center;
  background: var(--surface-2, #f8fafc);
  border-radius: var(--radius-lg, 12px);
  padding: 12px;
  border: 1px solid var(--border, #e2e8f0);
}
.question-image img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.question-image figcaption {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-2, #64748b);
  font-style: italic;
  line-height: 1.4;
}
.q-image-badge {
  font-size: 14px;
  cursor: default;
  opacity: 0.8;
}

/* ── Image Pool ── */
.pool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.pool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  overflow: hidden;
  transition: all 0.2s;
  box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,0.1));
}
.pool-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.1));
  transform: translateY(-2px);
}
.pool-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
  cursor: pointer;
  transition: filter 0.2s;
}
.pool-card div[onclick]:hover img {
  filter: brightness(0.85);
}
.pool-card-body {
  padding: 12px 16px;
}
.pool-card-body .pool-caption {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 8px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pool-card-body .pool-meta {
  font-size: 11px;
  color: var(--text-3, #94a3b8);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.pool-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.pool-actions .btn { font-size: 12px; padding: 6px 12px; }
.pool-status-pending { color: #f59e0b; font-weight: 700; }
.pool-status-accepted { color: #22c55e; font-weight: 700; }
.pool-status-rejected { color: #ef4444; font-weight: 700; }
.pool-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  overflow-x: auto;
}
.pool-tab {
  padding: 8px 20px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  border: 1px solid transparent;
  border-bottom: none;
  transition: all 0.2s;
  white-space: nowrap;
}
.pool-tab:hover { color: var(--text); background: var(--surface-2); }
.pool-tab.active {
  color: var(--primary);
  background: var(--surface);
  border-color: var(--border);
}
.pool-bulk-bar {
  background: var(--surface-2);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
}
.pool-checkbox {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  z-index: 2;
  accent-color: var(--primary);
}
@media (max-width: 640px) {
  .pool-grid {
    grid-template-columns: 1fr;
  }
  .pool-card img {
    height: 180px;
  }
  .pool-tabs {
    gap: 2px;
  }
  .pool-tab {
    padding: 6px 12px;
    font-size: 12px;
  }
  .pool-bulk-bar {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ── Pool Like Button ── */
.pool-like-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-2);
  transition: all 0.2s;
}
.pool-like-btn:hover {
  border-color: #ef4444;
  background: rgba(239,68,68,0.06);
}
.pool-like-btn.liked {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239,68,68,0.08);
}
.pool-like-btn .like-icon { font-size: 14px; line-height: 1; }
.pool-like-btn .like-count { font-weight: 600; }
.pool-lightbox-like {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  padding: 6px 16px;
  margin-top: 12px;
  font-size: 15px;
  cursor: pointer;
  color: #ccc;
  transition: all 0.2s;
}
.pool-lightbox-like:hover {
  border-color: #ef4444;
  background: rgba(239,68,68,0.15);
}
.pool-lightbox-like.liked {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239,68,68,0.12);
}
.pool-lightbox-like .like-icon { font-size: 18px; line-height: 1; }
.pool-lightbox-like .like-count { font-weight: 700; font-size: 14px; }

/* ── Pool Lightbox ── */
.pool-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: lightboxFadeIn 0.2s ease;
}
@keyframes lightboxFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.pool-lightbox.hidden { display: none; }
.pool-lightbox-close {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 10000;
  background: none;
  border: none;
  color: #fff;
  font-size: 36px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  line-height: 1;
  padding: 4px;
}
.pool-lightbox-close:hover { opacity: 1; }
.pool-lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10000;
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  padding: 16px 12px;
  border-radius: 8px;
  transition: background 0.2s;
  opacity: 0.6;
  line-height: 1;
}
.pool-lightbox-nav:hover { background: rgba(255,255,255,0.2); opacity: 1; }
.pool-lightbox-prev { left: 16px; }
.pool-lightbox-next { right: 16px; }
.pool-lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 90vw;
  max-height: 90vh;
}
.pool-lightbox-content img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}
.pool-lightbox-caption {
  color: #ccc;
  font-size: 14px;
  margin-top: 12px;
  text-align: center;
  max-width: 600px;
  line-height: 1.4;
}
.pool-lightbox-counter {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: #888;
  font-size: 13px;
  background: rgba(0,0,0,0.6);
  padding: 4px 14px;
  border-radius: 20px;
}
@media (max-width: 640px) {
  .pool-lightbox-nav {
    font-size: 22px;
    padding: 12px 10px;
  }
  .pool-lightbox-prev { left: 8px; }
  .pool-lightbox-next { right: 8px; }
  .pool-lightbox-close { top: 12px; right: 14px; font-size: 30px; }
  .pool-lightbox-caption { font-size: 13px; margin-top: 8px; }
  .pool-lightbox-content img { max-height: 70vh; }
}

/* ── Pool Card Placeholder (pending) ── */
.pool-card-placeholder {
  width: 100%;
  height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.pool-card-placeholder .placeholder-icon {
  font-size: 32px;
  opacity: 0.5;
}
.pool-card-placeholder .placeholder-text {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Pool Upload Form ── */
.pool-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--surface);
  margin-bottom: 24px;
}
.pool-upload-area:hover, .pool-upload-area.dragover {
  border-color: var(--primary);
  background: var(--primary-light, rgba(99,102,241,0.05));
}
.pool-upload-area .upload-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}
.pool-upload-area input[type="file"] { display: none; }

/* ── Mobile responsiveness for image filters ── */
@media (max-width: 640px) {
  select#quizImageFilter, select#trainImageFilter {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
  }
  .question-image {
    padding: 8px;
    margin: 12px auto;
  }
  .question-image img {
    border-radius: 6px;
  }
  .card .form-group select,
  .card .form-group input,
  .card .form-group textarea {
    font-size: 16px;
  }
  .card .form-group select {
    min-height: 44px;
  }
}

/* ====== RTL Arabic Support ====== */
html.rtl { direction: rtl; }
html.rtl .header { flex-direction: row-reverse; }
html.rtl .header-row { flex-direction: row-reverse; }
html.rtl .header h1 { margin-left: 0; margin-right: 0; }
html.rtl .user-info { margin-left: 0; margin-right: auto; }
html.rtl .page-wrap, html.rtl .page-wrap-lg { text-align: right; }
html.rtl .choice-prefix { margin-right: 0; margin-left: 4px; }
html.rtl .back-link { flex-direction: row-reverse; }
html.rtl .modal-content { text-align: right; }
html.rtl .question-number { text-align: right; }
html.rtl .quiz-layout { direction: rtl; }
html.rtl .forum-layout { direction: rtl; }
html.rtl .admin-layout { direction: rtl; }
html.rtl .header .user-info a { margin-left: 0; margin-right: 4px; }
html.rtl .footer-grid { direction: rtl; }
html.rtl .footer-bottom { flex-direction: row-reverse; }
html.rtl .neph-card .title { flex-direction: row-reverse; }
html.rtl .section { flex-direction: row-reverse; }
html.rtl .content li { padding-left: 0; padding-right: 20px; }
html.rtl .content li::before { left: auto; right: 0; }
html.rtl .comment-actions { text-align: left; }
html.rtl .reply-meta { flex-direction: row-reverse; }
html.rtl .thread-user-meta { flex-direction: row-reverse; }
html.rtl .page-header { text-align: right; }
html.rtl .stats-grid { direction: rtl; }
html.rtl .user-table-wrap { direction: rtl; }
html.rtl table { text-align: right; }
html.rtl .sg-panel-content { text-align: right; }
html.rtl .sg-progress-stats { direction: rtl; }
html.rtl .arena-popup { right: auto; left: 20px; }
html.rtl .notif-dropdown { right: auto; left: 0; }
html.rtl .user-dropdown-content { right: auto; left: 0; max-width: calc(100vw - 20px); }
html.rtl .user-dropdown-content::before { right: auto; left: 22px; }
html.rtl .user-dropdown-trigger { flex-direction: row-reverse; }
html.rtl .user-dropdown-item { flex-direction: row-reverse; }
html.rtl .user-dropdown-header { flex-direction: row-reverse; text-align: right; }
html.rtl .user-dropdown-footer { flex-direction: row-reverse; }
html.rtl .notif-dropdown { right: auto; left: 0; text-align: right; }
html.rtl .notif-header { flex-direction: row-reverse; }
html.rtl .notif-item { flex-direction: row-reverse; text-align: right; }
html.rtl .notif-item .notif-time { text-align: left; }
html.rtl .arena-popup { right: auto; left: 20px; text-align: right; }
html.rtl .arena-popup .arena-actions { flex-direction: row-reverse; }
/* Buttons & forms */
html.rtl .btn { margin-right: 0; margin-left: 4px; }
html.rtl .btn-group { flex-direction: row-reverse; }
html.rtl .input-group { flex-direction: row-reverse; }
html.rtl .field-input { text-align: right; }
html.rtl select, html.rtl textarea { text-align: right; }
html.rtl .switch { margin-right: 0; margin-left: 8px; }
html.rtl .checkbox-label { flex-direction: row-reverse; }
/* Cards */
html.rtl .card { text-align: right; }
html.rtl .card-header { flex-direction: row-reverse; text-align: right; }
html.rtl .card-footer { flex-direction: row-reverse; text-align: right; }
/* Modals */
html.rtl .modal-content { text-align: right; }
html.rtl .modal-header { flex-direction: row-reverse; text-align: right; }
html.rtl .modal-footer { flex-direction: row-reverse; }
html.rtl .modal-close { right: auto; left: 16px; }
/* Tables */
html.rtl table { text-align: right; }
html.rtl th, html.rtl td { text-align: right; }
html.rtl .user-table-wrap { direction: rtl; }
/* Tabs */
html.rtl .tab-bar { flex-direction: row-reverse; }
html.rtl .tab-btn { margin-right: 0; margin-left: 2px; }
html.rtl .admin-tab { text-align: right; }
/* Pagination */
html.rtl .pagination { flex-direction: row-reverse; }
html.rtl .page-btn { margin-right: 0; margin-left: 2px; }
/* Alerts & toasts */
html.rtl .alert { text-align: right; flex-direction: row-reverse; }
html.rtl .alert .alert-icon { margin-right: 0; margin-left: 10px; }
html.rtl .toast { text-align: right; flex-direction: row-reverse; }
/* Flex/grid alignments */
html.rtl .flex-row, html.rtl .flex { flex-direction: row-reverse; }
html.rtl .space-between { flex-direction: row-reverse; }
html.rtl .stats-grid { direction: rtl; }
html.rtl .stat-card { text-align: right; }
html.rtl .q-row { text-align: right; }
html.rtl .q-header-row { flex-direction: row-reverse; }
html.rtl .q-meta { flex-direction: row-reverse; }
html.rtl .q-actions { flex-direction: row-reverse; }
html.rtl .choice-prefix { margin-right: 0; margin-left: 4px; }
/* Search */
html.rtl .search-box { flex-direction: row-reverse; }
html.rtl .search-box input { text-align: right; }
/* Badges & pills */
html.rtl .badge { margin-right: 0; margin-left: 4px; }
html.rtl .topic-pill { margin-right: 0; margin-left: 4px; }
html.rtl .diff-pill { margin-right: 0; margin-left: 4px; }
/* Dropdowns */
html.rtl .dropdown-content { right: auto; left: 0; text-align: right; }
html.rtl .dropdown-item { flex-direction: row-reverse; }
/* Profile page */
html.rtl .profile-header { flex-direction: row-reverse; text-align: right; }
html.rtl .profile-info { text-align: right; }
html.rtl .profile-stats { flex-direction: row-reverse; }
html.rtl .profile-tabs { flex-direction: row-reverse; }
html.rtl .comment-item { flex-direction: row-reverse; text-align: right; }
html.rtl .comment-actions { text-align: left; }
/* League lobby */
html.rtl .lobby-layout { direction: rtl; }
html.rtl .challenge-card { text-align: right; }
html.rtl .challenge-meta { flex-direction: row-reverse; }
html.rtl .leaderboard-item { flex-direction: row-reverse; text-align: right; }
html.rtl .hall-of-fame { flex-direction: row-reverse; }
html.rtl .online-player-item { flex-direction: row-reverse; text-align: right; }
/* Battle page */
html.rtl .battle-layout { direction: rtl; }
html.rtl .battle-info { flex-direction: row-reverse; }
html.rtl .battle-timer { text-align: center; }
/* Tournament */
html.rtl .bracket-view { direction: rtl; }
html.rtl .bracket-round { text-align: right; }
html.rtl .bracket-match { text-align: right; }
html.rtl .tournament-header { flex-direction: row-reverse; }
/* Groups */
html.rtl .group-header { flex-direction: row-reverse; text-align: right; }
html.rtl .group-tabs { flex-direction: row-reverse; }
html.rtl .group-member-item { flex-direction: row-reverse; text-align: right; }
html.rtl .sg-panel-content { text-align: right; }
html.rtl .sg-progress-stats { direction: rtl; }
html.rtl .sg-pack-card { text-align: right; }
/* Footer */
html.rtl .footer-grid { direction: rtl; }
html.rtl .footer-bottom { flex-direction: row-reverse; }
html.rtl .footer-col { text-align: right; }
html.rtl .footer-social-link { margin-right: 0; margin-left: 8px; }
/* Image pool */
html.rtl .pool-grid { direction: rtl; }
html.rtl .pool-card { text-align: right; }
html.rtl .pool-tabs { flex-direction: row-reverse; }
html.rtl .pool-checkbox { left: auto; right: 8px; }
html.rtl .pool-card-actions-bar { flex-direction: row-reverse; }
/* Messages */
html.rtl .msg-layout { direction: rtl; }
html.rtl .msg-conversation-item { flex-direction: row-reverse; text-align: right; }
html.rtl .msg-bubble { text-align: right; }
html.rtl .msg-input-row { flex-direction: row-reverse; }
/* Achievements */
html.rtl .achieve-grid { direction: rtl; }
html.rtl .achieve-card { text-align: right; }
html.rtl .quest-item { flex-direction: row-reverse; text-align: right; }
/* Study packs */
html.rtl .pack-card { text-align: right; }
html.rtl .pack-meta { flex-direction: row-reverse; }
/* Learning Resources */
.res-container { max-width: 1100px; margin: 0 auto; padding: 20px 16px; }
.res-header { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px; margin-bottom:8px; }
.res-header h1 { font-size:22px; margin:0; display:flex; align-items:center; gap:8px; }
.res-subtitle { font-size:13px; color:var(--text-3); margin-bottom:20px; }
.res-tabs { display:flex; gap:4px; flex-wrap:wrap; margin-bottom:20px; border-bottom:2px solid var(--border); padding-bottom:0; overflow-x:auto; -webkit-overflow-scrolling:touch; }
.res-tab { padding:8px 14px; font-size:13px; font-weight:600; cursor:pointer; border-radius:6px 6px 0 0; transition:all 0.15s; color:var(--text-2); border:1px solid transparent; border-bottom:none; margin-bottom:-2px; white-space:nowrap; }
.res-tab:hover { background:var(--hover-bg); color:var(--text); }
.res-tab.active { color:var(--res-accent, #8b5cf6); border-color:var(--border); background:var(--surface); border-bottom-color:var(--surface); }
.res-controls { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:16px; }
.res-controls select, .res-controls input { padding:7px 12px; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--surface); color:var(--text); font-size:13px; }
.res-controls input { flex:1; min-width:160px; max-width:280px; }
.res-btn { padding:7px 14px; border:none; border-radius:var(--radius-sm); font-size:13px; font-weight:600; cursor:pointer; transition:all 0.15s; background:var(--res-accent, #8b5cf6); color:#fff; display:inline-flex; align-items:center; gap:4px; }
.res-btn:hover { opacity:0.85; }
.res-btn-sm { padding:4px 10px; font-size:11px; }
.res-btn-outline { background:transparent; border:1px solid var(--border); color:var(--text); }
.res-btn-outline:hover { background:var(--hover-bg); }
.res-btn-success { background:var(--success,#22c55e); color:#fff; }
.res-btn-warning { background:var(--warning,#f59e0b); color:#fff; }
.res-btn-danger { background:var(--danger,#ef4444); color:#fff; }
.res-grid { display:grid; grid-template-columns:1fr; gap:10px; }
.res-card { padding:14px 16px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); transition:all 0.15s; }
.res-card:hover { border-color:var(--res-accent, #8b5cf6); box-shadow:0 2px 8px rgba(139,92,246,0.08); }
.res-card-title { font-size:14px; font-weight:600; margin-bottom:4px; display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.res-card-title a { color:var(--text); text-decoration:none; word-break:break-word; }
.res-card-title a:hover { color:var(--res-accent, #8b5cf6); }
.res-card-meta { font-size:11px; color:var(--text-3); display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:6px; }
.res-card-actions { display:flex; gap:4px; flex-wrap:wrap; margin-top:8px; }
.res-badge { display:inline-block; padding:2px 7px; border-radius:4px; font-size:10px; font-weight:700; text-transform:uppercase; white-space:nowrap; }
.res-badge-beginner { background:#dbeafe; color:#1d4ed8; }
.res-badge-intermediate { background:#fef3c7; color:#92400e; }
.res-badge-advanced { background:#fed7aa; color:#9a3412; }
.res-badge-expert { background:#fecaca; color:#991b1b; }
.res-badge-youtube_video { background:#fce7f3; color:#9d174d; }
.res-badge-article { background:#e0e7ff; color:#3730a3; }
.res-badge-pdf { background:#fce4ec; color:#c62828; }
.res-badge-guideline { background:#e8f5e9; color:#2e7d32; }
.res-badge-website { background:#f3e5f5; color:#6a1b9a; }
.res-badge-youtube_playlist { background:#fff3e0; color:#e65100; }
.res-badge-flashcards { background:#e0f7fa; color:#00695c; }
.res-stats { display:grid; grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); gap:10px; margin-bottom:20px; }
.res-stat-card { padding:14px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); text-align:center; }
.res-stat-num { font-size:24px; font-weight:800; color:var(--res-accent, #8b5cf6); }
.res-stat-label { font-size:11px; color:var(--text-3); margin-top:2px; }
.res-progress-bar { height:6px; background:var(--border); border-radius:3px; overflow:hidden; margin:6px 0; }
.res-progress-fill { height:100%; background:var(--res-accent, #8b5cf6); border-radius:3px; transition:width 0.3s; }
.res-progress-text { font-size:11px; color:var(--text-3); }
.res-path-card { padding:16px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); margin-bottom:10px; }
.res-path-header { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:8px; }
.res-path-title { font-size:15px; font-weight:700; display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.res-path-meta { font-size:11px; color:var(--text-3); }
.res-module-list { margin-top:12px; padding-left:20px; }
html.rtl .res-module-list { padding-left:0; padding-right:20px; }
.res-module-item { padding:8px 0; border-bottom:1px solid var(--border); display:flex; justify-content:space-between; align-items:center; gap:8px; font-size:13px; }
.res-module-item:last-child { border-bottom:none; }
.res-module-status { font-size:11px; flex-shrink:0; }
.res-module-resources { margin-left:20px; padding:4px 0; }
html.rtl .res-module-resources { margin-left:0; margin-right:20px; }
.res-module-res { padding:4px 0; font-size:12px; display:flex; align-items:center; gap:6px; }
.res-empty { text-align:center; padding:40px 20px; color:var(--text-3); }
.res-rating-stars { display:inline-flex; gap:2px; }
.res-rating-star { cursor:pointer; font-size:16px; color:var(--text-3); transition:color 0.1s; }
.res-rating-star.active, .res-rating-star:hover { color:#f59e0b; }
.res-type-icon { font-size:16px; }
.res-notes-area { width:100%; min-height:60px; padding:8px; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--input-bg); color:var(--text); font-size:12px; margin-top:6px; resize:vertical; box-sizing:border-box; }
html.rtl .res-tabs { flex-direction:row-reverse; }
html.rtl .res-controls { flex-direction:row-reverse; }
html.rtl .res-card { text-align:right; }
html.rtl .res-card-meta { flex-direction:row-reverse; }
html.rtl .res-card-actions { flex-direction:row-reverse; }
html.rtl .res-path-header { flex-direction:row-reverse; }
html.rtl .res-module-item { flex-direction:row-reverse; text-align:right; }
html.rtl .res-stats { direction:rtl; }
html.rtl .res-stat-card { text-align:center; }
@media(max-width:640px) {
    .res-stats { grid-template-columns:repeat(2,1fr); }
    .res-tab { padding:6px 10px; font-size:12px; }
    .res-controls select, .res-controls input { font-size:12px; padding:5px 8px; }
    .res-card { padding:10px 12px; }
    .res-card-title { font-size:13px; }
    .res-path-card { padding:12px; }
}
@media(max-width:480px) {
    .res-stats { grid-template-columns:1fr 1fr; }
    .res-tab { padding:5px 6px; font-size:10px; }
    .res-controls { flex-direction:column; }
    .res-controls input { max-width:100%; min-width:100%; }
    .res-card-title { font-size:12px; }
    .res-card-meta { font-size:10px; gap:4px; }
    .res-btn-sm { font-size:10px; padding:3px 7px; }
    .res-path-title { font-size:13px; }
    .res-stat-num { font-size:20px; }
}
/* Activity stream */
html.rtl .activity-item { flex-direction: row-reverse; text-align: right; }
html.rtl .activity-meta { flex-direction: row-reverse; }
/* Admin panels */
html.rtl .admin-page { text-align: right; }
html.rtl .admin-stats-grid { direction: rtl; }
html.rtl .admin-stat-card { text-align: right; }
html.rtl .pref-row { flex-direction: row-reverse; }
/* Misc */
html.rtl .help-toc { direction: rtl; }
html.rtl .neph-card { text-align: right; }
html.rtl .read-toggle { margin-left: 0; margin-right: 8px; }
html.rtl .back-link { flex-direction: row-reverse; }
html.rtl .page-header { text-align: right; flex-direction: row-reverse; }
html.rtl .header-actions { flex-direction: row-reverse; }
html.rtl .sidebar { right: 0; left: auto; }
html.rtl .sidebar-overlay { right: 0; left: auto; }
html.rtl .hamburger-menu { margin-right: auto; margin-left: 0; }
html.rtl .tag { margin-right: 0; margin-left: 4px; }
html.rtl .chip { margin-right: 0; margin-left: 4px; }
html.rtl .header h1 svg { margin-right: 0 !important; margin-left: 8px; }
html.rtl .loading-skeleton { direction: ltr; }
html.rtl .question-figure { text-align: center; }
/* Forum detail */
html.rtl .forum-header { flex-direction: row-reverse; }
html.rtl .thread-card { text-align: right; }
html.rtl .thread-meta { flex-direction: row-reverse; }
html.rtl .post-item { text-align: right; }
html.rtl .post-meta { flex-direction: row-reverse; }
html.rtl .reply-item { text-align: right; flex-direction: row-reverse; }
html.rtl .like-btn { flex-direction: row-reverse; }
html.rtl .prefix-badge { margin-right: 0; margin-left: 6px; }
html.rtl .thread-header-card > div[style*="position:absolute"] { right: auto !important; left: 24px !important; }

html.rtl .pack-range-row { direction: rtl; }
html.rtl .pack-range-add-btn { margin-left: 0; margin-right: auto; }
html.rtl .modal-content > div[style*="justify-content: flex-end"] { justify-content: flex-start !important; }

/* History */
html.rtl .session-item .mode-badge { float: left; }
html.rtl .session-item:hover { transform: translateX(-4px); }

@media (max-width: 640px) {
  html.rtl .q-actions { direction: rtl; }
  html.rtl .reply-meta { align-items: flex-end; }
}
