:root {
  color-scheme: light;
  --ink: oklch(24% 0.025 248);
  --muted: oklch(48% 0.028 248);
  --paper: oklch(97% 0.012 82);
  --panel: oklch(99% 0.008 82);
  --line: oklch(86% 0.018 82);
  --blue: oklch(43% 0.11 250);
  --blue-dark: oklch(31% 0.095 250);
  --rose: oklch(72% 0.12 24);
  --green: oklch(66% 0.13 151);
  --shadow: 0 24px 70px oklch(30% 0.04 248 / 18%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, oklch(88% 0.055 63), transparent 32rem),
    linear-gradient(135deg, oklch(96% 0.018 80), oklch(91% 0.02 246));
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
textarea {
  font: inherit;
}

.coach-shell {
  min-height: 100vh;
  padding: clamp(16px, 3vw, 38px);
  display: grid;
  place-items: center;
}

.coach-panel {
  width: min(1360px, 100%);
  min-height: min(720px, calc(100vh - 40px));
  display: grid;
  grid-template-columns: minmax(310px, 430px) minmax(0, 1fr);
  background: var(--panel);
  border: 1px solid oklch(90% 0.014 82);
  box-shadow: var(--shadow);
  overflow: hidden;
  border-radius: 28px;
}

.coach-profile {
  padding: clamp(22px, 3vw, 34px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: linear-gradient(180deg, oklch(94% 0.035 76), oklch(90% 0.025 248));
  border-right: 1px solid var(--line);
}

.avatar-frame {
  aspect-ratio: 1;
  border: 1px solid oklch(81% 0.022 82);
  background: oklch(96% 0.012 82);
  overflow: hidden;
  border-radius: 22px;
}

.avatar-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  display: block;
}

.coach-identity {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.eyebrow,
.status-dot,
.voice-disclosure {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.coach-identity h1,
.chat-header h2 {
  margin: 0;
  line-height: 1.05;
  letter-spacing: 0;
}

.coach-identity h1 {
  max-width: 12ch;
  font-size: clamp(2rem, 3vw, 2.85rem);
}

.coach-identity p:last-child,
.voice-disclosure {
  max-width: 34ch;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.chat-card {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: oklch(98% 0.007 82);
}

.chat-header {
  min-height: 104px;
  padding: 22px clamp(18px, 3vw, 30px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.status-dot span {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px oklch(66% 0.13 151 / 18%);
}

.chat-header h2 {
  font-size: clamp(1.35rem, 2.5vw, 2.15rem);
}

.speak-button {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--blue-dark);
  cursor: pointer;
  border-radius: 999px;
}

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

.speak-button:hover,
.speak-button:focus-visible {
  color: #283249;
  outline: none;
}

.messages {
  min-height: 0;
  padding: clamp(18px, 3vw, 30px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.message {
  display: flex;
  gap: 12px;
  align-items: center;
  animation: rise 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

.message.user {
  justify-content: flex-end;
}

.message img {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 1px solid var(--line);
  object-fit: cover;
  border-radius: 12px;
}

.bubble {
  max-width: min(580px, 82%);
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: oklch(99% 0.006 82);
  border-radius: 20px 20px 20px 8px;
}

.user .bubble {
  background: #283249;
  color: oklch(98% 0.006 248);
  border-color: #283249;
  border-radius: 20px 20px 8px 20px;
}

.bubble p {
  margin: 0;
  line-height: 1.55;
}

.bubble .coach-section {
  display: block;
  margin-top: 10px;
  color: var(--blue-dark);
  font-weight: 800;
}

.user .bubble p {
  color: inherit;
}

.play-line {
  margin-top: 12px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--blue-dark);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 800;
}

.composer {
  padding: 18px clamp(18px, 3vw, 30px) 22px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  border-top: 1px solid var(--line);
  background: oklch(96% 0.01 82);
}

.composer textarea {
  width: 100%;
  min-height: 54px;
  max-height: 150px;
  resize: none;
  border: 1px solid oklch(79% 0.023 82);
  padding: 14px;
  color: var(--ink);
  background: oklch(99% 0.006 82);
  outline: none;
  line-height: 1.45;
  border-radius: 18px;
}

.composer textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px oklch(43% 0.11 250 / 18%);
}

.composer button {
  min-width: 96px;
  min-height: 54px;
  border: 0;
  background: #283249;
  color: oklch(98% 0.006 248);
  cursor: pointer;
  font-weight: 800;
  border-radius: 18px;
}

.composer button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 42px;
  min-height: 24px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--muted);
  animation: dotPulse 900ms ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 120ms;
}

.typing-dots span:nth-child(3) {
  animation-delay: 240ms;
}

.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;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes dotPulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@media (max-width: 820px) {
  .coach-panel,
  .coach-profile,
  .chat-card {
    min-width: 0;
    max-width: 100vw;
  }

  .coach-shell {
    padding: 0;
    place-items: stretch;
  }

  .coach-panel {
    min-height: 100vh;
    grid-template-columns: 1fr;
    border: 0;
  }

  .coach-profile {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    align-items: center;
    gap: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .avatar-frame {
    aspect-ratio: 1;
  }

  .coach-identity h1 {
    max-width: none;
    font-size: 1.5rem;
    line-height: 1.08;
  }

  .coach-identity p:last-child,
  .voice-disclosure {
    grid-column: 1 / -1;
  }

  .coach-identity p:last-child {
    max-width: 100%;
  }

  .chat-card {
    min-height: 620px;
  }

  .bubble {
    max-width: calc(100% - 92px);
  }

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