:root {
  --bg: #f7f7f8;
  --ink: #161616;
  --muted: #6b6d72;
  --surface: #ffffff;
  --surface-soft: #f1f2f4;
  --line: #e5e7eb;
  --primary: #111827;
  --primary-soft: #eef2ff;
  --student: #f3f4f6;
  --teacher: #ffffff;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button,
textarea {
  font: inherit;
}

.page-shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
}

h1,
h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
}

h1 {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  line-height: 1.05;
}

.ghost-button,
.send-button,
.mic-button,
.topic-chip,
.voice-select {
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
  cursor: pointer;
}

.ghost-button {
  padding: 10px 14px;
  background: var(--surface);
  color: var(--ink);
}

.voice-picker {
  display: flex;
}

.voice-select {
  min-height: 42px;
  max-width: 220px;
  padding: 0 38px 0 14px;
  background: var(--surface);
  color: var(--ink);
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 18px,
    calc(100% - 12px) 18px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.voice-select:focus {
  outline: none;
  border-color: #c7cbd4;
}

.ghost-button:hover,
.send-button:hover,
.mic-button:hover,
.topic-chip:hover {
  background: var(--surface-soft);
}

.intro {
  margin-bottom: 16px;
}

.intro-text {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.6;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.status-pill {
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.panel-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--muted);
}

.chat-shell {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 78vh;
  padding: 18px;
}

.chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding: 8px 4px 18px;
}

.message-row {
  display: flex;
}

.message-row.student {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: min(88%, 720px);
  border-radius: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  animation: rise 180ms ease;
}

.chat-bubble p,
.chat-bubble ul {
  margin: 0;
}

.chat-bubble.student {
  background: var(--student);
}

.chat-bubble.teacher {
  background: var(--teacher);
}

.message-meta {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

#chatInput {
  width: 100%;
  min-height: 54px;
  max-height: 180px;
  resize: vertical;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

#chatInput:focus {
  border-color: #c7cbd4;
}

.composer-actions {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.mic-button,
.send-button {
  min-height: 54px;
  padding: 0 18px;
  font-weight: 700;
}

.mic-button {
  background: var(--surface);
  color: var(--ink);
}

.mic-button.is-listening {
  background: var(--primary-soft);
  color: var(--primary);
}

.send-button {
  min-width: 88px;
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.topic-chip {
  padding: 10px 14px;
  background: var(--surface);
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 920px) {
  .chat-panel {
    min-height: auto;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 100%);
    padding-top: 20px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .voice-select {
    max-width: 100%;
    width: 100%;
  }

  .composer-actions {
    width: 100%;
    justify-content: space-between;
  }

  .chat-bubble {
    max-width: 100%;
  }

  .composer {
    grid-template-columns: 1fr;
  }
}
