* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: system-ui, sans-serif;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05060a;
  color: white;
}

#app-container {
  position: relative;
  width: 100%;
  height: 100%;
}

/* 🔵 AREA SFERA */
#renderCanvas {
  width: 100%;
  height: calc(100% - 210px); /* spazio per la chat */
  display: block;
}

/* 💬 CHAT (mobile first) */
#chat-box {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;

  width: 100%;
  height: 210px;

  background: rgba(15, 17, 25, 0.85);
  backdrop-filter: blur(6px);
  border-top: 1px solid rgba(255,255,255,0.1);

  display: flex;
  flex-direction: column;
  padding: 10px;
  overflow: hidden;
}

/* 📜 CONTAINER MESSAGGI SCORRIBILE */
#chat-messages {
  flex: 1;
  overflow-y: auto;       /* SCROLL ABILITATO */
  padding-right: 6px;

  display: flex;
  flex-direction: column;
  position: relative;
}

/* questo trucco fa partire i messaggi dal basso */
#chat-messages::after {
  content: "";
  flex-grow: 1;
}

/* 🔥 Scrollbar moderna */
#chat-messages::-webkit-scrollbar {
  width: 6px;
}
#chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.25);
  border-radius: 6px;
}
#chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

/* 🗨️ MESSAGGI */
.message {
  max-width: 90%;
  margin-bottom: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  line-height: 1.3;
  font-size: 0.86rem;

  background: transparent; /* i vecchi messaggi restano trasparenti */
}

/* ultimo messaggio → ha la bolla colorata */
.message.latest.user {
  background: linear-gradient(135deg, #3b82f6, #22c55e);
  color: #f9fafb;
}

.message.latest.ai {
  background: rgba(250, 204, 21, 0.16);
  border: 1px solid rgba(250, 204, 21, 0.45);
  color: #ffe9a2;
}

/* allineamento */
.message.user {
  align-self: flex-end;
  text-align: right;
  color: #9ad0ff;
}

.message.ai {
  align-self: flex-start;
  text-align: left;
  color: #ffd88a;
}

/* ✏️ INPUT */
#chat-input-container {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

#chat-input {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  border: none;
  outline: none;
  background: rgba(30, 32, 40, 0.6);
  color: white;
}

#send-btn {
  padding: 8px 14px;
  background: #446bff;
  border: none;
  border-radius: 6px;
  color: white;
  cursor: pointer;
}

/* 🔗 PULSANTI SOCIAL INIZIALI */
.social-buttons {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.social-btn {
  flex: 1;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(30,32,40,0.7);

  font-size: 0.75rem;
  cursor: pointer;
  color: #e5e7eb;

  transition: 0.15s ease;
}
.social-btn:hover {
  background: rgba(255,255,255,0.1);
}

.social-btn .icon {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  font-size: 0.75rem;
  font-weight: 700;
}

/* colori icone */
.social-btn.google .icon { background: #ffffff; color: #ea4335; }
.social-btn.facebook .icon { background: #1877f2; color: #ffffff; }
.social-btn.itunes .icon { background: #ff2d55; color: #ffffff; }

/* 🌐 VERSIONE DESKTOP / WEB */
@media (min-width: 768px) {
  #renderCanvas {
    height: 100%;
  }

  #chat-box {
    height: 230px;
    width: 40vw;              /* <── meno della metà dello schermo */
    max-width: 480px;
    min-width: 360px;

    left: 50%;
    transform: translateX(-50%);

    border-radius: 14px 14px 0 0;
    border: 1px solid rgba(255,255,255,0.12);
    border-bottom: none;
    box-shadow: 0 -12px 30px rgba(0,0,0,0.5);
  }

  #chat-messages {
    padding-right: 8px;
  }
}
