* { 
  margin: 0; 
  padding: 0; 
  box-sizing: border-box; 
  font-family: 'Inter Tight', sans-serif; 
}

body {
  background: black;
  color: #fff;
  display: flex;
  justify-content: center;
  height: 100vh;
  padding: 20px;
  overflow: hidden;
}

.container {
  width: 100%; 
  max-width: 1500px;
  display: flex; 
  flex-direction: column; 
  gap: 12px;
  background: rgba(0, 0, 0, 0.2);
  padding: 16px;
  border-radius: 20px;
  backdrop-filter: blur(60px);
}

.topbar {
  display: flex; 
  justify-content: space-between; 
  align-items: center;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
}

.topbar-left { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
}

.chip {
  display: flex; 
  align-items: center; 
  gap: 6px;
  padding: 6px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 14px;
}

.online-dot {
  width: 8px; 
  height: 8px; 
  border-radius: 50%; 
  background: #4aff8a;
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0% { opacity: 1 }
  50% { opacity: .4 }
  100% { opacity: 1 }
}

.chat {
  flex: 1;
  overflow-y: auto;
  display: flex; 
  flex-direction: column;
  gap: 14px;
  padding: 6px;
}

/* --- MESSAGE BUBBLE ALIGNMENT & RESIZING --- */
.message-container {
  display: flex; 
  flex-direction: column;
  gap: 4px;
  opacity: 0;
  transform: translateY(10px);
  animation: fadeInUp 0.4s forwards;
  /* Ensure container spans full width for align-self to work */
  width: 100%; 
  /* Default align left (for Moon's messages) */
  align-items: flex-start;
}

@keyframes fadeInUp { 
  to { 
    opacity: 1; 
    transform: translateY(0); 
  } 
}

.msg-header {
  display: flex; 
  align-items: center; 
  gap: 6px;
  font-size: 13px;
  opacity: .8;
}

.msg-header .chip {
  display: flex; 
  align-items: center; 
  gap: 4px;
  padding: 2px 8px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.msg {
  padding: 12px 14px;
  border-radius: 16px;
  backdrop-filter: blur(25px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  position: relative;
  word-break: break-word;
  
  /* Key properties for shrinking to content width */
  width: fit-content; 
  max-width: 80%;

  /* FIX: Ensure text inside the bubble flows naturally (left-aligned) */
  text-align: left; 
}

.msg.error { 
  background: rgba(255, 0, 0, 0.5); 
}

.message-container.user { 
  /* Pushes the whole container to the right */
  align-self: flex-end; 
  /* Aligns the header chip and bubble to the right within this container */
  align-items: flex-end; 
}

/* --- MARKDOWN STYLING FOR AI RESPONSES --- */
/* Marked.js creates these tags (p, strong, code) inside the .msg bubble */
.msg p {
    margin: 0; 
}
.msg strong {
    font-weight: 700;
}
.msg code {
    background: rgba(0, 0, 0, 0.5); 
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 85%;
    font-family: monospace;
}
.msg pre code {
    display: block;
    padding: 10px;
    white-space: pre-wrap;
    word-break: break-all;
}

/* --- INPUT AREA AND BUTTONS --- */
.input-area { 
  display: flex; 
  gap: 8px; 
  align-items: center; 
}

.input-wrapper {
  display: flex; 
  flex: 1; 
  align-items: center; 
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 8px 12px;
  backdrop-filter: blur(25px);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

input { 
  flex: 1; 
  background: transparent; 
  border: none; 
  outline: none; 
  color: #fff; 
  font-size: 16px; 
}
button {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer; 
  color: #fff; 
  font-size: 18px;
  transition: all 0.2s;
}
button:hover { 
  background: rgba(255, 255, 255, 0.2); 
}
button:disabled { 
  opacity: 0.4; 
  cursor: not-allowed; 
}

.typing { 
  display: flex; 
  gap: 4px; 
  font-size: 22px; 
}
.typing span { 
  animation: bounce 1s infinite; 
}
.typing span:nth-child(2) { 
  animation-delay: .15s; 
}
.typing span:nth-child(3) { 
  animation-delay: .3s; 
}
@keyframes bounce {
  0%, 100% { 
    transform: translateY(0); 
  }
  50% { 
    transform: translateY(-5px); 
  } 
}

/* --- MODALS --- */
#signInModal {
  position: fixed; 
  top: 0; 
  left: 0; 
  width: 100%; 
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex; 
  justify-content: center; 
  align-items: center;
  z-index: 9999;
}
#signInModal .modal-content {
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(25px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 40px; 
  text-align: center; 
  max-width: 450px;
  color: #fff; 
  font-size: 16px;
}
#signInModal h2 {
  font-size: 24px; 
  margin-bottom: 12px;
}
#signInModal p {
  margin-bottom: 8px; 
  line-height: 1.5;
}

#roadblockModal {
  position: fixed; 
  top: 0; 
  left: 0; 
  width: 100%; 
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex; 
  justify-content: center; 
  align-items: center;
  z-index: 9999;
}
#roadblockModal .modal-content {
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(25px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 40px; 
  text-align: center; 
  max-width: 450px;
  color: #fff; 
  font-size: 16px;
}
#roadblockModal h2 {
  font-size: 24px; 
  margin-bottom: 12px;
}
#roadblockModal p {
  margin-bottom: 8px; 
  line-height: 1.5;
}

/* --- REMOVED/HIDDEN SETTINGS CSS --- */
.switch { 
  display: none; 
}
#settingsModal {
  display: none !important; 
}