* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0a0a0a; color: #eaeaea; height: 100vh; display: flex; flex-direction: column;
  overflow: hidden;
}
.hidden { display: none !important; }
img.logo { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }
header {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: #141414; border-bottom: 1px solid #262626; flex-shrink: 0;
}
header .title { flex: 1; min-width: 0; }
header h1 { margin: 0; font-size: 15px; }
header p { margin: 0; font-size: 11px; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 1px solid #333; flex-shrink: 0; }
button {
  background: #22c55e; color: #06210a; border: none; padding: 9px 14px; border-radius: 8px;
  font-weight: 600; cursor: pointer; font-size: 13px;
}
button.secondary { background: #262626; color: #ddd; }
button.danger { background: #7a2323; color: #fff; }
button:disabled { opacity: 0.5; }
input, select, textarea {
  background: #171717; border: 1px solid #333; color: #eaeaea; padding: 10px;
  border-radius: 8px; font-size: 14px; width: 100%;
}

#gate {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 20px; overflow-y: auto; text-align: center;
}
#gate img.big-logo { width: 100px; height: 100px; border-radius: 24px; margin-bottom: 10px; object-fit: cover; }
#gate h1 { margin: 4px 0; font-size: 18px; }
#gate .tag { color: #999; font-size: 12px; margin-bottom: 18px; }
#guestBtn { width: 100%; max-width: 340px; padding: 14px; font-size: 14px; margin-bottom: 16px; }
.divider { color: #666; font-size: 11px; margin-bottom: 14px; }
.tabs { display: flex; background: #171717; border-radius: 10px; padding: 4px; margin-bottom: 16px; width: 100%; max-width: 340px; }
.tabs button { flex: 1; background: transparent; color: #999; padding: 8px; }
.tabs button.active { background: #22c55e; color: #06210a; }
#authForm, #loginForm, #signupForm { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 8px; text-align: left; }
#courseCheckList { background: #171717; border: 1px solid #333; border-radius: 8px; padding: 8px; max-height: 220px; overflow-y: auto; }
#courseCheckList label { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 3px 0; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.footnote { font-size: 11px; color: #666; margin-top: 6px; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 999;
  background: #3a1414; border: 1px solid #7a2323; color: #fca5a5; font-size: 12px;
  padding: 12px 14px; border-radius: 10px; display: flex; justify-content: space-between; gap: 10px;
  max-width: 360px; margin: 0 auto; box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
#toast button { background: transparent; color: #fca5a5; padding: 0; font-size: 16px; }

#app { display: none; flex-direction: column; flex: 1; min-height: 0; }
#app.active { display: flex; }
#courseBar { padding: 8px 16px; background: #141414; border-bottom: 1px solid #262626; flex-shrink: 0; }
#messages { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: #e5e5e5; color: #111; }
.msg.bot { align-self: flex-start; background: #171717; border: 1px solid #262626; }
.msg.loading { color: #999; font-style: italic; }
#inputBar { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #262626; background: #141414; flex-shrink: 0; }
#chatInput { flex: 1; }
#sendBtn { width: 46px; flex-shrink: 0; }

#adminPanel { display: none; background: #141414; border-bottom: 1px solid #262626; padding: 14px; max-height: 320px; overflow-y: auto; flex-shrink: 0; }
#adminPanel.active { display: block; }
#materialList { list-style: none; padding: 0; margin: 8px 0 0; }
#materialList li { display: flex; justify-content: space-between; align-items: center; background: #1f1f1f; padding: 8px 12px; border-radius: 8px; margin-bottom: 6px; font-size: 13px; }

#adminGateModal {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  align-items: center; justify-content: center; z-index: 500; padding: 20px;
}
#adminGateModal.active { display: flex; }
#adminGateModal .box { background: #171717; border: 1px solid #333; border-radius: 16px; padding: 18px; width: 100%; max-width: 300px; }

/* SPLASH SCREEN */
#splash {
  position: fixed; inset: 0; background: #0a0a0a; z-index: 1000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  animation: fadeOutSplash 0.6s ease 1.8s forwards;
}
.splash-logo { width: 90px; height: 90px; border-radius: 22px; object-fit: cover; animation: pulseLogo 1.4s ease-in-out infinite; }
#splash h2 { margin: 6px 0 2px; font-size: 16px; letter-spacing: 1px; }
#splash p { margin: 0; font-size: 12px; color: #999; }
.splash-bar { width: 220px; height: 8px; background: #1a1a1a; border-radius: 6px; overflow: hidden; margin-top: 8px; border: 1px solid #262626; }
#splashFill { width: 0%; height: 100%; background: linear-gradient(90deg,#16a34a,#22c55e); transition: width 0.2s ease; }
.splash-status { color: #22c55e !important; font-weight: 600; }
@keyframes pulseLogo { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes fadeOutSplash { to { opacity: 0; visibility: hidden; pointer-events: none; } }

/* QUICK TOOLS */
.quick-tools { margin-bottom: 12px; }
button.small { padding: 6px 12px; font-size: 11px; }

/* GPA MODAL */
#gpaModal {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  align-items: center; justify-content: center; z-index: 600; padding: 20px;
}
#gpaModal.active { display: flex; }
.gpa-box { background: #171717; border: 1px solid #333; border-radius: 16px; padding: 18px; width: 100%; max-width: 360px; max-height: 80vh; overflow-y: auto; }
.gpa-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.gpa-row input { flex: 2; }
.gpa-row select { flex: 1; }
.gpa-row button { flex: 0 0 auto; padding: 6px 8px; background: #7a2323; color: #fff; }
.gpa-result { display: flex; justify-content: space-between; margin-top: 12px; padding-top: 10px; border-top: 1px solid #333; font-size: 13px; }
.gpa-result strong { color: #22c55e; }
