:root {
  --neon-purple: #bc13fe;
  --neon-green: #39ff14;
  --primary-dark: #0f172a;
  --secondary-dark: #1e293b;
  --surface-bg: #ffffff;
  --surface-muted: #f9fafb;
  --border-subtle: rgba(148, 163, 184, 0.35);
}

#chat-app {
  max-width: 1380px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
  color: var(--primary-dark);
}

.glass-card {
  background: var(--surface-bg);
  border-radius: 1.5rem;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
}

.teacher-selector {
  padding: 1.25rem 1.75rem;
  margin-bottom: 1.5rem;
}

.teacher-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.1rem;
}

.teacher-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 0.9rem;
  row-gap: 0.1rem;
  padding: 0.85rem 1.35rem;
  border-radius: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  background: linear-gradient(180deg, #fdfefe 0%, #f4f6fb 100%);
  border: 1px solid rgba(148, 163, 184, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.teacher-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.12);
}

.teacher-card.active {
  border-width: 2px;
  border-color: #9ae6b4;
  box-shadow: 0 12px 30px rgba(47, 133, 90, 0.25);
  background: linear-gradient(180deg, #f8fff9 0%, #ecfdf3 100%);
}

.teacher-avatar {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  object-fit: cover;
  border: 2px solid #e5e7eb;
  background: #ffffff;
}

.teacher-info h4 {
  margin: 0;
  color: var(--primary-dark);
}

.teacher-info p {
  margin: 0;
  color: #64748b;
  font-size: 0.8rem;
}

.teacher-accent {
  margin: 0;
  margin-bottom: 0.2rem;
  font-size: 0.8rem;
  color: #6b7280;
}

.teacher-status {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
}

.teacher-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #a0aec0;
}

.teacher-status-dot.online {
  background: #16a34a;
}

.teacher-status-label {
  color: #6b7280;
}

.teacher-status-label.online {
  color: #16a34a;
}

.teacher-status-label.offline {
  color: #94a3b8;
}

.teacher-radio {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 2px solid #d1d5db;
  display: grid;
  place-items: center;
  background: #ffffff;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.teacher-radio::after {
  content: "";
  width: 0;
  height: 0;
  border-radius: 999px;
  background: #16a34a;
  transition: width 0.16s ease, height 0.16s ease;
}

.teacher-card.active .teacher-radio {
  border-color: #16a34a;
  background: #ecfdf3;
}

.teacher-card.active .teacher-radio::after {
  width: 10px;
  height: 10px;
}

.conversation-switcher {
  margin-bottom: 1.5rem;
}

.conversation-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.btn-new-chat,
.btn-history {
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-muted);
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-new-chat:hover,
.btn-history:hover {
  background: rgba(188, 19, 254, 0.15);
}

.btn-new-chat {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

.btn-new-chat:hover {
  background: #111827;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.conversation-card {
  padding: 2rem;
  margin-bottom: 1.5rem;
}

#chat-history {
  max-height: 60vh;
  min-height: 40vh;
  overflow-y: auto;
  padding-right: 1rem;
}

.message {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.message-user {
  flex-direction: row-reverse;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
}

.bubble {
  padding: 1rem 1.5rem;
  border-radius: 1.5rem;
  max-width: 70%;
}

.message-user .bubble {
  background: var(--neon-purple);
  color: white;
  border-bottom-right-radius: 0.5rem;
}

.message-assistant .bubble {
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
  color: var(--primary-dark);
  border-bottom-left-radius: 0.5rem;
}

.input-panel {
  padding: 1.5rem;
}

.history-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1.5rem;
}

.history-overlay.active {
  display: flex;
}

.history-panel {
  width: min(420px, 100%);
  max-height: 90vh;
  overflow: hidden;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.history-eyebrow {
  margin: 0;
  font-size: 0.8rem;
  color: #6b7280;
  letter-spacing: 0.02em;
}

.history-title {
  margin: 0.1rem 0 0;
  font-size: 1.1rem;
  color: var(--primary-dark);
}

.history-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #0f172a;
}

.history-list {
  border: 1px solid var(--border-subtle);
  border-radius: 1rem;
  background: var(--surface-muted);
  padding: 0.5rem;
  max-height: 60vh;
  overflow-y: auto;
}

.history-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  border-radius: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  color: var(--primary-dark);
  transition: background 0.15s ease, transform 0.15s ease;
}

.history-item:hover {
  background: #f1f5f9;
  transform: translateX(2px);
}

.history-item-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.history-item-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-item-title {
  margin: 0;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary-dark);
}

.history-item-preview {
  margin: 0.15rem 0 0;
  color: #64748b;
  font-size: 0.85rem;
}

.history-item-date {
  font-size: 0.8rem;
  color: #475569;
}

.history-empty {
  padding: 1rem;
  text-align: center;
  color: #6b7280;
}

.history-new-chat {
  display: block;
  text-align: center;
  padding: 0.85rem;
  border-radius: 0.9rem;
  background: #eef2ff;
  color: #4338ca;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid #e0e7ff;
}

.history-new-chat:hover {
  background: #e0e7ff;
}

.history-overlay.hidden {
  display: none !important;
}

.input-area textarea {
  width: 100%;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--border-subtle);
  background: var(--surface-muted);
  color: var(--primary-dark) !important;
  resize: none;
}

.input-area textarea:focus {
  outline: 2px solid var(--neon-purple);
}

.input-area {
  position: relative;
}

.voice-bar {
  display: none;
  margin-top: 0.5rem;
  border-radius: 1.5rem;
  background: linear-gradient(90deg, #3b82f6 0%, #4338ca 100%);
  padding: 0.8rem 1.1rem;
  color: #ffffff;
}

.input-area.recording .voice-bar {
  display: block;
}

.voice-bar-inner {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: #fff;
}

.voice-bar-label {
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0.9;
}

.voice-waveform {
  flex: 1;
  height: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
  position: relative;
  overflow: hidden;
}

.voice-waveform::after {
  content: "";
  position: absolute;
  left: -40px;
  top: -3px;
  width: 40px;
  height: 8px;
  background: repeating-linear-gradient(
    to right,
    #ffffff,
    #ffffff 2px,
    rgba(255, 255, 255, 0) 2px,
    rgba(255, 255, 255, 0) 4px
  );
}

.voice-waveform.active::after {
  animation: voice-wave 1.2s linear infinite;
}

@keyframes recordingPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.voice-timer {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
}

.voice-status-text {
  font-size: 0.8rem;
  opacity: 0.85;
}

@keyframes voice-wave {
  to {
    transform: translateX(160px);
  }
}

.input-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.btn-send {
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  border: none;
  background: var(--neon-purple);
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-send:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(188, 19, 254, 0.3);
}

.btn-record {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: var(--neon-green);
  color: var(--primary-dark);
  cursor: pointer;
   box-shadow: 0 6px 18px rgba(34, 197, 94, 0.4);
   transition: all 0.2s ease;
}

.btn-record.recording {
  background: #ef4444;
  color: #ffffff;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
  animation: recordingPulse 1.4s infinite;
}

.btn-upload {
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-muted);
  color: var(--primary-dark);
  cursor: pointer;
}

.btn-clear {
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: #64748b;
  cursor: pointer;
}

.btn-clear:hover,
.btn-upload:hover {
  background: #e5e7eb;
}

.audio-pill {
  background: var(--surface-muted);
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  color: var(--primary-dark);
  font-size: 0.85rem;
}

.prompt-btn {
  background: var(--surface-muted);
  border: 1px solid transparent;
  color: #475569;
  font-size: 0.9rem;
  white-space: nowrap;
}

.prompt-btn:hover {
  border-color: var(--neon-purple);
  background: #f3e8ff;
  color: var(--primary-dark);
}

.message-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.chip {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
  color: #475569;
  font-size: 0.8rem;
  cursor: pointer;
}

.chip:hover {
  background: #e5e7eb;
}

@media (max-width: 768px) {
  .teacher-options {
    flex-direction: column;
  }

  .bubble {
    max-width: 85%;
  }

  .input-actions {
    flex-wrap: wrap;
  }
}
