:root {
  --hku-blue: #003366;
  --hku-gold: #996633;
  --bg-light: #f4f7f9;
  --text-dark: #333;
  --border-color: #e0e0e0;
}

body {
  font-family: "Roboto", sans-serif;
  background-color: var(--bg-light);
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  padding: 24px;
}

#chat-container {
  width: min(980px, 96vw);
  height: min(900px, 92vh);
  background: white;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  border-top: 6px solid var(--hku-blue);
}

@media (min-width: 1200px) {
  #chat-container {
    width: min(1100px, 94vw);
    height: min(940px, 90vh);
  }
}

header {
  background: white;
  padding: 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  gap: 15px;
}

header img {
  height: 45px;
  margin-right: 0;
  flex-shrink: 0;
}

header .title {
  flex: 1;
  text-align: right;
  min-width: 0;
}

@media (max-width: 480px) {
  header {
    padding: 14px 14px;
    flex-wrap: wrap;
    gap: 10px;
  }

  header img {
    height: 34px;
  }

  header h1 {
    font-size: 16px;
    letter-spacing: 0.5px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  header .title {
    flex: 1 1 100%;
    text-align: right;
  }
}

header h1 {
  font-size: 18px;
  margin: 0;
  color: var(--hku-blue);
  text-transform: uppercase;
  letter-spacing: 1px;
}

header p {
  font-size: 12px;
  margin: 0;
  color: #777;
}

#chat-window {
  flex: 1;
  padding: 25px;
  overflow-y: auto;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.msg {
  max-width: 90%;
  padding: 15px 20px;
  font-size: 14px;
  line-height: 1.6;
  border-radius: 18px;
}

.msg.bot {
  align-self: flex-start;
  background: #f8f9fa;
  border: 1px solid var(--border-color);
  color: var(--text-dark);
  border-bottom-left-radius: 4px;
}

.msg.user {
  align-self: flex-end;
  background: var(--hku-blue);
  color: white;
  border-bottom-right-radius: 4px;
}

/* --- BEAUTIFUL MARKDOWN STYLING --- */
.msg h2,
.msg h3 {
  margin-top: 10px;
  margin-bottom: 5px;
  color: var(--hku-blue);
}

.msg p {
  margin: 8px 0;
}

.msg ul,
.msg ol {
  padding-left: 20px;
}

/* Table Styling */
.msg table {
  border-collapse: collapse;
  width: 100%;
  margin: 15px 0;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  font-size: 13px;
}

.msg th {
  background: var(--hku-blue);
  color: white;
  padding: 10px;
  text-align: left;
}

.msg td {
  border: 1px solid var(--border-color);
  padding: 8px;
  color: #555;
}

.msg tr:nth-child(even) {
  background-color: #f2f2f2;
}

.msg img {
  max-width: 100%;
  border-radius: 8px;
  margin: 10px 0;
  border: 1px solid #ddd;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.msg a {
  color: var(--hku-gold);
  font-weight: bold;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.msg a:hover {
  border-bottom: 1px solid var(--hku-gold);
}

/* Input Area */
#input-area {
  padding: 20px;
  background: white;
  border-top: 1px solid #eee;
  display: flex;
  gap: 12px;
}

#chatInput {
  flex: 1;
  border: 1px solid #ddd;
  padding: 12px 15px;
  border-radius: 6px;
  outline: none;
  font-size: 14px;
}

#sendBtn {
  background: var(--hku-blue);
  color: white;
  border: none;
  padding: 0 25px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
}

#sendBtn:hover {
  background: #002244;
}

.typing {
  font-style: italic;
  font-size: 12px;
  color: #aaa;
  margin: 0 0 10px 25px;
  display: none;
}
