:root {
  --bg: #0f1115;
  --bg2: #171a21;
  --text: #f2f4f8;
  --muted: #9aa3b2;
  --accent: #ffb020;
  --accent2: #ff7a1a;
  --line: #262b36;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #1b2030 0%, var(--bg) 60%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  cursor: default;
  user-select: none;
}

#stage {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 28px 28px;
}

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

#brand {
  font-size: 15px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}

#resetBtn, #typeToggle {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
}
#resetBtn:hover, #typeToggle:hover { color: var(--text); border-color: #3a4150; }

#log {
  flex: 1;
  overflow-y: auto;
  padding: 28px 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bubble {
  max-width: 78%;
  padding: 16px 20px;
  border-radius: 22px;
  font-size: 24px;
  line-height: 1.45;
  animation: pop .18s ease-out;
}
.bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #1a1207;
  border-bottom-right-radius: 8px;
  font-weight: 600;
}
.bubble.bot {
  align-self: flex-start;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-bottom-left-radius: 8px;
}
.bubble.thinking { color: var(--muted); font-size: 20px; }

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

#caption {
  min-height: 30px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 19px;
  font-style: italic;
  text-align: center;
}

#handoff {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin: 0 0 12px;
  padding: 12px 18px;
  border: 1px solid #3d3320;
  background: #241d10;
  border-radius: 14px;
  font-size: 18px;
}
#handoff strong { color: var(--accent); }

#controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#micBtn {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #1a1207;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 12px 40px rgba(255, 140, 30, .35);
  transition: transform .12s ease, box-shadow .2s ease;
}
#micBtn svg { width: 46px; height: 46px; fill: currentColor; }
#micBtn:active { transform: scale(.96); }
#micBtn.listening {
  animation: pulse 1.3s ease-out infinite;
  box-shadow: 0 0 0 0 rgba(255, 176, 32, .6);
}
#micBtn.disabled { opacity: .35; pointer-events: none; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 176, 32, .55); }
  100% { box-shadow: 0 0 0 34px rgba(255, 176, 32, 0); }
}

#hint {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  letter-spacing: .04em;
}

#typeForm {
  display: flex;
  gap: 10px;
  width: 100%;
}
#typeInput {
  flex: 1;
  padding: 16px 18px;
  font-size: 20px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  outline: none;
  user-select: text;
}
#typeInput:focus { border-color: var(--accent); }
#typeForm button {
  padding: 0 22px;
  font-size: 17px;
  border-radius: 14px;
  border: none;
  background: var(--accent);
  color: #1a1207;
  font-weight: 700;
  cursor: pointer;
}

#idle {
  position: fixed;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  text-align: center;
  background: rgba(10, 12, 18, .88);
  backdrop-filter: blur(6px);
  padding: 24px;
}
#idle h1 { font-size: 46px; margin: 0; }
#idle p { color: var(--muted); font-size: 20px; margin: 0; }

#warn {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  color: #ffb4a2;
  font-size: 14px;
  margin: 0;
}

.hidden { display: none !important; }
