:root {
  --bg: #0f1b2d;
  --ink: #eef3fa;
  --accent: #e8890c;
}

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

html, body { height: 100%; }

body {
  background: radial-gradient(ellipse at 50% 20%, #17263d 0%, var(--bg) 70%);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

#stage {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 2vh 4vw;
}

/* ---------------- búho ---------------- */
#owl-wrap { position: relative; }

#owl {
  height: 56vh;
  max-height: 62vh;
  filter: drop-shadow(0 18px 40px rgba(0, 0, 0, 0.45));
  animation: breathe 4.2s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1)    translateY(0); }
  50%      { transform: scale(1.015) translateY(-6px); }
}

/* párpados: nacen arriba del ojo, caen al parpadear */
#lid-l, #lid-r {
  transform-origin: 158px 66px;
  transform: scaleY(0);
  transition: transform 90ms ease-in;
}
#lid-r { transform-origin: 242px 66px; }
#owl.blink #lid-l, #owl.blink #lid-r { transform: scaleY(1); }

/* pupilas siguen suavemente */
#pupil-l, #pupil-r { transition: transform 300ms ease; }

/* pico: la mandíbula rota desde la bisagra */
#beak-lower { transform-origin: 0 0; transform: rotate(0deg); }
#beak-upper { transform-origin: 0 -6px; }

/* estados */
#owl.speaking { animation: breathe 4.2s ease-in-out infinite, bob 0.9s ease-in-out infinite; }
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-10px) rotate(0.6deg); }
}
#owl.thinking { animation: tilt 1.6s ease-in-out infinite; }
@keyframes tilt {
  0%, 100% { transform: rotate(-2.5deg); }
  50%      { transform: rotate(2.5deg); }
}

/* burbuja de pensamiento */
#thought {
  position: absolute;
  top: -14px;
  right: -60px;
  display: flex;
  gap: 7px;
  padding: 12px 18px;
  background: #fffdf5;
  border-radius: 24px;
}
#thought::after {
  content: "";
  position: absolute;
  bottom: -16px;
  left: 26px;
  width: 16px;
  height: 16px;
  background: #fffdf5;
  border-radius: 50%;
}
#thought span {
  width: 11px; height: 11px;
  background: #8b5e3c;
  border-radius: 50%;
  animation: dot 1.2s infinite;
}
#thought span:nth-child(2) { animation-delay: 0.2s; }
#thought span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-8px); opacity: 1; } }

/* ---------------- chat / subtítulos ---------------- */
#chat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 17vh;
  justify-content: flex-end;
  width: min(900px, 90vw);
}

#question {
  align-self: flex-end;
  background: #233850;
  border: 1px solid #31476a;
  color: #cfe0f4;
  padding: 10px 18px;
  border-radius: 18px 18px 4px 18px;
  font-size: clamp(14px, 2vh, 20px);
  max-width: 80%;
}

#subtitle {
  background: rgba(255, 253, 245, 0.96);
  color: #1b2637;
  padding: 14px 22px;
  border-radius: 18px 18px 18px 4px;
  font-size: clamp(16px, 2.6vh, 26px);
  line-height: 1.45;
  max-width: 100%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.hidden { display: none !important; }

/* ---------------- estado y operador ---------------- */
.pill {
  background: rgba(35, 56, 80, 0.8);
  border: 1px solid #31476a;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: clamp(12px, 1.8vh, 16px);
  letter-spacing: 0.4px;
}

#ask-form {
  display: flex;
  gap: 8px;
  width: min(640px, 86vw);
  margin-top: 4px;
}
#ask-form input {
  flex: 1;
  padding: 12px 16px;
  font-size: 15px;
  border-radius: 12px;
  border: 1px solid #31476a;
  background: #17263d;
  color: var(--ink);
  outline: none;
}
#ask-form input:focus { border-color: var(--accent); }
#ask-form button {
  padding: 12px 20px;
  font-size: 15px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #1b1206;
  font-weight: 700;
  cursor: pointer;
}
#ask-form button:hover { filter: brightness(1.1); }
#ask-form button:disabled { opacity: 0.5; cursor: wait; }

#mic-btn {
  background: #233850 !important;
  color: var(--ink) !important;
  font-size: 17px;
  padding: 12px 16px !important;
}
#mic-btn.recording {
  background: #c0392b !important;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.7); }
  50%      { box-shadow: 0 0 0 10px rgba(192, 57, 43, 0); }
}

/* manos libres (🎧): verde pulsante mientras escucha */
#hands-btn {
  background: #233850 !important;
  color: var(--ink) !important;
  font-size: 17px;
  padding: 12px 16px !important;
}
#hands-btn.on {
  background: #1d7a4c !important;
  animation: listen 1.6s infinite;
}
@keyframes listen {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.55); }
  50%      { box-shadow: 0 0 0 10px rgba(46, 204, 113, 0); }
}

#hands-ctl {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink);
  opacity: 0.85;
  white-space: nowrap;
}
#hands-ctl.hidden { display: none !important; }
#sil-range { width: 110px; accent-color: var(--accent); }

#hint {
  font-size: 12px;
  opacity: 0.55;
}

/* modo proyección limpio (tecla C o ?clean=1) */
body.clean #ask-form, body.clean #hint { display: none; }
