:root {
  --blue: #003366;
  --gold: #FFB81C;
  --grey-light: #f4f4f4;
  --grey-mid: #e0e0e0;
  --text: #1a1a1a;
  --text-light: #555;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--grey-light); color: var(--text); }

/* ── Login Page ── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

.login-container {
  background: white;
  border-radius: 12px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
  text-align: center;
}

.mtu-logo {
  width: 64px; height: 64px;
  background: var(--blue);
  color: var(--gold);
  border-radius: 12px;
  font-size: 32px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}

.login-container h1 { font-size: 1.5rem; color: var(--blue); margin-bottom: 6px; }
.subtitle { color: var(--text-light); font-size: 0.9rem; margin-bottom: 32px; }

.login-form label { display: block; text-align: left; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; color: var(--text-light); }

.login-form input[type="password"] {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--grey-mid);
  border-radius: 8px; font-size: 1rem;
  margin-bottom: 16px; outline: none;
  transition: border-color 0.2s;
}
.login-form input[type="password"]:focus { border-color: var(--blue); }

.login-form button {
  width: 100%; padding: 13px;
  background: var(--blue); color: white;
  border: none; border-radius: 8px;
  font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: background 0.2s;
}
.login-form button:hover { background: #004080; }

.error { color: #c0392b; font-size: 0.85rem; margin-top: 12px; }

/* ── Chat Page ── */
.chat-page { height: 100vh; display: flex; flex-direction: column; }

.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: 260px; min-width: 260px;
  background: var(--blue); color: white;
  display: flex; flex-direction: column;
  overflow-y: auto; padding: 0 0 16px;
}

.sidebar-header {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.15);
  font-weight: 700; font-size: 0.95rem;
}

.mtu-logo-sm {
  width: 32px; height: 32px;
  background: var(--gold); color: var(--blue);
  border-radius: 6px; font-weight: 800; font-size: 16px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.scope-note {
  font-size: 0.78rem; color: rgba(255,255,255,0.65);
  padding: 10px 16px 4px; font-style: italic;
}

.starters { padding: 8px 0; }
.starters h4 { padding: 8px 16px 4px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(255,255,255,0.5); }

.starter-group { margin-bottom: 4px; }
.group-label { padding: 6px 16px 2px; font-size: 0.72rem; font-weight: 700; color: var(--gold); text-transform: uppercase; letter-spacing: 0.05em; }

.starter-btn {
  display: block; width: 100%; text-align: left;
  padding: 7px 16px; background: none; border: none;
  color: rgba(255,255,255,0.85); font-size: 0.82rem;
  cursor: pointer; transition: background 0.15s;
}
.starter-btn:hover { background: rgba(255,255,255,0.1); color: white; }

/* Chat main */
.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: white; border-bottom: 1px solid var(--grey-mid);
  font-weight: 600; color: var(--blue);
}

.model-badge { font-size: 0.75rem; font-weight: 400; color: var(--text-light); background: var(--grey-light); padding: 3px 10px; border-radius: 20px; }

.messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }

.message { display: flex; flex-direction: column; max-width: 78%; }
.message.student { align-self: flex-end; align-items: flex-end; }
.message.assistant { align-self: flex-start; align-items: flex-start; }

.bubble {
  padding: 12px 16px; border-radius: 16px; font-size: 0.92rem; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
.message.student .bubble { background: var(--gold); color: var(--blue); border-bottom-right-radius: 4px; }
.message.assistant .bubble { background: white; border: 1px solid var(--grey-mid); border-bottom-left-radius: 4px; }

.sources { font-size: 0.75rem; color: var(--text-light); margin-top: 4px; padding: 0 4px; }
.sources a { color: var(--blue); text-decoration: none; }
.sources a:hover { text-decoration: underline; }

.typing { letter-spacing: 4px; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity:0.3 } 50% { opacity:1 } }

.input-area {
  display: flex; gap: 10px; padding: 16px 24px;
  background: white; border-top: 1px solid var(--grey-mid);
}

#query {
  flex: 1; padding: 10px 14px;
  border: 1.5px solid var(--grey-mid); border-radius: 8px;
  font-size: 0.95rem; resize: none; outline: none;
  font-family: inherit; transition: border-color 0.2s;
}
#query:focus { border-color: var(--blue); }

#send-btn {
  padding: 10px 22px;
  background: var(--blue); color: white;
  border: none; border-radius: 8px;
  font-size: 0.92rem; font-weight: 600;
  cursor: pointer; transition: background 0.2s;
}
#send-btn:hover { background: #004080; }
#send-btn:disabled { background: var(--grey-mid); cursor: not-allowed; }

/* Mobile */
@media (max-width: 640px) {
  .sidebar { display: none; }
  .chat-header { padding: 12px 16px; }
  .messages { padding: 16px; }
  .input-area { padding: 12px 16px; }
  .message { max-width: 92%; }
}
