* {
  box-sizing: border-box;
}

:root {
  --bg1: #0f172a;
  --bg2: #1e293b;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-border: rgba(255, 255, 255, 0.12);
  --input-bg: rgba(15, 23, 42, 0.8);
  --text: #ffffff;
  --muted: #cbd5e1;
  --teacher: #38bdf8;
  --student: #22c55e;
  --danger: #ef4444;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: linear-gradient(135deg, var(--bg1), var(--bg2));
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.app {
  width: 100%;
  max-width: 900px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
}

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

h1 {
  margin: 0 0 8px;
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

.badge {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(2, 6, 23, 0.6);
  color: #f8fafc;
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}

.teacher-panel {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
}

.field-group.grow {
  flex: 1;
}

label {
  font-size: 14px;
  color: var(--muted);
}

input,
select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 15px;
  background: var(--input-bg);
  color: white;
  outline: none;
}

input::placeholder {
  color: #94a3b8;
}

.controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

button {
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 16px;
  cursor: pointer;
  transition: 0.2s ease;
}

#runBtn {
  background: #22c55e;
  color: white;
}

#runBtn:hover {
  background: #16a34a;
}

#exampleBtn {
  background: #38bdf8;
  color: white;
}

#exampleBtn:hover {
  background: #0ea5e9;
}

#clearBtn {
  background: var(--danger);
  color: white;
}

#clearBtn:hover {
  background: #dc2626;
}

.output {
  background: #020617;
  border-radius: 12px;
  padding: 16px;
  min-height: 360px;
  max-height: 560px;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  padding: 14px;
  border-radius: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.message .name {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.message.teacher {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #e0f2fe;
  align-self: flex-start;
}

.message.student {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: #dcfce7;
  align-self: flex-end;
}

.message.system {
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #e2e8f0;
}

.typing {
  opacity: 0.9;
  font-style: italic;
}

@media (max-width: 700px) {
  .app {
    padding: 18px;
  }

  .header {
    flex-direction: column;
    align-items: stretch;
  }

  .badge {
    width: fit-content;
  }

  button {
    width: 100%;
  }
}
