:root {
  --bg: #0f1117;
  --bg-2: #161922;
  --card: #1c2030;
  --card-2: #232839;
  --border: #2a2f44;
  --text: #e8ebf1;
  --muted: #9aa1b5;
  --accent: #7c5cff;
  --accent-2: #5b8cff;
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #ef4444;
  --bubble-user: linear-gradient(135deg, #7c5cff 0%, #5b8cff 100%);
  --bubble-bot: #232839;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Roboto",
    "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--accent); }
code { background: var(--bg-2); padding: 1px 6px; border-radius: 4px; font-size: 0.92em; }

/* === Layout === */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 26px; }
.brand-title { color: var(--text); font-weight: 700; font-size: 16px; }
.nav { display: flex; gap: 18px; flex: 1; margin-left: 16px; }
.nav a { color: var(--muted); font-size: 14px; padding: 6px 10px; border-radius: 8px; }
.nav a:hover { color: var(--text); background: var(--card); }
.user { display: flex; align-items: center; gap: 12px; }
.user-role { color: var(--muted); font-size: 13px; }
.user-name { font-weight: 600; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--card);
  color: var(--text);
  font-family: inherit;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--bubble-user); color: white; border-color: transparent; }
.btn-primary:hover { box-shadow: 0 4px 18px rgba(124, 92, 255, 0.35); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--card); }
.btn-danger { color: var(--danger); border-color: rgba(239, 68, 68, 0.3); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.1); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.logout-form { display: inline; margin: 0; }

/* === Hero === */
.hero { padding: 8px 0 24px; }
.hero h1 { font-size: 28px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.section-title { margin: 36px 0 14px; font-size: 18px; }

/* === Cards === */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 17px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* === Agents grid === */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}
.agent-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: all 0.18s ease;
  text-align: left;
}
.agent-card:hover {
  border-color: var(--accent);
  background: var(--card-2);
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(124, 92, 255, 0.18);
}
.agent-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin-bottom: 6px;
  background: var(--bg-2);
  flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; border-radius: 50%; vertical-align: middle; margin-right: 8px; flex-shrink: 0; }
.avatar-md { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.avatar-lg { width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0; }
.agent-icon { font-size: 32px; margin-bottom: 4px; }
.agent-title { font-weight: 600; font-size: 15px; margin-top: 4px; }
.agent-full-name { color: var(--text); font-size: 14px; font-weight: 500; margin-top: 2px; }
.agent-role { color: var(--muted); font-size: 12px; margin-top: 2px; }
.agent-subject {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--accent-2);
  background: rgba(91, 140, 255, 0.12);
  padding: 2px 8px;
  border-radius: 999px;
  align-self: flex-start;
}

.chat-side-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }

/* === Login === */
.login-wrap {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 880px;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
@media (max-width: 760px) { .login-card { grid-template-columns: 1fr; } }
.login-hero {
  padding: 36px 32px;
  background: linear-gradient(135deg, rgba(124,92,255,0.15) 0%, rgba(91,140,255,0.15) 100%);
  border-right: 1px solid var(--border);
}
.login-hero h1 { margin: 16px 0 4px; font-size: 28px; }
.login-emoji { font-size: 56px; }
.login-sub { color: var(--muted); margin: 0 0 18px; }
.login-desc { color: var(--text); font-size: 14px; }
.login-staff {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.login-staff span {
  background: rgba(255,255,255,0.05);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid var(--border);
}
.login-form { padding: 36px 32px; display: flex; flex-direction: column; gap: 14px; }
.login-form h2 { margin: 0 0 8px; font-size: 20px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-form input, .login-form select, .card input, .card select, .card textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
}
.login-form input:focus, .card input:focus, .card select:focus, .card textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.login-hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

/* === Chat === */
.chat-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  height: calc(100vh - 110px);
  min-height: 540px;
}
@media (max-width: 880px) {
  .chat-layout { grid-template-columns: 1fr; height: auto; }
}
.chat-sidebar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-y: auto;
}
.chat-side-head { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.big-emoji { font-size: 40px; }
.side-title { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 16px 0 8px; letter-spacing: 0.05em; }
.conv-list, .agents-mini { list-style: none; margin: 0; padding: 0; }
.conv-list a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  margin-bottom: 2px;
}
.conv-list a:hover, .conv-list a.active { background: var(--card-2); }
.conv-title { display: block; font-size: 14px; }
.conv-time { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.agents-mini a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; font-size: 13px; color: var(--text); border-radius: 8px; }
.agents-mini a:hover { background: var(--card-2); }
.agents-mini .mini-name { font-size: 13px; }
.agents-mini .mini-sub { font-size: 11px; margin-top: 1px; }
.empty { color: var(--muted); font-size: 13px; padding: 8px 10px; }
.empty { color: var(--muted); font-size: 13px; padding: 8px 10px; }

.chat-main {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-agent-title { font-weight: 600; font-size: 16px; }
.messages {
  flex: 1;
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg { display: flex; flex-direction: column; max-width: 78%; }
.msg-user { align-self: flex-end; }
.msg-assistant { align-self: flex-start; }
.msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 14px;
}
.msg-user .msg-bubble {
  background: var(--bubble-user);
  color: white;
  border-bottom-right-radius: 4px;
}
.msg-assistant .msg-bubble {
  background: var(--bubble-bot);
  color: var(--text);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}
.msg-meta { color: var(--muted); font-size: 11px; margin-top: 4px; padding: 0 6px; }
.msg-user .msg-meta { text-align: right; }

.chat-input {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
}
.chat-input textarea {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 44px;
  max-height: 160px;
}
.chat-input textarea:focus { outline: none; border-color: var(--accent); }

/* === Quick-ask === */
.quick-ask {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}
.quick-ask textarea {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
.quick-ask textarea:focus { outline: none; border-color: var(--accent); }
.quick-ask .btn { align-self: flex-end; }
.quick-ask-result {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.quick-ask-result.hidden { display: none; }
.chat-stream { white-space: pre-wrap; }
.loader {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}
.loader::before {
  content: "● ● ●";
  animation: pulse 1.4s ease-in-out infinite;
  letter-spacing: 0.4em;
}
@keyframes pulse { 50% { opacity: 0.3; } }
.error { color: var(--danger); }

/* === Schedule (calendar) === */
.schedule-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  padding: 12px 18px;
}
.schedule-current { text-align: center; flex: 1; }
.schedule-current b { font-size: 17px; }
.schedule-current .muted { display: block; font-size: 13px; margin-top: 2px; }

.schedule-grid {
  display: grid;
  grid-template-columns: 80px repeat(5, 1fr);
  gap: 6px;
  background: var(--bg-2);
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.schedule-corner { background: transparent; }
.schedule-day-head {
  background: var(--card);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
}
.schedule-day-head .day-name { font-weight: 600; font-size: 14px; }
.schedule-day-head .day-date { font-size: 12px; margin-top: 2px; }
.schedule-time {
  background: var(--card);
  border-radius: 8px;
  padding: 10px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.schedule-time .time { font-weight: 600; color: var(--accent-2); }
.schedule-cell {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  color: var(--text);
  text-decoration: none;
  transition: all 0.15s ease;
  min-height: 70px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.schedule-cell:hover {
  border-color: var(--accent);
  background: var(--card-2);
  transform: translateY(-1px);
}
.schedule-cell.empty { background: transparent; border: 1px dashed var(--border); opacity: 0.5; }
.cell-subject { font-weight: 600; font-size: 14px; }
.cell-topic { font-size: 12px; color: var(--text); margin-top: 4px; line-height: 1.3; }
.cell-meta { font-size: 10px; margin-top: 4px; }

@media (max-width: 880px) {
  .schedule-grid { grid-template-columns: 60px repeat(5, 1fr); gap: 4px; padding: 8px; }
  .schedule-cell { padding: 6px; min-height: 60px; }
  .cell-subject { font-size: 12px; }
  .cell-topic { font-size: 11px; }
}

/* === Grades === */
.table {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-collapse: collapse;
  overflow: hidden;
}
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: var(--bg-2); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.table tr:last-child td { border-bottom: none; }
.grade {
  display: inline-block;
  min-width: 28px;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
  text-align: center;
}
.grade-5 { background: rgba(74, 222, 128, 0.15); color: var(--success); }
.grade-4 { background: rgba(91, 140, 255, 0.15); color: var(--accent-2); }
.grade-3 { background: rgba(251, 191, 36, 0.15); color: var(--warning); }
.grade-2 { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.form-row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.form-row label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); flex: 1; min-width: 120px; }

/* === Homework === */
.hw-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.hw-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.hw-item.done { opacity: 0.55; }
.hw-item.done .hw-desc { text-decoration: line-through; }
.hw-check {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--accent-2);
  cursor: pointer;
  font-size: 16px;
}
.hw-check:hover { border-color: var(--accent); }
.hw-content { flex: 1; }
.hw-subject { color: var(--accent-2); font-size: 13px; font-weight: 600; }
.hw-desc { margin-top: 2px; }
.hw-due { color: var(--muted); font-size: 12px; margin-top: 4px; }
