:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  background: #111514;
  color: #f4f1e8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, #101514 0%, #17211e 54%, #241f18 100%);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: #f4b94f;
  color: #1c160d;
  font-weight: 750;
  cursor: pointer;
}

button.secondary {
  background: #293331;
  color: #f4f1e8;
}

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

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid #3a4642;
  border-radius: 8px;
  background: #151b1a;
  color: #f4f1e8;
  padding: 0 12px;
  outline: none;
}

input:focus {
  border-color: #f4b94f;
}

button:focus-visible,
input:focus-visible,
a:focus-visible,
audio:focus-visible {
  outline: 3px solid #76a7ff;
  outline-offset: 3px;
}

.shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.face-panel,
.controls-panel,
.chat-panel {
  border: 1px solid rgba(244, 241, 232, 0.11);
  border-radius: 8px;
  background: rgba(18, 24, 22, 0.82);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

.face-panel {
  min-height: 330px;
  padding: 16px;
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 14px;
}

.status-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #cfc8b8;
  font-size: 0.92rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6f7772;
}

.face {
  width: min(74vw, 300px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.85) 0 0.44rem, transparent 0.48rem),
    linear-gradient(145deg, #f7f0df, #d8e4df 55%, #b8d0c7);
  position: relative;
  display: grid;
  place-items: center;
  box-shadow: inset -18px -22px 34px rgba(20, 46, 43, 0.18), 0 24px 60px rgba(0, 0, 0, 0.36);
  transition: transform 180ms ease, filter 180ms ease;
}

.eyes {
  width: 58%;
  display: flex;
  justify-content: space-between;
  transform: translateY(-26px);
}

.eyes span {
  width: 52px;
  height: 64px;
  border-radius: 50%;
  background: #14211f;
  box-shadow: inset 12px 12px 0 rgba(255, 255, 255, 0.14);
  transform-origin: center;
}

.mouth {
  position: absolute;
  bottom: 72px;
  width: 74px;
  height: 22px;
  border: 5px solid #14211f;
  border-top: 0;
  border-radius: 0 0 80px 80px;
}

.face.listening {
  filter: drop-shadow(0 0 22px rgba(76, 186, 148, 0.38));
}

.face.listening .eyes span {
  animation: blink 1.6s infinite;
}

.face.thinking {
  animation: think 1.1s ease-in-out infinite;
}

.face.speaking .mouth {
  bottom: 66px;
  width: 96px;
  height: 34px;
  border-width: 6px;
  border-top: 0;
  border-radius: 0 0 96px 96px;
  animation: talk 320ms ease-in-out infinite;
}

.face.speaking .eyes span {
  transform: scaleY(0.94);
}

.face.error {
  filter: drop-shadow(0 0 20px rgba(255, 95, 95, 0.42));
}

.face.error .mouth {
  border-top: 5px solid #14211f;
  border-bottom: 0;
  border-radius: 80px 80px 0 0;
}

audio {
  width: 100%;
  min-width: 0;
  max-width: min(460px, calc(100vw - 64px));
  display: block;
}

.controls-panel,
.chat-panel {
  padding: 16px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading p {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 780;
}

.section-heading span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #a9b4ae;
  font-size: 0.78rem;
}

.field {
  display: grid;
  gap: 7px;
  color: #cfc8b8;
  font-size: 0.86rem;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin: 12px 0;
}

.briefing-output {
  display: grid;
  gap: 10px;
  color: #e9e1d2;
  line-height: 1.55;
  font-size: 0.93rem;
}

.briefing-output ul {
  margin: 0;
  padding-left: 20px;
}

.briefing-output a {
  color: #f4b94f;
}

.messages {
  min-height: 180px;
  max-height: 320px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 9px;
  padding-right: 4px;
}

.message {
  width: fit-content;
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.5;
  background: #27312f;
}

.message.user {
  justify-self: end;
  background: #49361d;
}

.message.system {
  background: #512829;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  margin-top: 12px;
}

.mic.recording {
  background: #ef6f54;
}

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

@keyframes think {
  0%, 100% {
    transform: translateX(0) rotate(0deg);
  }
  50% {
    transform: translateX(5px) rotate(1.5deg);
  }
}

@keyframes talk {
  0%, 100% {
    transform: translateY(0) scaleX(1) scaleY(0.82);
  }
  50% {
    transform: translateY(2px) scaleX(1.08) scaleY(1.16);
  }
}

@media (min-width: 840px) {
  .shell {
    min-height: 100vh;
    grid-template-columns: 360px 1fr;
    align-content: center;
  }

  .face-panel {
    grid-row: span 2;
    min-height: 680px;
  }
}

@media (max-width: 520px) {
  .shell {
    padding: 10px;
  }

  .face-panel,
  .controls-panel,
  .chat-panel {
    overflow: hidden;
  }

  audio {
    max-width: calc(100vw - 44px);
  }

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

  .section-heading {
    display: grid;
  }
}
