:root {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: rgba(19, 28, 51, 0.96);
  --surface-strong: rgba(25, 36, 70, 0.98);
  --border: rgba(79, 116, 179, 0.3);
  --text: #f4f7ff;
  --muted: #a8b7d6;
  --accent: #5bb8ff;
  --accent-strong: #80d8ff;
  --positive: #47d6ac;
  --shadow: 0 32px 90px rgba(0, 0, 0, 0.35);
  --site-brightness: 1;
  font-family: Inter, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  padding: 1rem;
  background: radial-gradient(circle at top, rgba(95, 151, 255, 0.18), transparent 28%),
              linear-gradient(180deg, #08101d 0%, #08101d 100%);
  color: var(--text);
  filter: brightness(var(--site-brightness));
}

main {
  max-width: 1024px;
  margin: 0 auto;
}

.hero-band {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(91, 184, 255, 0.1);
  border: 1px solid rgba(91, 184, 255, 0.2);
  color: var(--accent-strong);
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

header {
  margin-bottom: 0.25rem;
}

h1 {
  font-size: clamp(2.4rem, 4vw, 3.5rem);
  margin: 0 0 0.75rem;
  line-height: 1.05;
}

p {
  line-height: 1.75;
  color: var(--muted);
}

.chat-panel,
.info-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 1.35rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.avatar-panel {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.25rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.avatar {
  position: relative;
  width: 160px;
  aspect-ratio: 1 / 1.25;
  margin: 0 auto;
  display: grid;
  place-items: center;
}

.avatar img {
  width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: cover;
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, filter 0.2s ease;
}

.avatar.speaking img {
  transform: scale(1.03);
  filter: brightness(1.08);
}

.sound-wave {
  position: absolute;
  bottom: -1.8rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.4rem;
  align-items: flex-end;
  justify-content: center;
  width: 6rem;
  height: 1.8rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.wave-line {
  width: 0.35rem;
  height: 0.8rem;
  background: rgba(91, 184, 255, 0.8);
  border-radius: 999px;
  transform-origin: bottom center;
}

.avatar.speaking .sound-wave {
  opacity: 1;
}

.avatar.speaking .wave-line:nth-child(1) {
  animation: pulseWave 0.7s ease-in-out infinite 0s;
}

.avatar.speaking .wave-line:nth-child(2) {
  animation: pulseWave 0.7s ease-in-out infinite 0.15s;
}

.avatar.speaking .wave-line:nth-child(3) {
  animation: pulseWave 0.7s ease-in-out infinite 0.3s;
}

@keyframes pulseWave {
  0%, 100% {
    transform: scaleY(0.75);
    background: rgba(91, 184, 255, 0.8);
  }
  50% {
    transform: scaleY(1.7);
    background: rgba(111, 218, 255, 1);
  }
}

.nose {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 8%;
  height: 8%;
  background: rgba(255, 190, 170, 0.85);
  transform: translateX(-50%);
  border-radius: 50%;
}

.neck {
  position: absolute;
  left: 50%;
  top: 74%;
  width: 28%;
  height: 18%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #f1b394 0%, #d79778 100%);
  border-radius: 18px;
}

.shoulders {
  position: absolute;
  left: 50%;
  top: 88%;
  width: 82%;
  height: 18%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #2f4b92 0%, #1c2b53 100%);
  border-radius: 40% / 100%;
}

.avatar-copy {
  display: grid;
  gap: 0.65rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(71, 214, 172, 0.28);
  background: rgba(71, 214, 172, 0.11);
  color: var(--accent-strong);
  font-size: 0.95rem;
  width: fit-content;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
  align-items: center;
  margin-bottom: 1rem;
}

.face-mode-panel {
  display: grid;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(91, 184, 255, 0.2);
  border-radius: 24px;
  padding: 1rem;
  position: relative;
}

.camera-status {
  font-size: 0.95rem;
  color: var(--muted);
}

#cameraPreview {
  width: 100%;
  min-height: 260px;
  background: #071122;
  border-radius: 24px;
  border: 1px solid rgba(91, 184, 255, 0.24);
  object-fit: cover;
}

.camera-overlay {
  position: absolute;
  bottom: 1.8rem;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 2rem);
  padding: 0.85rem 1rem;
  background: rgba(10, 25, 50, 0.75);
  border-radius: 18px;
  color: #dbe9ff;
  font-size: 0.95rem;
  text-align: center;
  pointer-events: none;
}

.checkbox-label,
.toggle-label,
.slider-label {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.85rem 1rem;
  border-radius: 18px;
}

.checkbox-label input,
.toggle-label input {
  width: 1.1rem;
  height: 1.1rem;
}

.slider-label {
  flex-direction: column;
  align-items: stretch;
}

.slider-label input {
  width: 100%;
  margin-top: 0.55rem;
}

button,
textarea {
  border: 1px solid rgba(91, 184, 255, 0.25);
}

button {
  background: linear-gradient(135deg, #5bb8ff, #2b6bd1);
  color: #fff;
  padding: 1rem 1.4rem;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover,
button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 18px 30px rgba(44, 112, 225, 0.2);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button:focus,
textarea:focus,
input:focus {
  outline: 3px solid rgba(128, 184, 255, 0.8);
  outline-offset: 2px;
}

.history {
  min-height: 320px;
  max-height: 520px;
  overflow-y: auto;
  padding: 1.2rem;
  background: rgba(7, 15, 30, 0.92);
  border-radius: 22px;
  border: 1px solid rgba(91, 184, 255, 0.12);
}

.message {
  margin-bottom: 1rem;
  line-height: 1.8;
  border-radius: 18px;
  padding: 1rem;
}

.message.user {
  background: rgba(48, 79, 170, 0.12);
  border-left: 4px solid rgba(91, 184, 255, 0.8);
}

.message.bot {
  background: rgba(23, 38, 74, 0.92);
  border-left: 4px solid rgba(71, 214, 172, 0.9);
}

.feedback-buttons {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.feedback-label {
  font-size: 0.875rem;
  color: var(--muted);
}

.feedback-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
}

.feedback-btn:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
}

.feedback-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.feedback-thanks {
  font-size: 0.875rem;
  color: var(--positive);
  font-weight: 500;
}

.prompt-form {
  display: grid;
  gap: 0.9rem;
}

textarea {
  width: 100%;
  min-height: 120px;
  background: rgba(11, 18, 32, 0.96);
  color: var(--text);
  padding: 1rem;
  border-radius: 20px;
  resize: vertical;
}

@media (max-width: 860px) {
  .avatar-panel {
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
  }

  .avatar {
    width: 140px;
  }

  .avatar-copy {
    align-items: center;
  }
}

@media (max-width: 640px) {
  .avatar {
    width: 120px;
  }

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

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