:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-soft: #edf5f2;
  --text: #13201f;
  --muted: #65716e;
  --border: #d9e1de;
  --navy: #183244;
  --teal: #0d8275;
  --teal-dark: #09695f;
  --amber: #c87a24;
  --shadow: 0 18px 48px rgba(24, 50, 68, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(13, 130, 117, 0.08), transparent 32rem),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100vw - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 0;
}

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

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4.5rem);
  line-height: 0.95;
  font-weight: 760;
  letter-spacing: 0;
  color: var(--navy);
}

.status-text {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.45;
}

.coach-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.72fr);
  gap: 22px;
  height: clamp(620px, calc(100vh - 168px), 740px);
  align-items: stretch;
}

.avatar-panel,
.conversation-panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.avatar-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.video-wrap {
  position: relative;
  display: grid;
  flex: 1;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(9, 105, 95, 0.2)),
    radial-gradient(circle at 52% 32%, rgba(255, 255, 255, 0.9), transparent 9rem),
    #dceae6;
}

.persona-video {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 180ms ease;
}

.persona-video.is-live {
  opacity: 1;
}

.mock-avatar {
  position: relative;
  display: grid;
  width: min(360px, 76%);
  height: min(510px, 84%);
  place-items: end center;
}

.avatar-light {
  position: absolute;
  inset: 8% 2% 2%;
  border-radius: 50% 50% 40% 40%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(13, 130, 117, 0.08));
  filter: blur(2px);
}

.avatar-head {
  position: absolute;
  top: 12%;
  z-index: 1;
  width: 172px;
  height: 206px;
}

.avatar-hair {
  position: absolute;
  inset: 0;
  border-radius: 46% 46% 42% 42%;
  background: #1f2a33;
}

.avatar-face {
  position: absolute;
  left: 21px;
  top: 34px;
  width: 130px;
  height: 152px;
  border-radius: 44% 44% 46% 46%;
  background: #d9a982;
  box-shadow: inset 0 -10px 0 rgba(104, 63, 41, 0.08);
}

.eye {
  position: absolute;
  top: 62px;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #18242b;
  animation: blink 6s infinite;
}

.eye-left {
  left: 36px;
}

.eye-right {
  right: 36px;
}

.mouth {
  position: absolute;
  left: 50%;
  bottom: 36px;
  width: 34px;
  height: 12px;
  border: 3px solid #7a3f38;
  border-top: 0;
  border-radius: 0 0 999px 999px;
  transform: translateX(-50%);
}

.mock-avatar.is-speaking .mouth {
  height: 20px;
  animation: talk 420ms infinite alternate;
}

.avatar-body {
  position: absolute;
  bottom: 0;
  width: 250px;
  height: 270px;
  border-radius: 45% 45% 0 0;
  background:
    linear-gradient(90deg, transparent 0 26%, rgba(255, 255, 255, 0.78) 26% 74%, transparent 74%),
    linear-gradient(180deg, #183244, #0d8275);
  box-shadow: 0 30px 60px rgba(24, 50, 68, 0.22);
}

.avatar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 92px;
  padding: 22px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.avatar-name {
  margin: 0 0 4px;
  font-size: 1.08rem;
  font-weight: 720;
}

.avatar-mode {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.signal {
  display: flex;
  align-items: end;
  gap: 4px;
  width: 34px;
  height: 26px;
}

.signal span {
  display: block;
  width: 7px;
  min-height: 8px;
  border-radius: 999px;
  background: var(--teal);
  opacity: 0.35;
}

.signal.is-active span {
  animation: meter 700ms infinite alternate;
}

.signal.is-active span:nth-child(2) {
  animation-delay: 140ms;
}

.signal.is-active span:nth-child(3) {
  animation-delay: 280ms;
}

.conversation-panel {
  display: grid;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto auto;
  overflow: hidden;
}

.transcript {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
  scroll-behavior: smooth;
}

.message {
  width: min(92%, 520px);
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  line-height: 1.42;
}

.message p {
  margin: 0;
}

.message.coach {
  align-self: flex-start;
}

.message.user {
  align-self: flex-end;
  border-color: rgba(13, 130, 117, 0.34);
  background: #e8f6f3;
}

.message-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 760;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.handoff-panel {
  margin: 0 24px 18px;
  padding: 16px;
  border: 1px solid rgba(200, 122, 36, 0.35);
  border-radius: 8px;
  background: #fff8ef;
}

.handoff-panel p {
  margin: 0 0 12px;
  font-weight: 720;
  line-height: 1.35;
}

.composer {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 18px;
  border-top: 1px solid var(--border);
  background: #fbfcfc;
}

.composer input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  outline: none;
}

.composer input:focus {
  border-color: rgba(13, 130, 117, 0.78);
  box-shadow: 0 0 0 3px rgba(13, 130, 117, 0.14);
}

.access-gate {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(246, 248, 247, 0.76);
  backdrop-filter: blur(10px);
}

.access-card {
  width: min(100%, 420px);
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.access-card h2 {
  margin: 0 0 8px;
  color: var(--navy);
  font-size: 1.45rem;
  line-height: 1.1;
}

.access-card p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.45;
}

.access-card input {
  width: 100%;
  min-height: 48px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  outline: none;
}

.access-card input:focus {
  border-color: rgba(13, 130, 117, 0.78);
  box-shadow: 0 0 0 3px rgba(13, 130, 117, 0.14);
}

.access-error {
  margin: 0 0 12px !important;
  color: #a33d1c !important;
  font-weight: 680;
}

.access-card .button {
  width: 100%;
}

.button,
.icon-button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.94rem;
  font-weight: 720;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    background-color 140ms ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  white-space: nowrap;
}

.button-primary {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 10px 20px rgba(13, 130, 117, 0.2);
}

.button-primary:hover {
  background: var(--teal-dark);
}

.button-secondary {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--navy);
}

.icon-button {
  display: grid;
  width: 46px;
  place-items: center;
  border: 1px solid rgba(13, 130, 117, 0.24);
  background: #e9f6f3;
  color: var(--teal);
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button.is-muted,
.icon-button:hover {
  background: #d9eee9;
}

.button:active,
.icon-button:active {
  transform: translateY(1px);
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

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

@keyframes meter {
  from {
    height: 8px;
    opacity: 0.35;
  }
  to {
    height: 25px;
    opacity: 1;
  }
}

@keyframes talk {
  from {
    transform: translateX(-50%) scaleY(0.7);
  }
  to {
    transform: translateX(-50%) scaleY(1.15);
  }
}

@keyframes blink {
  0%,
  94%,
  100% {
    transform: scaleY(1);
  }
  96% {
    transform: scaleY(0.12);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 28px, 680px);
    padding: 22px 0;
  }

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

  .coach-grid {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .avatar-panel,
  .conversation-panel {
    min-height: auto;
  }

  .video-wrap {
    min-height: 420px;
  }

  .conversation-panel {
    height: min(680px, calc(100vh - 32px));
    min-height: 560px;
    grid-template-rows: minmax(0, 1fr) auto auto;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 440px);
    padding: 16px 0;
  }

  .topbar {
    flex-direction: column;
    gap: 14px;
  }

  h1 {
    font-size: 2.6rem;
  }

  .topbar .button {
    width: 100%;
  }

  .video-wrap {
    min-height: 360px;
  }

  .mock-avatar {
    width: 78%;
    height: 380px;
  }

  .conversation-panel {
    height: min(640px, calc(100vh - 24px));
    min-height: 540px;
  }

  .transcript {
    padding: 16px;
  }

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

  .composer .button {
    grid-column: 1 / -1;
  }
}
