:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #4f7cff;
  --accent-text: #ffffff;
  --bot: #eef2ff;
  --border: #e5e7eb;
  --sos: #b42318;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --surface: #171b23;
    --text: #e8eaf0;
    --muted: #9aa3b2;
    --accent: #7b9cff;
    --accent-text: #0f1218;
    --bot: #1e2533;
    --border: #2a3140;
    --sos: #ff8a80;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button { font: inherit; cursor: pointer; }

.top {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { margin: 0; font-size: 18px; }
.brand p { margin: 0; font-size: 13px; color: var(--muted); }
.avatar {
  width: 44px; height: 44px; flex: none; border-radius: 50%; object-fit: cover;
  background: var(--bot);
}
/* Mascota mare de bun venit, cu mișcare „de robot AI”: scanare, puls de lumină, mic tremur. */
.hero {
  position: relative; flex: none; align-self: center;
  width: 240px; height: 300px; margin: 4px 0;
  overflow: hidden;
  /* Marginile se topesc în fundalul paginii, ca mascota să pară că iese din întuneric. */
  -webkit-mask-image: radial-gradient(ellipse 55% 52% at 50% 52%, #000 60%, transparent 100%);
  mask-image: radial-gradient(ellipse 55% 52% at 50% 52%, #000 60%, transparent 100%);
}
.hero img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  animation: ekoo-puls 4s ease-in-out infinite, ekoo-tremur 7s steps(1) infinite;
}
.hero::after {
  content: ""; position: absolute; left: 0; right: 0; top: -30%; height: 30%;
  background: linear-gradient(transparent, rgba(150, 235, 255, .28), transparent);
  animation: ekoo-scan 5s linear infinite;
  pointer-events: none;
}
@keyframes ekoo-scan { 0%, 40% { transform: translateY(0); } 100% { transform: translateY(440%); } }
@keyframes ekoo-puls { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.15) saturate(1.1); } }
@keyframes ekoo-tremur {
  0%, 90%, 100% { transform: none; }
  91% { transform: translateX(2px); }
  92% { transform: translateX(-2px); }
  93% { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .hero img, .hero::after { animation: none; }
  .hero::after { display: none; }
}
.actions { display: flex; gap: 6px; }
.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
}
#btn-help { color: var(--sos); border-color: currentColor; white-space: nowrap; }
.ghost { flex: none; }
.brand p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand { min-width: 0; }
.brand div { min-width: 0; }

.menu {
  position: absolute;
  right: 16px; top: 100%;
  z-index: 10;
  display: flex; flex-direction: column; gap: 8px;
  width: min(300px, calc(100vw - 32px));
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}
.menu[hidden] { display: none; }
.menu label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.menu input {
  padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit;
}
.menu button {
  text-align: left; padding: 8px 10px; border-radius: 8px;
  border: 0; background: var(--bg); color: var(--text);
}

#chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg {
  max-width: min(640px, 85%);
  padding: 10px 14px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.bot { align-self: flex-start; background: var(--bot); border-bottom-left-radius: 4px; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }
.msg a { color: inherit; }
.msg.typing { color: var(--muted); font-style: italic; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.buttons button {
  border: 1px solid var(--accent); color: var(--accent);
  background: var(--surface); border-radius: 999px; padding: 6px 14px;
}
.buttons button:disabled { opacity: .5; cursor: default; }

#composer {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
#input {
  flex: 1; resize: none; max-height: 160px;
  padding: 10px 14px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font: inherit;
}
#send {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-size: 18px;
}
#send:disabled { opacity: .5; }

.sos {
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  font-size: 13px; text-align: center; color: var(--muted);
  background: var(--surface);
}
.sos a { color: var(--sos); font-weight: 600; text-decoration: none; }
