  /* Reset CSS */
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }

  /* Base Body Layout - Mobile First */
  body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh; /* Use min-height for content flexibility */
    display: grid;
    /* Default for mobile, will be overridden by media queries and JS for desktop */
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto; /* Dynamic rows */
    grid-template-areas:
      "profile"
      "header"
      "page"
      "footer";
    font-size: 16px; /* Base font size for rem units */
    --sidebar-width: 250px; /* Default sidebar width for larger screens, adjusted for better initial fit */
  }

  /* Profile Section */
  .profile {
    grid-area: profile;
    background: linear-gradient(135deg, #4a90e2, #7bb3f0);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem; /* Use rem for padding */
    position: relative;
  }

  .author-photo {
    width: 5rem; /* 80px / 16px = 5rem */
    height: 5rem;
    background-color: #1a1a1a;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 0.75rem; /* 12px */
    font-weight: bold;
    text-align: center;
    line-height: 1.2;
    border: 0.1875rem solid white; /* 3px */
    box-shadow: 0 0.25rem 0.75rem rgba(0,0,0,0.2); /* 0 4px 12px */
    overflow: hidden;
  }

  .author-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .profile-upload-btn {
    margin-top: 0.625rem; /* 10px */
    padding: 0.3125rem 0.625rem; /* 5px 10px */
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 0.3125rem; /* 5px */
    cursor: pointer;
    font-size: 0.75rem; /* 12px */
    display: none;
  }

  body.admin-active .profile-upload-btn {
    display: block;
  }

  /* Header */
  .header {
    grid-area: header;
    background: linear-gradient(135deg, #00bcd4, #26c6da);
    color: #004d5c;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
  }

  .header h1 {
    font-size: 1.5rem; /* 24px */
    font-weight: 800;
    margin-bottom: 0.5rem; /* 8px */
    text-shadow: none;
    outline: none;
  }

  .header p {
    font-size: 0.875rem; /* 14px */
    font-weight: 500;
    opacity: 0.9;
    text-shadow: none;
    outline: none;
	margin: 0 24px;
  }
  
/* Resizer for sidebar */
.resizer {
  width: 0.5rem; /* 8px */
  background: #ccc;
  cursor: ew-resize;
  grid-area: resizer;
  z-index: 100;
  display: none; /* Hidden by default, shown on larger screens */
}
.resizer:hover {
  background: #2196f3;
}

/* Mobile Sidebar Toggle Button */
.sidebar-toggle-btn {
  position: fixed;
  top: 0.5rem;
  left: 1rem;
  height: 2.5rem;
  background: linear-gradient(135deg, #3f51b5, #5c6bc0);
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: bold;
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 0.25rem 0.75rem rgba(0,0,0,0.2);
}
.sidebar-toggle-btn:hover {
  background: linear-gradient(135deg, #3648a6, #5361b5);
}

  /* Footer */
  .footer {
    grid-area: footer;
    background: linear-gradient(135deg, #1976d2, #2196f3);
    color: white;
    padding: 1.25rem; /* 20px */
    display: flex;
    flex-direction: column; /* Stack vertically on mobile */
    justify-content: center;
    align-items: center;
    font-size: 0.875rem; /* 14px */
    gap: 0.25rem; /* Gap between items */
  }

  .footer-left {
    display: flex;
    flex-direction: column; /* Stack vertically on mobile */
    gap: 0.25rem; /* 8px */
    margin-bottom: 0.5rem;
  }

  .footer-item {
    display: flex;
    align-items: center;
    gap: 0.5rem; /* 8px */
  }

  .footer-item strong {
    font-weight: 600;
  }

  .footer-item span {
    text-shadow: none;
    outline: none;
  }

/* =========================================================
   HELP BUTTON + ADMIN UI + HELP/CHAT MODAL (FINAL SINGLE)
   ========================================================= */

/* ---------- Help floating button ---------- */
.help-faq-btn{
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: linear-gradient(135deg, #9735e2, #0b74c7);
  color: #fff;
  width: 3rem;
  height: 2.5rem;
  border-radius: 0.625rem 0.625rem 0.625rem 0; /*  lancip di bawah kiri */
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: 700;
  box-shadow: 0 0.375rem 1.25rem rgba(63,81,181,0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.help-faq-btn:hover{
  transform: scale(1.05);
  box-shadow: 0 0.025rem 0.025rem #8b18e4;
}

button#help-faq-btn.help-faq-btn::after{
  content: "AiSisten";
  position: absolute;
  top: -19px;
  left: 50%;
  display: flex;     
  transform: translateX(-50%);
  font-size: 12px;
  font-weight: 780;
  letter-spacing: .2px;
  white-space: nowrap;
  pointer-events: none;

  /* fallback kalau clip-text tidak didukung */
  color: #9735e2;

  /* gradient ungu -> biru (setara style tombolmu) */
  background: linear-gradient(135deg, #9735e2, #1040ef);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.help-faq-btn svg{
  fill: #fff;
  width: 2rem;
  height: 2rem;
}

/* ---------- Admin mode toggle ---------- */
.admin-mode-toggle{
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  background: linear-gradient(135deg, #a7d9f7, #c2e0f2);
  color: #333;
  padding: 0.2rem 0.5rem;
  border-radius: 0.2rem;
  cursor: pointer;
  font-weight: 700;
  z-index: 2500;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
  font-size: 0.65rem;
  border: 1px solid rgba(0,0,0,0.1);
  box-shadow: 0 0.1rem 0.2rem rgba(0,0,0,0.1);
}
.admin-mode-toggle:hover{
  transform: translateY(-0.0625rem);
  box-shadow: 0 0.1875rem 0.375rem rgba(0,0,0,0.15);
  background: linear-gradient(135deg, #c2e0f2, #a7d9f7);
}
.admin-mode-toggle.active{
  background: linear-gradient(135deg, #f44336, #ef5350);
  color: #fff;
}
.admin-mode-toggle.active:hover{
  background: linear-gradient(135deg, #d32f2f, #f44336);
}

/* ---------- Admin login overlay + card ---------- */
#login-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 1500;
  display: none;
}
.admin-login-section{
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #f7f7f7;
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15);
  border: 2px solid #1086ff;
  z-index: 2000;

  display: none;
  flex-direction: column;
  gap: 0.75rem;
  width: 320px;
  height: fit-content;
  overflow: hidden;
}
body.admin-active .admin-login-section{ display: flex; }

.admin-login-section .form-group{ margin-bottom: 0.5rem; }
.admin-login-section label{
  font-weight: 700;
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}
.admin-login-section input:focus{
  outline: none;
  border-color: #1086ff;
  box-shadow: 0 0 0 2px rgba(16,134,255,0.15);
}
.admin-login-section input[type="text"],
.admin-login-section input[type="password"]{
  padding: 0.45rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 0.25rem;
  width: 100%;
  font-size: 0.9rem;
  box-sizing: border-box;
}
.admin-login-section button{
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 0.25rem;
  background-color: #1086ff;
  color: #fff;
  cursor: pointer;
  width: 100%;
  font-size: 0.95rem;
  font-weight: 600;
}
.admin-login-section button:hover{ background-color: #0a6ed6; }

/* ---------- Editable & admin controls ---------- */
.editable-content{
  border: none;
  padding: 0;
  min-height: auto;
}
body.admin-active .editable-content{
  border: 1px dashed rgba(148, 163, 184, 0.5); /* abu lembut */
  padding: 0.3125rem;
  min-height: 1.5em;
}
.editable-content:hover{ background-color: #e6f5ff; }
.editable-content:focus {
  background-color: #e6f5ff;
  outline: 1px solid rgba(59, 130, 246, 0.4);  /* biru lembut */
}

.admin-controls{
  margin-top: 1.25rem;
  padding: 0.9375rem;
  background-color: #fff3e0;
  border-left: 0.3125rem solid #ff9800;
  display: none;
}
body.admin-active .admin-controls{ display: block; }

.admin-controls button{
  margin-right: 0.625rem;
  padding: 0.5rem 0.9375rem;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  font-weight: 700;
}
.admin-controls .save-btn{ background-color: #4CAF50; color: #fff; }
.admin-controls .cancel-btn{ background-color: #f44336; color: #fff; }
.admin-controls .add-material-btn{ background-color: #2196f3; color: #fff; }

.material-item .edit-btn,
.material-item .delete-btn{
  position: absolute;
  top: 0.3125rem;
  right: 0.3125rem;
  background-color: #2196f3;
  color: #fff;
  border: none;
  border-radius: 0.1875rem;
  padding: 0.1875rem 0.375rem;
  font-size: 0.625rem;
  cursor: pointer;
  display: none;
  margin-left: 0.3125rem;
}
.material-item .delete-btn{
  right: 2.8125rem;
  background-color: #f44336;
}
body.admin-active .material-item .edit-btn,
body.admin-active .material-item .delete-btn{
  display: block;
}
 
/* KODE HOVER HEADER */
   .header h1:hover,
   .header p:hover {
	 background-color: rgba(255, 255, 255, 0.2);
	 color: #004d5c;
	 padding: 4px 8px;
	 border-radius: 4px;
	 transition: all 0.3s ease;
	 cursor: pointer;
   }
   .header .editable-content:hover {
	 background-color: rgba(255, 255, 255, 0.2);
	 color: #004d5c;
	 padding: 4px 8px;
	 border-radius: 4px;
	 transition: all 0.3s ease;
	 cursor: pointer;
   }
   .header:hover {
	 background: linear-gradient(135deg, #00bcd4, #26c6da);
	 transition: background 0.3s ease;
   }

/* KODE HOVER FOOTER */
   .footer-item span:hover {
	 background-color: rgba(255, 255, 255, 0.2);
	 color: #FFFFFF;
	 padding: 4px 8px;
	 border-radius: 4px;
	 transition: all 0.3s ease;
	 cursor: pointer;
   }
   .footer .editable-content:hover {
	 background-color: rgba(255, 255, 255, 0.2);
	 color: #FFFFFF;
	 padding: 4px 8px;
	 border-radius: 4px;
	 transition: all 0.3s ease;
	 cursor: pointer;
   }
   .footer-item:hover {
	 background-color: rgba(0, 0, 0, 0.1);
	 border-radius: 6px;
	 padding: 2px;
	 transition: background-color 0.3s ease;
   }

/* Admin Mode Toggle Button */
.admin-mode-toggle {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  background: linear-gradient(135deg, #a7d9f7, #c2e0f2);
  color: #333;
  padding: 0.2rem 0.5rem;
  border-radius: 0.2rem;
  cursor: pointer;
  font-weight: bold;
  z-index: 2500;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  transition: all 0.3s ease;
  font-size: 0.65rem;
  border: 1px solid rgba(0,0,0,0.1);
  box-shadow: 0 0.1rem 0.2rem rgba(0,0,0,0.1);
}

.admin-mode-toggle:hover {
  transform: translateY(-0.0625rem);
  box-shadow: 0 0.1875rem 0.375rem rgba(0,0,0,0.15);
  background: linear-gradient(135deg, #c2e0f2, #a7d9f7);
}

.admin-mode-toggle.active {
  background: linear-gradient(135deg, #f44336, #ef5350);
  color: white;
}
.admin-mode-toggle.active:hover {
  background: linear-gradient(135deg, #d32f2f, #f44336);
}

.admin-login-section {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);  /* benar-benar di tengah */
  background-color: #f7f7f7;
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15);
  border: 2px solid #1086ff;   /* garis biru */
  z-index: 2000;
  display: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 320px;                      /* lebar kartu */
  max-height: 210px;                 /* batasi tinggi kartu */
  overflow: hidden;                  /* hilangkan ruang kosong */
}

body.admin-active .admin-login-section {
  display: flex;
}

.admin-login-section .form-group {
  margin-bottom: 0.5rem;
}

.admin-login-section label {
  font-weight: 700;
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

.admin-login-section input:focus {
  outline: none;
  border-color: #1086ff;
  box-shadow: 0 0 0 2px rgba(16,134,255,0.15);
}
.admin-login-section input[type="text"],
.admin-login-section input[type="password"] {
  padding: 0.45rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 0.25rem;
  width: 100%;
  font-size: 0.9rem;
  box-sizing: border-box;
}

.admin-login-section button {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 0.25rem;
  background-color: #1086ff;
  color: white;
  cursor: pointer;
  width: 100%;
  font-size: 0.95rem;
  font-weight: 600;
}

.admin-login-section button:hover {
  background-color: #0a6ed6;
}

#login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 1500;         /* naikkan cukup tinggi */
  display: none;
}

/* Kotak login di atas overlay */
.admin-login-section {
  position: fixed;
  z-index: 2000;
}

  .editable-content {
    border: none;
    padding: 0;
    min-height: auto;
  }

  /* Styles for editable content when admin mode is active */
  body.admin-active .editable-content {
    border: 0.0625rem dashed #ff9800; /* 1px */
    padding: 0.3125rem; /* 5px */
    min-height: 1.5em;
  }

  .editable-content:hover {
    background-color: #f0f0f0;
  }

  .admin-controls {
    margin-top: 1.25rem; /* 20px */
    padding: 0.9375rem; /* 15px */
    background-color: #fff3e0;
    border-left: 0.3125rem solid #ff9800; /* 5px */
    display: none;
  }

  body.admin-active .admin-controls {
    display: block;
  }

  .admin-controls button {
    margin-right: 0.625rem; /* 10px */
    padding: 0.5rem 0.9375rem; /* 8px 15px */
    border: none;
    border-radius: 0.25rem; /* 4px */
    cursor: pointer;
    font-weight: bold;
  }

  .admin-controls .save-btn {
    background-color: #4CAF50;
    color: white;
  }

  .admin-controls .cancel-btn {
    background-color: #f44336;
    color: white;
  }

  .admin-controls .add-material-btn {
    background-color: #2196f3;
    color: white;
  }

  .material-item .edit-btn, .material-item .delete-btn {
    position: absolute;
    top: 0.3125rem; /* 5px */
    right: 0.3125rem; /* 5px */
    background-color: #2196f3;
    color: white;
    border: none;
    border-radius: 0.1875rem; /* 3px */
    padding: 0.1875rem 0.375rem; /* 3px 6px */
    font-size: 0.625rem; /* 10px */
    cursor: pointer;
    display: none;
    margin-left: 0.3125rem; /* 5px */
  }

  .material-item .delete-btn {
    right: 2.8125rem; /* 45px */
    background-color: #f44336;
  }

  body.admin-active .material-item .edit-btn,
  body.admin-active .material-item .delete-btn {
    display: block;
  }

/* Math Notation - Pre & Post KaTeX */
.stat-card .math-inline,
.chatbot-message .math-block {
  border-radius: 6px;
  font-family: 'SF Mono', 'Courier New', monospace;
  font-size: 0.92em;
  line-height: 1.4;
  margin: 2px 0;
}

/* Block math centered */
.math-block {
  display: block !important;
  margin: 12px auto;
  text-align: center;
  max-width: 90%;
}

/* Post-KaTeX: Clean & Beautiful */
.katex-rendered .math-inline,
.katex-rendered .math-block {
  background: none !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  font-family: KaTeX_Math, serif !important;
  font-size: 1em !important;
}

/* Hover effect (bonus) */
.katex:hover {
  background: #f8f9ff !important;
  border-radius: 4px;
  padding: 2px 4px;
}

/* CSS awal sudah terpisah */
#sarc-stats-panel {
  margin-top:0;position:fixed !important;bottom:65px !important;left:20px !important;z-index:2502 !important;
  background:linear-gradient(57deg, #3a60a8, #31c0a9) !important;color:white !important;
  border-radius:15px !important;box-shadow:0 10px 40px rgba(0,102,204,0.5) !important;
  font-family:system-ui !important;font-size:14px !important;transition:all 0.2s !important;
  min-width:180px !important;padding:0 12px 12px !important;
}
#sarc-stats-panel:not(.minimized){
  min-width:260px !important;padding:0 14px 14px !important;border-radius:18px !important;
  box-shadow:0 15px 60px rgba(0,102,204,0.7) !important;
}
#sarc-stats-panel.minimized #stats-content{display:none !important;}
#sarc-stats-panel.minimized .stats-mini{
  display:flex !important;gap:8px !important;font-size:12px !important;margin-top:4px !important;
}
@media (max-width: 768px) {
  #sarc-stats-panel {
    top: auto !important;
    right: auto !important;
    bottom: 20px !important;
    left: 18px !important;
  }
  #sarc-stats-panel.minimized {
    top: auto !important;
    right: auto !important;
    bottom: 20px !important;
    left: 18px !important;
  }
}

@media screen and (max-width: 480px) {
  #sarc-stats-panel {
    top: auto !important;
    right: auto !important;
    bottom: 20px !important;
    left: 16px !important;
  }
  #sarc-stats-panel.minimized {
    top: auto !important;
    right: auto !important;
    bottom: 20px !important;
    left: 16px !important;
  }
}
.stats-toggle-btn{
  font-size:16px !important;padding:8px !important;border-radius:6px !important;background:transparent !important;
  border:none !important;color:#faf60c !important;cursor:pointer !important;display:flex !important;
  align-items:center !important;justify-content:center !important;width:24px !important;height:24px !important;
  margin-left:auto !important;line-height:1 !important;transition:all 0.2s !important;
  -webkit-appearance:none !important;appearance:none !important;
}
.stats-toggle-btn:hover{background:rgba(255,255,255,0.2) !important;}
#sarc-consent-banner {
  position: fixed !important;
  bottom: 65px !important;
  left: 60% !important;
  z-index: 2501 !important;
  background: rgb(159 236 220 / 90%) !important;
  backdrop-filter: blur(10px) !important;
  border-radius: 16px !important;
  padding: 20px !important;
  align-items: center;
  transform: translateX(-50%) !important;
  text-align: center !important;
}

/* Refact CSS inline */
.stats-header{display:flex;justify-content:space-between;align-items:center;margin:5px 0 6px 0;min-height:32px;}
.stats-title{font-size:16px;line-height:1.2;}
.stats-grid{display:grid;grid-template-columns:1fr 1fr;gap:5px 30px;font-size:13px;padding:0 6px 0 2px;}
.stat-value{float:right;font-weight:600;}
.stats-mini{display:none;}
.mini-value{font-weight:600;font-size:12px;}

.label-views{color:#e8bdba;}.label-chats{color:#47efd9;}.label-vision{color:#f5c9f9;}
.label-search{color:#adf8f5;}.label-tools{color:#f6dfec;}.label-location{color:#d4f4e3;}
.mini-views{color:#ffffff;}.mini-chats{color:#ffffff;}.mini-vision{color:#ffffff;}
.mini-search{color:#ffffff;}.mini-tools{color:#ffffff;}

@media (max-width: 768px) {
  #mobile-stats-btn {
	margin-top: 0;  
    display: flex !important;
    position: fixed !important;
    bottom: 34px !important;
    left: 17px !important;
    width: 48px !important;      /* Lebih kecil */
    height: 48px !important;     /* Lebih kecil */
    border-radius: 50% !important;
    background: linear-gradient(157deg, #3a60a8, #31c0a9) !important;
    border: 2px solid rgba(255,255,255,0.3) !important;  /* Glow ring */
    color: white !important;
    font-size: 24px !important;  /* Ikon lebih kecil */
    cursor: pointer !important;
    z-index: 2502 !important;
    box-shadow: 0 8px 24px rgba(58,96,168,0.5) !important;
    transition: all 0.3s ease !important;
    align-items: center !important;
    justify-content: center !important;  /* PERFECT TENGAH */
    line-height: 0 !important;           /* No line-height shift */
    text-align: center !important;
  }
  
  #sarc-stats-panel:not(.minimized) {
  margin-top:0;position:fixed !important;bottom:84px !important;left:15px !important;z-index:2502 !important;
  background:linear-gradient(57deg, #3a60a8, #31c0a9) !important;color:white !important;
  border-radius:15px !important;box-shadow:0 10px 40px rgba(0,102,204,0.5) !important;
  font-family:system-ui !important;font-size:14px !important;transition:all 0.2s !important;
  min-width:180px !important;padding:0 12px 12px !important;
  }
  /* Panel hidden default 
  #sarc-stats-panel {
    display: none !important;
  } */
  
  /* Hide panel minimized di mobile */
  #sarc-stats-panel.minimized {
    transform: scale(0) !important;
    opacity: 0 !important;
  }

  #mobile-stats-btn:hover,
  #mobile-stats-btn:active {
    transform: scale(1.08) !important;   
    box-shadow: 0 12px 32px rgba(58,96,168,0.7) !important;
    border-color: rgba(255,255,255,0.6) !important;
  }
}
@media (min-width: 769px) {
#mobile-stats-btn { display: none !important; }
}
