:root {
  --bg: #eef6ff;
  --card: #ffffff;
  --primary: #3a7bd5;
  --primary-dark: #2c5fa8;
  --accent: #ffb545;
  --text: #22314a;
  --muted: #6b7a93;
  --bubble-user: #3a7bd5;
  --bubble-bot: #f0f3f9;
  --danger: #e0575b;
  font-size: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  font-family: "Segoe UI", Verdana, Arial, sans-serif;
  color: var(--text);
}

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Écran de connexion ---- */
#login-screen {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: var(--card);
  border-radius: 24px;
  padding: 32px 28px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(30, 60, 120, 0.12);
  text-align: center;
}

.mascot { font-size: 64px; }
.mascot.small { font-size: 36px; }

h1 { margin: 8px 0 4px; font-size: 1.8rem; }
.subtitle { color: var(--muted); margin-bottom: 24px; }

#login-form label {
  display: block;
  text-align: left;
  font-weight: 600;
  margin-bottom: 16px;
}

#login-form select,
#login-form input {
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid #dbe6f7;
  font-size: 1rem;
  background: #fbfdff;
}

button {
  cursor: pointer;
  border: none;
  font-family: inherit;
}

#login-form button,
.chat-input button {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  background: var(--primary);
  color: white;
  font-size: 1.05rem;
  font-weight: 700;
  margin-top: 8px;
}
#login-form button:active,
.chat-input button:active { background: var(--primary-dark); }

.error {
  color: var(--danger);
  font-weight: 600;
  margin-top: 12px;
}

/* ---- Écran de chat ---- */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--card);
  box-shadow: 0 2px 10px rgba(30, 60, 120, 0.08);
}
.child-name { font-weight: 800; font-size: 1.1rem; }
.time-left { color: var(--muted); font-size: 0.85rem; }
.ghost-btn {
  margin-left: auto;
  background: transparent;
  color: var(--muted);
  border: 2px solid #dbe6f7 !important;
  border-radius: 12px;
  padding: 8px 12px;
  font-weight: 600;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.4;
  white-space: pre-wrap;
}
.bubble.bot {
  align-self: flex-start;
  background: var(--bubble-bot);
  border-bottom-left-radius: 4px;
}
.bubble.user {
  align-self: flex-end;
  background: var(--bubble-user);
  color: white;
  border-bottom-right-radius: 4px;
}
.bubble.system {
  align-self: center;
  background: #fff4de;
  color: #8a5b00;
  font-weight: 600;
  font-size: 0.9rem;
}

.chat-input {
  display: flex;
  gap: 10px;
  padding: 14px;
  background: var(--card);
  box-shadow: 0 -2px 10px rgba(30, 60, 120, 0.08);
}
.chat-input input {
  flex: 1;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid #dbe6f7;
  font-size: 1rem;
}
.chat-input button { width: auto; padding: 14px 20px; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101826;
    --card: #182234;
    --text: #eaf1fb;
    --muted: #93a3bd;
    --bubble-bot: #24314a;
  }
  #login-form select,
  #login-form input,
  .chat-input input { background: #101826; color: var(--text); border-color: #2a394f; }
  .ghost-btn { border-color: #2a394f !important; }
}

/* ---- Voix ---- */
.voice-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 10px 18px;
  background: var(--card);
  border-top: 1px solid #e3ecf8;
  font-size: 0.85rem;
  color: var(--muted);
}
.voice-bar .toggle,
.voice-bar .lang-pick { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.voice-bar select {
  border: 2px solid #dbe6f7;
  border-radius: 10px;
  padding: 4px 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
}
.voice-status {
  margin: 0;
  padding: 6px 18px;
  text-align: center;
  font-weight: 700;
  color: var(--primary);
}
.voice-status.listening::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.7); } }
.chat-input .mic-btn {
  width: 52px;
  height: 52px;
  padding: 0;
  margin-top: 0;
  flex: none;
  align-self: center;
  border-radius: 50%;
  background: var(--accent);
  color: #3a2a00;
  display: grid;
  place-items: center;
}
.chat-input .mic-btn.on { background: var(--danger); color: #fff; }
.chat-input .mic-btn:active { background: var(--danger); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .voice-status.listening::before { animation: none; } }

[hidden] { display: none !important; }
.chat-input input { min-width: 0; }
.chat-input { max-width: 100%; }
@media (max-width: 480px) {
  .chat-input { gap: 8px; padding: 10px; }
  .chat-input button#send-btn { padding: 14px 14px; }
}

/* ---- Mode appel (conversation vocale continue) ---- */
.call-btn {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
}
.call-btn.on { background: var(--danger); }
.call-btn:disabled { opacity: 0.5; cursor: default; }
