:root {
  --bg: #0f1117;
  --panel: #1a1e29;
  --panel-2: #222738;
  --text: #e8ebf2;
  --muted: #8b93a7;
  --accent: #4f8cff;
  --accent-2: #7c5cff;
  --ring: #4f8cff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 640px;
  padding: 24px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.header {
  text-align: center;
}

.header h1 {
  font-size: 1.6rem;
  font-weight: 700;
}

.subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* Аватар */
.avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.avatar-video {
  display: none;
  width: 320px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  background: #000;
  object-fit: cover;
}

.avatar-video.active {
  display: block;
}

.avatar-wrap.has-video .avatar {
  display: none;
}

.avatar {
  position: relative;
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-face {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: var(--panel-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  z-index: 2;
  transition: background 0.2s;
}

.avatar-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  z-index: 1;
  opacity: 0;
}

.avatar.speaking .avatar-ring {
  opacity: 1;
  border-color: var(--ring);
  animation: pulse 1.4s ease-out infinite;
}

.avatar.speaking .avatar-face {
  background: #2a3350;
}

.avatar.interrupted .avatar-ring {
  border-color: #ff6b6b;
}

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

.avatar-status {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  background: var(--panel);
  padding: 2px 10px;
  border-radius: 999px;
}

/* Выбор персонажа */
.persona-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
  text-align: center;
}

.persona-select {
  width: 100%;
  max-width: 360px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--panel-2);
  background: var(--panel);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}

.persona-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Кнопки */
.controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  padding: 12px 28px;
  border: none;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: transform 0.1s, opacity 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--panel-2);
  color: var(--text);
}

/* Расшифровка */
.transcript {
  background: var(--panel);
  border-radius: 16px;
  padding: 16px;
}

.transcript-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 10px;
}

.transcript-body {
  max-height: 240px;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.placeholder {
  color: var(--muted);
  font-style: italic;
}

.msg {
  padding: 8px 12px;
  border-radius: 12px;
  max-width: 85%;
}

.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}

.msg.bot {
  align-self: flex-start;
  background: var(--panel-2);
}

.msg .who {
  display: block;
  font-size: 0.7rem;
  opacity: 0.7;
  margin-bottom: 2px;
}

.msg .msg-text {
  word-break: break-word;
}

/* Статус-бар */
.status-bar {
  min-height: 20px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.status-bar.error {
  color: #ff6b6b;
}
