/* Brand Icon Styles */
.sidebar-header img,
.chat-header img {
  height: 32px;
  width: 32px;
  margin-right: 0.7rem;
  border-radius: 8px;
  vertical-align: middle;
  object-fit: cover;
}
.chat-header img {
  height: 36px;
  width: 36px;
}
.chat-header {
  position: relative;
}
/* Welcome Overlay: less blur, more clear, less border radius */
#welcome-overlay.welcome-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(24, 16, 40, 0.95); /* slightly less opaque */
  z-index: 2000; /* Higher than login overlay */
  display: none; /* Hidden by default, shown via JavaScript */
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px); /* less blur */
}
.welcome-content {
  background: #23163a;
  color: #e0d7ff;
  padding: 2.5rem 2.5rem 2rem 2.5rem;
  border-radius: 0.7rem; /* less rounded corners */
  box-shadow: 0 4px 18px rgba(162,89,255,0.13); /* less shadow */
  text-align: center;
  min-width: 320px;
}
.welcome-content h2 {
  margin-top: 0;
  font-size: 2rem;
  color: #a259ff;
}
.welcome-content p {
  margin-bottom: 2rem;
  font-size: 1.1rem;
}
.welcome-options {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
}
.welcome-option {
  background: linear-gradient(135deg, #a259ff 60%, #4f8cff 100%);
  color: #fff;
  border: none;
  border-radius: 0.7rem;
  padding: 0.8rem 2.2rem;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(162,89,255,0.15);
}
.welcome-option:hover {
  background: linear-gradient(135deg, #4f8cff 60%, #a259ff 100%);
  box-shadow: 0 4px 16px rgba(162,89,255,0.25);
}
/* Login Overlay */
#login-overlay.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(24, 16, 40, 0.95);
  z-index: 3000; /* Higher than welcome overlay */
  display: none; /* Hidden by default, shown via JavaScript */
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.login-content {
  background: #23163a;
  color: #e0d7ff;
  padding: 2.5rem 3rem;
  border-radius: 0.7rem;
  box-shadow: 0 4px 18px rgba(162,89,255,0.13);
  text-align: center;
  min-width: 320px;
  max-width: 400px;
  position: relative;
}
.login-content h2 {
  margin-top: 0;
  font-size: 2rem;
  color: #a259ff;
  margin-bottom: 0.5rem;
}
.login-content input {
  width: 100%;
  padding: 0.75rem;
  border-radius: 0.5rem;
  border: 1.5px solid #333;
  background: #1a1a1a;
  color: #fff;
  font-size: 1rem;
  box-sizing: border-box;
  margin-bottom: 1rem;
  transition: border-color 0.2s;
}
.login-content input:focus {
  outline: none;
  border-color: #a259ff;
}
.login-content button[type="submit"] {
  width: 100%;
  padding: 0.75rem;
  border-radius: 0.5rem;
  background: #a259ff;
  color: #fff;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.login-content button[type="submit"]:hover {
  background: #4f8cff;
}
#login-error {
  display: none;
  margin-top: 1rem;
  padding: 0.75rem;
  background: #ff4444;
  color: #fff;
  border-radius: 0.5rem;
  text-align: center;
  font-size: 0.9rem;
}
/* Storage Modal */
.storage-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(24, 16, 40, 0.95);
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.storage-modal-content {
  background: #23163a;
  color: #e0d7ff;
  border-radius: 0.7rem;
  box-shadow: 0 4px 18px rgba(162,89,255,0.13);
  min-width: 500px;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
}
.storage-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid #2d1846;
}
.storage-modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: #a259ff;
}
.storage-modal-body {
  padding: 2rem;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@media (max-width: 900px) {
  #app {
    flex-direction: column;
    height: 100vh;
  }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 240px;
    z-index: 2000;
    background: #1a1124;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(.4,0,.2,1);
    box-shadow: 2px 0 12px 0 rgba(162,89,255,0.08);
    border-right: 1px solid #2d1846;
    border-bottom: none;
    display: flex;
    flex-direction: column;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-header {
    flex: 1;
    border-bottom: 1px solid #2d1846;
    border-right: none;
    padding: 1rem;
    font-size: 1rem;
  }
  #session-list {
    flex: 2;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-bottom: none;
    border-right: none;
  }
  #session-list li {
    min-width: 90px;
    border-bottom: 1px solid #2d1846;
    border-right: none;
    padding: 0.8rem 1rem;
    font-size: 0.95rem;
    text-align: left;
  }
  .chat-header h1 {
    font-size: 1.1rem;
  }
  .chat-area {
    padding: 0.7rem;
    gap: 0.7rem;
  }
  .message {
    font-size: 0.97rem;
    padding: 0.7rem 0.8rem;
    max-width: 90%;
  }
  #chat-form {
    padding: 0.7rem;
    gap: 0.3rem;
  }
  #user-input {
    font-size: 0.97rem;
    padding: 0.5rem;
  }
  #chat-form button {
    padding: 0 1rem;
    font-size: 0.97rem;
  }
  .sidebar-toggle {
    display: inline-block !important;
  }
}

/* Always hide sidebar toggle on desktop */
@media (min-width: 901px) {
  .sidebar-toggle {
    display: none !important;
  }
  .sidebar {
    transform: none !important;
    position: static !important;
    width: 260px;
    z-index: auto;
  }
}
body {
  margin: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #f5f6fa;
  color: #222;
}
#app {
  display: flex;
  height: 100vh;
}
.sidebar {
  width: 260px;
  background: #23272f;
  color: #fff;
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid #333;
}
.sidebar-header h2 {
  margin: 0;
  font-size: 1.2rem;
}
#new-session {
  background: #4f8cff;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1.5rem;
  cursor: pointer;
}
#session-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
}
#session-list li {
  padding: 0.8rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid #333;
  transition: background 0.2s;
}
#session-list li.active, #session-list li:hover {
  background: #353b48;
}
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
}
.chat-header {
  padding: 1rem;
  border-bottom: 1px solid #eee;
  background: #f7f9fb;
}
.chat-header h1 {
  margin: 0;
  font-size: 1.5rem;
  color: #4f8cff;
}
.chat-area {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}
.message {
  max-width: 70%;
  padding: 1rem;
  border-radius: 1.2rem;
  font-size: 1rem;
  line-height: 1.5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  word-break: break-word;
}
.message.user {
  align-self: flex-end;
  background: #4f8cff;
  color: #fff;
}
.message.bot {
  align-self: flex-start;
  background: #f1f2f6;
  color: #23272f;
}
.message.loader {
  align-self: flex-start;
  background: transparent;
  box-shadow: none;
  margin-bottom: 0.2rem;
  padding: 0.5rem 0.7rem;
}
.typing-indicator {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 24px;
}
.typing-indicator svg {
  display: block;
}
.typing-indicator .dot {
  fill: #a259ff;
  opacity: 0.5;
  transform: scale(0.7);
  transform-origin: center;
  animation: dot-typing 1.2s infinite cubic-bezier(.4,0,.2,1);
}
.typing-indicator .dot:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-indicator .dot:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes dot-typing {
  0% { opacity: 0.5; transform: scale(0.7); }
  20% { opacity: 1; transform: scale(1.1); }
  40% { opacity: 0.5; transform: scale(0.7); }
  100% { opacity: 0.5; transform: scale(0.7); }
}
.loader-dots {
  display: flex;
  gap: 0.4rem;
}
.loader-dots span {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #a259ff;
  opacity: 0.7;
  animation: loader-bounce 1s infinite alternate;
}
body {
  margin: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #181028;
  color: #e0d7ff;
}
#app {
  display: flex;
  height: 100vh;
}
.sidebar {
  width: 260px;
  background: #1a1124;
  color: #e0d7ff;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 12px 0 rgba(162,89,255,0.08);
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid #2d1846;
}
.sidebar-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: #a259ff;
  letter-spacing: 1px;
}
#new-session {
  background: linear-gradient(135deg, #a259ff 60%, #4f8cff 100%);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(162,89,255,0.15);
  transition: background 0.2s, box-shadow 0.2s;
}
#new-session:hover {
  background: linear-gradient(135deg, #4f8cff 60%, #a259ff 100%);
  box-shadow: 0 4px 16px rgba(162,89,255,0.25);
}
#session-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
}
#session-list li {
  padding: 0.8rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid #2d1846;
  transition: background 0.2s, color 0.2s;
  color: #e0d7ff;
}
#session-list li.active, #session-list li:hover {
  background: #2d1846;
  color: #a259ff;
}
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #181028;
}
.chat-header {
  padding: 1rem;
  border-bottom: 1px solid #2d1846;
  background: #1a1124;
  box-shadow: 0 2px 8px rgba(162,89,255,0.04);
}
.chat-header h1 {
  margin: 0;
  font-size: 1.5rem;
  color: #a259ff;
  letter-spacing: 1px;
}
.chat-area {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}
.message {
  max-width: 70%;
  padding: 1rem 1.2rem;
  border-radius: 1.2rem;
  font-size: 1rem;
  line-height: 1.5;
  box-shadow: 0 2px 12px rgba(162,89,255,0.08);
  word-break: break-word;
  margin-bottom: 0.2rem;
}
.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #a259ff 60%, #4f8cff 100%);
  color: #fff;
  border-bottom-right-radius: 0.3rem;
  border-top-right-radius: 1.2rem;
  border-top-left-radius: 1.2rem;
  border-bottom-left-radius: 1.2rem;
}
.message.bot {
  align-self: flex-start;
  background: #23163a;
  color: #e0d7ff;
  border-bottom-left-radius: 0.3rem;
  border-top-right-radius: 1.2rem;
  border-top-left-radius: 1.2rem;
  border-bottom-right-radius: 1.2rem;
}
#chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid #2d1846;
  background: #1a1124;
}
#user-input {
  flex: 1;
  resize: none;
  border-radius: 0.7rem;
  border: 1px solid #a259ff;
  background: #23163a;
  color: #e0d7ff;
  padding: 0.7rem;
  font-size: 1rem;
  outline: none;
  min-height: 2.2rem;
  max-height: 200px;
  transition: border 0.2s, background 0.2s;
  overflow-y: hidden;
}
#user-input:focus {
  border: 1.5px solid #4f8cff;
  background: #2d1846;
}
#chat-form button {
  background: linear-gradient(135deg, #a259ff 60%, #4f8cff 100%);
  color: #fff;
  border: none;
  border-radius: 0.7rem;
  padding: 0 1.5rem;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(162,89,255,0.15);
}
#chat-form button:hover {
  background: linear-gradient(135deg, #4f8cff 60%, #a259ff 100%);
  box-shadow: 0 4px 16px rgba(162,89,255,0.25);
}
