body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  line-height: 1.6;
  color: #d1d5db;
  background-color: #343541;
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
}

/* Main layout */
.container-fluid {
  padding: 0;
  height: 100vh;
  overflow: hidden;
}

/* Main content layout */
/* Message styles */
.message {
  display: flex;
  flex-direction: column;
  max-width: 100%;
}

.message-user {
  align-items: flex-end;
}

.message-ai {
  align-items: flex-start;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  max-width: 80%;
  word-wrap: break-word;
  position: relative;
}

.message-user .message-bubble {
  background-color: #10a37f;
  color: white;
}

.message-ai .message-bubble {
  background-color: #444654;
  color: #131313;
}

.message-bubble p {
  margin: 0 0 10px 0;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

/* Image rendering in chat */
.message-bubble img {
  max-width: 100%;
  border-radius: 6px;
  margin: 10px 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Text-to-speech button styles */
.text-to-speech-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background-color: rgba(240, 240, 240, 0.8);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  opacity: 0.7;
  transition: opacity 0.2s, background-color 0.2s;
}

.text-to-speech-btn:hover {
  opacity: 1;
  background-color: rgba(220, 220, 220, 0.9);
}

.message-ai .text-to-speech-btn {
  background-color: rgba(220, 240, 255, 0.8);
}

.message-ai .text-to-speech-btn:hover {
  background-color: rgba(200, 230, 255, 0.9);
}

/* Thinking toggle and content styles */
.thinking-toggle {
  margin-bottom: 12px;
  position: relative;
}

.thinking-content {
  margin-top: 8px;
  margin-bottom: 16px;
  animation: fadeIn 0.3s ease-in-out;
}

.thinking-box {
  background-color: rgba(16, 163, 127, 0.1);
  border-left: 3px solid #10a37f;
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
  font-style: italic;
  color: #d1d5db;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Message meta information */
.message-meta {
  font-size: 0.8rem;
  margin-top: 4px;
  opacity: 0.7;
  padding: 0 8px;
}

/* Main content area */
.main-content {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Chat area */
.chat-area {
  display: flex;
  flex-direction: column;
  height: 100%;
  flex: 1;
  background-color: #343541;
  position: relative;
}

.full-width {
  width: 100%;
}

/* Chat header */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background-color: #444654;
  border-bottom: 1px solid #565869;
  z-index: 10;
}

.chat-title {
  font-weight: bold;
  font-size: 1.2rem;
}

.level-selector-top {
  display: flex;
  align-items: center;
}

/* Chat container */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Input area */
.input-area {
  padding: 16px;
  background-color: #444654;
  border-top: 1px solid #565869;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-area textarea {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #565869;
  background-color: #40414f;
  color: #d1d5db;
  resize: none;
  outline: none;
  transition: border-color 0.3s;
}

.input-area textarea:focus {
  border-color: #10a37f;
}

.input-controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Button styles */
.btn-primary {
  background-color: #10a37f;
  border-color: #10a37f;
}

.btn-primary:hover {
  background-color: #0d8c6d;
  border-color: #0d8c6d;
}

/* Gallery styles */
#galleryArea {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #343541;
  z-index: 1000;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s ease-in-out;
}

#galleryArea.visible {
  transform: translateY(0);
}

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #565869;
}

.gallery-close-btn {
  background: none;
  border: none;
  color: #d1d5db;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.gallery-close-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.gallery-card {
  background-color: #444654;
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid #565869;
}

.gallery-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.card-header {
  padding: 12px;
  background-color: #40414f;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #565869;
}

.card-body {
  padding: 12px;
  flex: 1;
  cursor: pointer;
}

.explanation-preview {
  color: #d1d5db;
  font-size: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-footer {
  padding: 12px;
  background-color: #40414f;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: #a0a0a0;
  border-top: 1px solid #565869;
}

.card-actions {
  display: flex;
  gap: 8px;
}

/* Gallery count badge */
.gallery-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: #10a37f;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.7rem;
  margin-left: 5px;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background-color: #444654;
  color: #d1d5db;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  animation: slideIn 0.3s ease-out, fadeOut 0.3s ease-in 2.7s forwards;
  max-width: 300px;
  pointer-events: auto;
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast-success {
  border-left: 4px solid #10a37f;
}

.toast-error {
  border-left: 4px solid #e53e3e;
}

.toast-info {
  border-left: 4px solid #3182ce;
}

.toast-fade-out {
  animation: fadeOut 0.3s ease-in forwards;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Error message styling */
.error {
  background-color: rgba(229, 62, 62, 0.1);
  border-left: 3px solid #e53e3e;
}

/* Loading spinner */
.spinner-border {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  vertical-align: text-bottom;
  border: 0.2em solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spinner-border 0.75s linear infinite;
}

@keyframes spinner-border {
  to { transform: rotate(360deg); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .message-bubble {
    max-width: 90%;
  }
  
  .gallery-grid {
    grid-template-columns: 1fr;
  }
}

/* Image container styles */
.image-container {
  margin: 10px 0;
  border-radius: 8px;
  overflow: hidden;
  max-width: 100%;
}

.image-caption {
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px;
  font-size: 0.9rem;
  text-align: center;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #40414f;
}

::-webkit-scrollbar-thumb {
  background-color: #565869;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: #676a7e;
}