@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --accent: #ef4444;
  --accent-dark: #dc2626;
  --accent-soft: #fef2f2;
  --accent-border: #fecaca;
  font-family: 'Plus Jakarta Sans', sans-serif;
  color: #172033;
  background: #f4f6fb;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
}

button, input { font: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 0 max(24px, calc((100vw - 1200px) / 2));
  background: #fff;
  border-bottom: 1px solid #e6eaf2;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 11px;
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  color: var(--accent-dark);
  font-size: .8rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: background .2s, color .2s, border-color .2s;
}

.back-link:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.brand {
  color: #172033;
  font-size: 1.15rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 18px;
  color: #6b7891;
  font-size: .82rem;
}

.topbar nav a { color: inherit; text-decoration: none; }
.topbar nav a:hover { color: var(--accent-dark); }

.topbar button, .composer button {
  border: 0;
  border-radius: 10px;
  padding: 10px 15px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.topbar button:disabled, .composer button:disabled {
  cursor: wait;
  opacity: .6;
}

.topbar button:hover:not(:disabled), .composer button:hover:not(:disabled),
.enrollment-prompt button:hover:not(:disabled) { background: var(--accent-dark); }

.page {
  width: min(1200px, calc(100% - 40px));
  margin: 0 auto;
  padding: 42px 0 64px;
}

.page-heading { margin-bottom: 26px; }
.eyebrow { color: var(--accent-dark); font-size: .68rem; font-weight: 800; letter-spacing: .12em; }
.page-heading h1 { margin: 8px 0; font-size: clamp(1.8rem, 4vw, 2.5rem); }
.page-heading > p:last-child { margin: 0; color: #6b7891; }

.page-status {
  min-height: 24px;
  margin: 0 0 12px;
  color: #6b7891;
  font-size: .85rem;
}

.page-status.error, .chat-status.error, .enrollment-prompt p.error { color: #bd3131; }

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  min-height: 590px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e3e8f1;
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(34, 52, 94, .08);
}

.sidebar {
  padding: 22px 18px;
  border-right: 1px solid #e8ecf3;
  background: #fbfcfe;
}

.sidebar section + section { margin-top: 28px; }
.sidebar h2 { margin: 0 0 12px; font-size: .9rem; }
.list { display: grid; gap: 6px; }

.list-item {
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #25314a;
  text-align: left;
  cursor: pointer;
}

.list-item:hover, .list-item.active {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.list-item-title { display: block; font-size: .82rem; font-weight: 700; }
.list-item-preview {
  display: block;
  margin-top: 4px;
  color: #7a869c;
  font-size: .73rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-status { margin: 8px 2px; color: #8490a5; font-size: .75rem; }

.conversation { min-width: 0; display: flex; flex-direction: column; }
.empty-chat {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 420px;
  padding: 28px;
  text-align: center;
}

.chat-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 1.5rem;
}

.empty-chat h2 { margin: 18px 0 6px; font-size: 1.05rem; }
.empty-chat p { margin: 0; color: #7a869c; font-size: .84rem; }
.enrollment-prompt { margin-top: 18px; }
.enrollment-prompt p { margin: 0 0 12px; }
.enrollment-prompt button {
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.enrollment-prompt button:disabled { cursor: wait; opacity: .6; }
.enrollment-prompt button[hidden] { display: none; }
.chat-window { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.conversation-header { padding: 20px 24px; border-bottom: 1px solid #e8ecf3; }
.conversation-header h2 { margin: 0; font-size: 1rem; }
.chat-status { min-height: 30px; margin: 0; padding: 8px 24px 0; color: #7a869c; font-size: .75rem; }

.messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-height: 340px;
  max-height: 60vh;
  padding: 16px 24px;
  overflow-y: auto;
}

.message {
  align-self: flex-start;
  max-width: min(80%, 520px);
  padding: 10px 13px;
  border-radius: 14px 14px 14px 4px;
  background: #f0f3f8;
  font-size: .84rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.message.mine {
  align-self: flex-end;
  border-radius: 14px 14px 4px 14px;
  background: #fee2e2;
}

.message time { display: block; margin-top: 5px; color: #8792a6; font-size: .63rem; }

.composer {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid #e8ecf3;
}

.composer input {
  flex: 1;
  min-width: 0;
  border: 1px solid #dfe5ef;
  border-radius: 10px;
  padding: 11px 13px;
  outline: none;
}

.composer input:focus { border-color: var(--accent); }

[hidden] { display: none !important; }

@media (max-width: 760px) {
  .topbar { padding: 0 16px; }
  .topbar nav { gap: 10px; }
  #authIdentity { display: none; }
  .page { width: min(100% - 24px, 600px); padding-top: 28px; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid #e8ecf3; }
  .sidebar section + section { margin-top: 18px; }
  .messages { min-height: 280px; }
}

@media (max-width: 420px) {
  .topbar-brand { gap: 8px; }
  .back-link { padding: 8px; }
  .back-link span { display: none; }
  .brand { font-size: 1rem; }
  .topbar nav { gap: 8px; }
  .topbar button { padding: 9px 10px; font-size: .72rem; }
}
