@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800&display=swap");

:root {
  --blue: #5b83f1;
  --blue-dark: #254eb8;
  --blue-soft: #eaf0ff;
  --ink: #14213d;
  --muted: #6b7897;
  --line: #dbe4fa;
  --bg: #f7f9ff;
  --card: #ffffff;
  --ok: #0f9f6e;
  --danger: #d64545;
  --radius-sm: 14px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --shadow: 0 22px 70px rgba(32, 64, 160, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Montserrat, "Montserrat Alternates", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
}

h2 {
  font-size: 20px;
}

.student-pill {
  min-width: 120px;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--muted);
  text-align: center;
  word-break: break-word;
}

.login-panel,
.control-panel,
.conversation-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow);
}

.login-panel {
  padding: 28px;
}

.login-form label,
.level-setting label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.field + .field {
  margin-top: 14px;
}

.login-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 18px;
}

input,
select {
  min-width: 0;
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 16px;
  background: #fbfcff;
  color: var(--ink);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

select {
  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) 20px, calc(100% - 12px) 20px;
  background-repeat: no-repeat;
  background-size: 6px 6px, 6px 6px;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(91, 131, 241, 0.18);
}

.login-row button {
  height: 48px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0 22px;
  background: var(--blue);
  color: white;
  font-weight: 800;
  box-shadow: 0 10px 28px rgba(91, 131, 241, 0.25);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.login-row button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 34px rgba(91, 131, 241, 0.3);
}

.trainer {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
}

.control-panel {
  padding: 22px;
  align-self: start;
}

.level-setting {
  margin-bottom: 16px;
}

.end-session-button {
  width: 100%;
  min-height: 46px;
  margin-bottom: 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: #edf3ff;
  color: var(--blue-dark);
  font-weight: 800;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.end-session-button:hover {
  background: #dfe9ff;
  transform: translateY(-1px);
}

.end-session-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.speak-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  font-size: 28px;
  font-weight: 900;
  box-shadow: 0 20px 54px rgba(91, 131, 241, 0.34);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.speak-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 62px rgba(91, 131, 241, 0.4);
}

.speak-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.speak-button.recording {
  background: var(--danger);
}

.pulse {
  position: absolute;
  inset: 18px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  opacity: 0;
}

.speak-button.recording .pulse {
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.88);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.08);
    opacity: 0;
  }
}

.status {
  min-height: 54px;
  margin: 20px 0;
  color: var(--muted);
  line-height: 1.45;
}

.meter-group {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.meter-group + .meter-group {
  margin-top: 16px;
}

.meter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

.meter-row strong {
  color: var(--ink);
  white-space: nowrap;
}

.meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--blue-soft);
}

.meter div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 180ms ease;
}

.conversation-panel {
  min-height: 620px;
  padding: 22px;
}

.conversation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.conversation-header span {
  color: var(--muted);
  font-size: 14px;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 560px;
  overflow: auto;
  padding-top: 18px;
}

.message {
  width: min(82%, 680px);
  border: 0;
  border-radius: var(--radius-md);
  padding: 15px 17px;
  background: #eef4ff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.message.student {
  align-self: flex-end;
  background: var(--blue);
  color: white;
  border-bottom-right-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.message.assistant {
  align-self: flex-start;
  background: #edf3ff;
  color: var(--ink);
  border-bottom-left-radius: 8px;
}

.message.pending {
  color: var(--muted);
}

.message-label {
  margin-bottom: 5px;
  color: rgba(37, 78, 184, 0.78);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.message.student .message-label {
  color: rgba(255, 255, 255, 0.76);
}

.message.student.pending {
  color: rgba(255, 255, 255, 0.82);
}

.message-text {
  font-family: Montserrat, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  font-weight: 300;
  line-height: 1.5;
  white-space: pre-wrap;
}

.message.student .message-text {
  font-weight: 400;
}

.hidden {
  display: none;
}

@media (max-width: 780px) {
  .shell {
    width: min(100vw - 20px, 640px);
    padding: 18px 0;
  }

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

  .student-pill {
    width: 100%;
    text-align: left;
  }

  .login-row,
  .trainer {
    grid-template-columns: 1fr;
  }

  .speak-button {
    width: min(260px, 100%);
    margin: 0 auto;
  }

  .conversation-panel {
    min-height: 420px;
  }

  .messages {
    max-height: 500px;
  }

  .message {
    width: 100%;
  }
}
