* { 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; }
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; }
