/* LibAI Cockpit — minimal ChatGPT-ish dark UI, mobile-first. */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f1117;
  --panel: #171a23;
  --panel-2: #1f2330;
  --text: #e8eaf0;
  --muted: #8b90a0;
  --accent: #4f8cff;
  --user: #2b3550;
  --error: #ff6b6b;
  --ok: #4cd07d;
}
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.hidden { display: none !important; }

/* ── login ── */
.login {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--panel);
  border: 1px solid #262b3a;
  border-radius: 16px;
  padding: 36px 28px;
  width: 100%; max-width: 380px;
  text-align: center;
}
.login-card .logo { font-size: 42px; margin-bottom: 8px; }
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card input {
  width: 100%; padding: 12px 14px; margin-bottom: 12px;
  background: var(--panel-2); border: 1px solid #2c3245;
  border-radius: 10px; color: var(--text); font-size: 16px;
}
.login-card button {
  width: 100%; padding: 12px;
  background: var(--accent); border: 0; border-radius: 10px;
  color: #fff; font-size: 16px; font-weight: 600; cursor: pointer;
}
.error { color: var(--error); font-size: 13px; margin-top: 12px; }

/* ── chat ── */
.chat { display: flex; flex-direction: column; height: 100dvh; }
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid #232839;
}
.hdr-title { font-weight: 600; }
.hdr-right { display: flex; align-items: center; gap: 12px; }
#voice-btn {
  background: var(--panel-2); border: 1px solid #2c3245; border-radius: 10px;
  font-size: 18px; padding: 6px 12px; cursor: pointer; color: var(--text);
}
.status { color: var(--muted); font-size: 12px; }
.status.online { color: var(--ok); }
.status.busy { color: var(--accent); }

main {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}
.msg { max-width: 88%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 4px; }
.msg.bot  { align-self: flex-start; background: var(--panel-2); border-bottom-left-radius: 4px; }
.msg.card { align-self: flex-start; background: #23301f; border: 1px solid #33502b; font-size: 14px; }
.msg.err  { align-self: flex-start; background: #3a2026; border: 1px solid #5c2e38; }
.msg.thinking { color: var(--muted); font-style: italic; }
.msg code { background: #0c0e14; padding: 1px 5px; border-radius: 5px; font-size: 14px; }
.msg hr { border: 0; border-top: 1px solid #2a3142; margin: 8px 0; }
.msg pre {
  background: #0c0e14; padding: 10px; border-radius: 8px;
  overflow-x: auto; margin: 6px 0; font-size: 13px;
}
.meta { align-self: flex-start; color: var(--muted); font-size: 11px; margin-top: -8px; padding-left: 6px; }

footer { padding: 10px 12px 14px; background: var(--panel); border-top: 1px solid #232839; }
footer form { display: flex; gap: 8px; align-items: flex-end; }
footer textarea {
  flex: 1; resize: none; max-height: 160px;
  background: var(--panel-2); border: 1px solid #2c3245;
  border-radius: 12px; color: var(--text);
  padding: 11px 13px; font-size: 16px; font-family: inherit;
}
footer button {
  background: var(--accent); border: 0; border-radius: 12px;
  color: #fff; font-size: 18px; padding: 10px 16px; cursor: pointer;
}
footer button:disabled { opacity: 0.5; cursor: default; }
.hint { color: var(--muted); font-size: 11px; text-align: center; margin-top: 8px; }

/* ── voice mode — eyes-off, peripheral-glanceable states ── */
.voice {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center;
  justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  background: #05060a;
  transition: background 0.6s ease;
}
.voice.state-listening { background: #06180d; }   /* dark green */
.voice.state-thinking  { background: #1c1405; }   /* dark amber */
.voice.state-speaking  { background: #081127; }   /* dark blue */
.voice.state-error     { background: #250808; }   /* dark red */

#voice-exit {
  align-self: flex-start;
  background: none; border: 0; color: var(--muted);
  font-size: 26px; padding: 8px 14px; cursor: pointer;
}
#voice-stage {
  flex: 1; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; cursor: pointer;
}
#voice-orb {
  width: 42vmin; height: 42vmin; max-width: 260px; max-height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2a3350, #10131f 70%);
  box-shadow: 0 0 60px rgba(79, 140, 255, 0.10);
  transition: box-shadow 0.5s ease, background 0.5s ease;
}
.state-listening #voice-orb {
  background: radial-gradient(circle at 35% 30%, #1d5c36, #0a2415 70%);
  animation: voicepulse 2.4s ease-in-out infinite;
}
.state-thinking #voice-orb {
  background: radial-gradient(circle at 35% 30%, #6d5417, #241a06 70%);
  animation: voicebreathe 3.5s ease-in-out infinite;
}
.state-speaking #voice-orb {
  background: radial-gradient(circle at 35% 30%, #274a94, #0c1730 70%);
  box-shadow: 0 0 80px rgba(79, 140, 255, 0.35);
}
.state-error #voice-orb {
  background: radial-gradient(circle at 35% 30%, #8a2323, #2a0a0a 70%);
  animation: voiceflash 0.8s ease-in-out 3;
}
@keyframes voicepulse   { 0%,100% { transform: scale(1); box-shadow: 0 0 40px rgba(76,208,125,0.18); }
                          50%     { transform: scale(1.06); box-shadow: 0 0 90px rgba(76,208,125,0.35); } }
@keyframes voicebreathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.03); } }
@keyframes voiceflash   { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

#voice-statelabel { color: var(--muted); font-size: 17px; letter-spacing: 0.4px; }
#voice-texts { width: 100%; max-width: 560px; min-height: 64px; }
#voice-texts p { font-size: 13px; margin: 4px 0; white-space: pre-wrap; word-wrap: break-word; }
#voice-transcript { color: var(--muted); }
#voice-reply { color: var(--text); opacity: 0.85; max-height: 22vh; overflow-y: auto; }

#voice-controls { display: flex; gap: 14px; margin: 10px 0 4px; }
#voice-start {
  background: var(--accent); border: 0; border-radius: 999px;
  color: #fff; font-size: 20px; font-weight: 700; padding: 18px 42px; cursor: pointer;
}
#voice-stop {
  background: #3a2026; border: 1px solid #5c2e38; border-radius: 999px;
  color: #ffb4b4; font-size: 18px; font-weight: 600; padding: 16px 38px; cursor: pointer;
}
.voice .hint { margin-top: 2px; }
