:root {
  --bg: #f4f7fb;
  --ink: #182033;
  --muted: #5d687a;
  --line: #d7deea;
  --panel: #ffffff;
  --accent: #1f8a70;
  --accent-strong: #166c58;
  --gold: #f3c24e;
  --rose: #ef8080;
  --warning: #e5a500;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.shell {
  width: min(1160px, calc(100% - 32px));
  margin: 24px auto;
}

.classroom {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
  align-items: stretch;
  min-height: 260px;
}

.avatar,
.lesson,
.panel,
.chat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.avatar {
  display: grid;
  align-items: center;
  justify-items: start;
  position: relative;
  padding: 24px;
}

.avatar-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  justify-items: end;
  gap: 10px;
  max-width: 156px;
  z-index: 2;
}

.face {
  position: relative;
  width: 156px;
  height: 156px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 34%, rgb(255 255 255 / 68%) 0 10%, transparent 11%),
    radial-gradient(circle at 50% 115%, #ffb66c 0 46%, transparent 47%),
    linear-gradient(145deg, #ffe07c 0%, #ffbc49 58%, #ff9d3f 100%);
  border: 5px solid #293145;
  box-shadow:
    inset 0 -10px 0 rgb(239 128 128 / 18%),
    0 14px 22px rgb(24 32 51 / 18%);
}

.face::before,
.face::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.face::before {
  left: 50%;
  top: 88px;
  width: 12px;
  height: 10px;
  border-radius: 50%;
  background: rgb(43 49 66 / 32%);
  transform: translateX(-50%);
}

.face::after {
  left: 20px;
  right: 20px;
  bottom: -13px;
  height: 18px;
  border-radius: 50%;
  background: rgb(24 32 51 / 14%);
  filter: blur(3px);
  z-index: -1;
}

.hair {
  position: absolute;
  left: 30px;
  top: -16px;
  width: 96px;
  height: 48px;
  border-radius: 52% 48% 58% 42%;
  background: #2b3142;
  transform: rotate(-5deg);
}

.hair::before,
.hair::after {
  content: "";
  position: absolute;
  background: #2b3142;
}

.hair::before {
  left: 18px;
  bottom: -14px;
  width: 34px;
  height: 34px;
  border-radius: 6px 24px 24px 24px;
  transform: rotate(34deg);
}

.hair::after {
  right: 15px;
  bottom: -12px;
  width: 38px;
  height: 34px;
  border-radius: 24px 6px 24px 24px;
  transform: rotate(-28deg);
}

.eye {
  position: absolute;
  top: 56px;
  width: 20px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff 0 18%, #2b3142 19% 100%);
  z-index: 1;
}

.eye:first-child {
  left: 45px;
}

.eye:nth-child(2) {
  right: 45px;
}

.mouth {
  position: absolute;
  left: 51px;
  bottom: 35px;
  width: 52px;
  height: 18px;
  border: 4px solid #2b3142;
  border-top-width: 2px;
  border-radius: 10px 10px 34px 34px;
  background: #7b2435;
  overflow: hidden;
  transform-origin: center top;
}

.mouth::after {
  content: "";
  position: absolute;
  left: 13px;
  bottom: -7px;
  width: 26px;
  height: 14px;
  border-radius: 50%;
  background: #ff7d91;
}

.cheek {
  position: absolute;
  top: 89px;
  width: 24px;
  height: 14px;
  border-radius: 50%;
  background: rgb(239 128 128 / 46%);
}

.cheek-left {
  left: 29px;
}

.cheek-right {
  right: 29px;
}

.avatar.speaking .mouth {
  animation: mouth-talk 120ms ease-in-out infinite alternate;
}

.avatar.speaking .face {
  animation: teacher-bounce 360ms ease-in-out infinite alternate;
}

.badge {
  font-weight: 700;
}

.lesson {
  padding: 34px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(34px, 6vw, 64px);
  line-height: 1;
}

h2 {
  font-size: 18px;
}

.summary {
  max-width: 680px;
  color: var(--muted);
  font-size: 18px;
}

.status {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
}

.avatar-status {
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--rose);
}

.dot.checking {
  background: var(--warning);
}

.dot.ok {
  background: var(--accent);
}

.dot.error {
  background: var(--rose);
}

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  margin-top: 24px;
}

.panel {
  padding: 20px;
}

.lessons {
  display: grid;
  gap: 14px;
}

.module-picker {
  display: grid;
  gap: 8px;
}

.module-option {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.module-option:hover,
.module-option.selected {
  border-color: var(--accent);
  background: #e8f7f3;
}

.module-option span {
  font-weight: 800;
}

.module-option small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.module-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.module-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.module-header strong {
  font-size: 17px;
}

.module-header span {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.module-card > p {
  margin-bottom: 14px;
  color: var(--muted);
}

.module-lessons {
  display: grid;
  gap: 10px;
}

.lesson-card {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
}

.lesson-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.lesson-card strong {
  display: block;
  margin-bottom: 6px;
}

.lesson-card span {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--accent-strong);
  font-weight: 700;
}

.lesson-card p {
  color: var(--muted);
  margin-bottom: 10px;
}

.vocab {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.vocab code {
  background: #edf2f7;
  border-radius: 6px;
  padding: 4px 8px;
}

.voice-toggle {
  min-height: 36px;
  padding: 0 12px;
  white-space: nowrap;
}

.voice-toggle:disabled {
  background: #c8d1df;
  border-color: #c8d1df;
  cursor: wait;
}

.voice-indicator {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.voice-meter-dot {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 50%;
  background: #c8d1df;
}

.voice-indicator.listening {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.voice-indicator.listening .voice-meter-dot {
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

.voice-indicator.speaking {
  border-color: var(--gold);
  color: var(--ink);
}

.voice-indicator.speaking .voice-meter-dot {
  background: var(--gold);
}

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

  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}

@keyframes mouth-talk {
  from {
    height: 8px;
    transform: translateY(5px) scaleX(0.86);
  }

  to {
    height: 44px;
    transform: translateY(-4px) scaleX(1.14);
  }
}

@keyframes teacher-bounce {
  from {
    transform: translateY(1px);
  }

  to {
    transform: translateY(-2px);
  }
}

.chat {
  min-height: 430px;
  display: grid;
  grid-template-rows: 1fr auto;
}

.messages {
  padding: 20px;
  overflow: auto;
}

.message {
  max-width: 760px;
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 8px;
  background: #edf2f7;
}

.message.speakable {
  cursor: pointer;
}

.message.speakable:hover,
.message.speakable:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.message.student {
  margin-left: auto;
  background: #dff5ef;
}

.message small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

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

input,
button {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font: inherit;
}

input {
  padding: 0 14px;
}

button {
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 24px, 520px);
    margin: 12px auto 20px;
    padding-top: 222px;
  }

  .classroom,
  .workspace {
    grid-template-columns: 1fr;
  }

  .classroom {
    min-height: auto;
  }

  .avatar {
    position: fixed;
    z-index: 20;
    top: max(8px, env(safe-area-inset-top));
    left: 12px;
    right: 12px;
    min-height: 0;
    height: 202px;
    grid-template-columns: auto 1fr;
    justify-content: center;
    gap: 20px;
    padding: 20px 22px;
    box-shadow: 0 12px 30px rgb(24 32 51 / 16%);
  }

  .avatar .avatar-controls {
    top: 16px;
    right: 18px;
    gap: 9px;
    max-width: 142px;
    text-align: right;
  }

  .avatar .voice-toggle {
    min-height: 34px;
    padding: 0 10px;
    font-size: 14px;
  }

  .avatar .voice-indicator {
    max-width: 142px;
    padding: 6px 8px;
    font-size: 12px;
  }

  .avatar .face {
    justify-self: start;
    width: 136px;
    height: 136px;
    border-width: 4px;
  }

  .avatar .hair {
    left: 26px;
    top: -13px;
    width: 84px;
    height: 42px;
  }

  .avatar .hair::before {
    left: 15px;
    bottom: -12px;
    width: 30px;
    height: 30px;
  }

  .avatar .hair::after {
    right: 13px;
    bottom: -10px;
    width: 33px;
    height: 30px;
  }

  .avatar .eye {
    top: 49px;
    width: 16px;
    height: 22px;
  }

  .avatar .eye:first-child {
    left: 39px;
  }

  .avatar .eye:nth-child(2) {
    right: 39px;
  }

  .avatar .mouth {
    left: 44px;
    bottom: 30px;
    width: 46px;
    height: 16px;
    border-width: 3px;
    border-top-width: 2px;
    border-radius: 9px 9px 30px 30px;
  }

  .avatar .cheek {
    top: 78px;
    width: 21px;
    height: 12px;
  }

  .avatar .cheek-left {
    left: 25px;
  }

  .avatar .cheek-right {
    right: 25px;
  }

  .avatar .badge {
    font-size: 20px;
  }

  .lesson {
    padding: 24px;
  }
}
