#tf-chat {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  color: #1d2440;
  font-size: 16px;
}
#tf-chat * { box-sizing: border-box; }
#tf-chat button, #tf-chat textarea { font: inherit; }

.tf-launcher {
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: #3b6ef6;
  color: white;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 20px rgba(59, 110, 246, .28);
  position: relative;
}
.tf-launcher:hover { background: #2f5fe0; }
.tf-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: #c4375a;
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.tf-badge[hidden] { display: none; }

.tf-panel {
  position: absolute;
  right: 0;
  bottom: 64px;
  width: min(360px, calc(100vw - 24px));
  height: min(560px, calc(100vh - 96px));
  display: flex;
  flex-direction: column;
  background: #f5f7fb;
  border: 1px solid #e4e8f2;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(29, 36, 64, .16);
}
.tf-panel[hidden] { display: none; }
#tf-chat.open .tf-panel { animation: tf-in .16s ease; }
@keyframes tf-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.tf-bar {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 14px;
  background: #3b6ef6;
  color: white;
}
.tf-title { font-family: Poppins, "Source Sans 3", sans-serif; font-weight: 650; font-size: 16px; }
.tf-bar button {
  height: 30px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.12);
  color: white;
  padding: 0 10px;
  font-weight: 650;
}
.tf-bar button:hover { background: rgba(255,255,255,.22); }
.tf-bar .tf-x { width: 30px; padding: 0; }

.tf-nav {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  background: white;
  border-bottom: 1px solid #e4e8f2;
}
.tf-nav:empty { display: none; }
.tf-nav button {
  height: 32px;
  border-radius: 10px;
  border: 1px solid #e4e8f2;
  background: white;
  color: #3a4670;
  padding: 0 12px;
  font-weight: 650;
}
.tf-nav button.on { background: #eceefe; color: #3a4ec4; border-color: #d5dbff; }

.tf-body { flex: 1; overflow: auto; padding: 12px; }
.tf-empty { margin: 8px 4px; color: #7b849c; }

.tf-row {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  background: white;
  border: 1px solid #d9dfef;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  color: #1d2440;
  font-weight: 650;
}
.tf-row:hover { border-color: #9aa8ee; }
.tf-row span, .tf-note { color: #7b849c; font-weight: 500; font-size: 14px; }
.tf-label { margin: 4px 2px 8px; color: #7b849c; font-size: 13px; font-weight: 650; }

.tf-msg { max-width: 88%; margin-bottom: 8px; }
.tf-msg small { display: block; color: #7b849c; font-size: 12px; margin-bottom: 2px; }
.tf-msg p {
  margin: 0;
  padding: 8px 10px;
  border-radius: 12px;
  background: white;
  border: 1px solid #e4e8f2;
  white-space: pre-wrap;
}
.tf-msg.student, .tf-msg.staff { margin-left: auto; }
.tf-msg.student p { background: #3b6ef6; color: white; border-color: transparent; }
.tf-msg.staff p { background: #243056; color: white; border-color: transparent; }
.tf-msg.note p { background: #fff8ea; }
.tf-card {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  background: white;
  border: 1px solid #e4e8f2;
  color: #1d2440;
}
.tf-card strong, .tf-card p { display: block; margin: 0; }
.tf-card p { margin-top: 4px; white-space: pre-wrap; font-weight: 500; }
.tf-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tf-actions button, .tf-menu button {
  height: 30px;
  border-radius: 10px;
  border: 1px solid #d5dbff;
  background: #eceefe;
  color: #3a4ec4;
  padding: 0 10px;
  font-weight: 650;
}
.tf-actions button.primary { background: #3b6ef6; color: white; border-color: transparent; }
.tf-banner, .tf-menu {
  background: white;
  border: 1px solid #e4e8f2;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.tf-banner strong { display: block; }
.tf-menu { display: flex; flex-wrap: wrap; gap: 6px; }

.tf-compose {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px;
  background: white;
  border-top: 1px solid #e4e8f2;
}
.tf-compose textarea {
  flex: 1;
  resize: none;
  min-height: 38px;
  max-height: 96px;
  border: 1px solid #e4e8f2;
  border-radius: 10px;
  padding: 8px 10px;
  background: white;
  color: #1d2440;
}
.tf-compose button, .tf-tools button {
  height: 36px;
  border-radius: 10px;
  border: 0;
  background: #3b6ef6;
  color: white;
  padding: 0 12px;
  font-weight: 650;
}
.tf-compose button:hover, .tf-tools button:hover { background: #2f5fe0; }
.tf-tools { display: flex; justify-content: flex-end; padding: 0 10px 8px; background: white; }
.tf-tools button { background: white; color: #3a4670; border: 1px solid #e4e8f2; }
.tf-tools[hidden], .tf-compose[hidden] { display: none; }

@media (max-width: 640px) {
  #tf-chat { right: 10px; bottom: 10px; }
  .tf-panel { height: min(70vh, 560px); }
}
@media (prefers-reduced-motion: reduce) {
  #tf-chat.open .tf-panel { animation: none; }
}
