* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background-color: #000000;
  color: #e0e0e0;
  height: 100vh;
  display: flex;
  overflow: hidden;
}

.app-container {
  display: flex;
  flex: 1;
  height: 100%;
}

.sidebar {
  width: 260px;
  background: #2a2a2a;
  border-right: 2px solid #404040;
  display: flex;
  flex-direction: column;
  padding: 15px;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.sidebar-btn {
  background: #404040;
  color: #e0e0e0;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.sidebar-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.session-list {
  list-style: none;
  margin-bottom: 15px;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  background: #404040;
  color: #e0e0e0;
  transition: all 0.2s ease;
}

.session-item:hover {
  background: #505050;
  transform: translateY(-1px);
}

.session-item.active {
  background: #606060;
  font-weight: bold;
}

.session-title {
  flex: 1;
  margin-right: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: inherit;
}

.session-edit-btn,
.session-delete-btn {
  background: transparent;
  border: none;
  color: #b0b0b0;
  cursor: pointer;
  font-size: 16px;
  margin-left: 6px;
  transition: transform 0.2s ease;
}

.session-edit-btn:hover,
.session-delete-btn:hover {
  transform: scale(1.2);
  color: #e0e0e0;
}

.sidebar-label {
  margin-top: 12px;
  display: block;
  font-weight: bold;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: #e0e0e0;
}

.sidebar-select {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #505050;
  margin-bottom: 12px;
  background-color: #333333;
  color: #e0e0e0;
}

.divider {
  border: none;
  border-bottom: 1px solid #505050;
  margin: 15px 0;
}

.chat-layout {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

.chat-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  background: #000000;
  color: #e0e0e0;
}

.chat-box {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.chat-input-container {
  display: flex;
  padding: 12px 15px;
  background: #2a2a2a;
  align-items: center;
}

#chat-input {
  flex-grow: 1;
  background: #333333;
  color: #e0e0e0;
  border: 1px solid #505050;
  border-radius: 20px;
  font-size: 14px;
  padding: 12px 15px;
  resize: none;
  overflow-y: auto;
  min-height: 50px;
  max-height: 120px;
  transition: box-shadow 0.2s ease;
}

#chat-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(80,80,80,0.3);
}

.input-buttons-container {
  display: flex;
  gap: 8px;
  margin-left: 10px;
}

#voice-input-btn, #send-button {
  background: #404040;
  border: none;
  border-radius: 50%;
  color: #e0e0e0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

#voice-input-btn:hover, #send-button:hover {
  transform: scale(1.05);
  background: #505050;
}

#send-button:disabled {
  background: #606060;
  cursor: not-allowed;
  opacity: 0.6;
}

.chat-controls {
  display: flex;
  justify-content: space-between;
  padding: 10px 15px;
  background: #2a2a2a;
  border-top: 1px solid #505050;
}

.control-btn {
  background: #404040;
  border: none;
  padding: 8px 14px;
  border-radius: 20px;
  color: #e0e0e0;
  cursor: pointer;
  margin-left: 10px;
  transition: all 0.2s ease;
}

.control-btn:hover {
  background: #505050;
  transform: translateY(-1px);
}

.message {
  margin: 12px 0;
  padding: 12px 16px;
  border-radius: 18px;
  animation: fadeIn 0.3s ease;
  word-break: break-word;
  clear: both;
  max-width: 70%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.user-message {
  background-color: #404040;
  color: #e0e0e0;
  float: right;
  border-bottom-right-radius: 6px;
}

.ai-message {
  background-color: #505050;
  color: #e0e0e0;
  float: left;
  border-bottom-left-radius: 6px;
}

.message-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.message-action-btn {
  background: #606060;
  border: none;
  border-radius: 15px;
  padding: 5px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #e0e0e0;
}

.message-action-btn:hover {
  background: #707070;
}

.speak-message-btn {
  display: flex;
  align-items: center;
  gap: 4px;
}

.speak-message-btn .icon {
  font-size: 14px;
}

.message img {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 10px;
}

.ai-image-container {
  position: relative;
  margin: 10px 0;
  max-width: 100%;
  border-radius: 8px;
  overflow: hidden;
}

.ai-image-loading {
  background-color: rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  border-radius: 8px;
}

.loading-spinner {
  border: 4px solid rgba(0,0,0,0.1);
  border-radius: 50%;
  border-top: 4px solid #b0b0b0;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.image-button-container {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
  z-index: 10;
}

.image-button {
  background: #606060;
  border: none;
  border-radius: 15px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #e0e0e0;
}

.image-button:hover {
  background: #707070;
}

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-container {
  background: #2a2a2a;
  border-radius: 12px;
  padding: 20px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  color: #e0e0e0;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #505050;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: bold;
  margin: 0;
  color: #e0e0e0;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #b0b0b0;
  transition: color 0.2s ease;
}

.close-btn:hover {
  color: #e0e0e0;
}

.modal-body {
  margin-bottom: 20px;
  color: #e0e0e0;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid #505050;
  padding-top: 15px;
}

.form-group {
  margin-bottom: 15px;
}

.form-label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
  color: #e0e0e0;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #505050;
  background-color: #333333;
  color: #e0e0e0;
  font-size: 14px;
}

.form-control:focus {
  outline: none;
  border-color: #707070;
  box-shadow: 0 0 0 2px rgba(112,112,112,0.2);
}

.voice-chat-modal {
  background: #2a2a2a;
  border-radius: 12px;
  padding: 20px;
  width: 90vw;
  max-width: 1200px;
  min-height: 80vh;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  color: #e0e0e0;
}

.voice-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  color: #e0e0e0;
}

.voice-chat-controls {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.voice-status {
  padding: 15px;
  border-radius: 10px;
  background: #404040;
  text-align: center;
  font-size: 1.1rem;
  color: #e0e0e0;
}

.voice-buttons {
  display: flex;
  justify-content: space-around;
  gap: 15px;
}

.voice-btn {
  padding: 12px 20px;
  border-radius: 25px;
  border: none;
  background: #404040;
  color: #e0e0e0;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.voice-btn:hover {
  background: #505050;
  transform: translateY(-2px);
}

.voice-btn:disabled {
  background: #606060;
  cursor: not-allowed;
  opacity: 0.6;
}

.voice-btn.listening {
  background: #d07070;
}

.transcript {
  padding: 15px;
  border-radius: 10px;
  background: #333333;
  min-height: 100px;
  margin-top: 15px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
  color: #e0e0e0;
}

.personalization-modal {
  max-width: 600px;
}

.personalization-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.code-block-container {
  margin: 12px 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #505050;
  background: #333333;
  width: 100%;
  max-width: 100%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #404040;
  border-bottom: 1px solid #505050;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: #e0e0e0;
}

.code-language {
  font-size: 0.8rem;
  color: #b0b0b0;
  text-transform: uppercase;
  font-weight: bold;
}

.copy-code-btn, .expand-code-btn {
  background: #505050;
  color: #e0e0e0;
  border: none;
  padding: 5px 10px;
  border-radius: 15px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s ease;
  margin-left: 8px;
}

.copy-code-btn:hover, .expand-code-btn:hover {
  background: #606060;
}

.code-block {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
  background: #282c34;
  color: #abb2bf;
  border-radius: 0 0 10px 10px;
}

.code-block code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  tab-size: 2;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}

.message pre {
  background: #282c34;
  color: #abb2bf;
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  margin: 12px 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.message code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-message {
  max-width: 70% !important;
}

.message-text {
  width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}

.ai-message .message-text,
.user-message .message-text {
  width: 100%;
  overflow-x: auto;
}

.first-launch-modal {
  max-width: 650px;
  text-align: center;
}

.welcome-heading {
  font-size: 1.8rem;
  margin-bottom: 15px;
  color: #b0b0b0;
}

.welcome-text {
  margin-bottom: 20px;
  line-height: 1.6;
  color: #e0e0e0;
}

.setup-options {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 25px;
}

.setup-btn {
  padding: 12px;
  border-radius: 8px;
  border: none;
  background: #404040;
  color: #e0e0e0;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  display: flex;
  align-items: center;
}

.setup-btn:hover {
  background: #505050;
  transform: translateY(-2px);
}

.setup-btn-icon {
  margin-right: 15px;
  font-size: 1.5rem;
  color: #b0b0b0;
}

.setup-btn-content {
  flex: 1;
}

.setup-btn-title {
  font-weight: bold;
  margin-bottom: 5px;
  color: #e0e0e0;
}

.setup-btn-desc {
  font-size: 0.85rem;
  color: #b0b0b0;
}

#toast-notification {
  position: fixed;
  top: 5%;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(60, 60, 60, 0.9);
  color: white;
  padding: 10px 20px;
  border-radius: 5px;
  z-index: 9999;
  transition: opacity 0.3s;
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: 200px;
    border-right: none;
    border-bottom: 2px solid #505050;
  }

  .message {
    max-width: 80% !important;
  }

  .modal-container {
    width: 95%;
  }
}

.hidden {
  display: none !important;
}

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.fw-bold { font-weight: bold; }
.fw-normal { font-weight: normal; }
.d-flex { display: flex; }
.justify-content-between { justify-content: space-between; }
.justify-content-center { justify-content: center; }
.align-items-center { align-items: center; }
.flex-column { flex-direction: column; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }

.screensaver {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #000000;
  z-index: 9999;
  overflow: hidden;
}

.screensaver img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 0;
  transition: opacity var(--transition-duration, 1s) ease;
}

.screensaver-thumbnails {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 12px;
  overflow-x: auto;
  width: 100%;
  height: 120px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 0;
  z-index: 2;
  transition: opacity 0.3s ease;
  scrollbar-width: thin;
  scrollbar-color: #707070 #333333;
  white-space: nowrap;
  direction: ltr;
  scroll-behavior: smooth;
}

.screensaver-thumbnails::-webkit-scrollbar {
  height: 8px;
}

.screensaver-thumbnails::-webkit-scrollbar-track {
  background: #333333;
  border-radius: 4px;
}

.screensaver-thumbnails::-webkit-scrollbar-thumb {
  background: #707070;
  border-radius: 4px;
}

.screensaver-thumbnails img.thumbnail {
  width: 160px;
  height: 90px;
  object-fit: cover;
  cursor: pointer;
  border: 3px solid transparent;
  border-radius: 8px;
  transition: border 0.3s, transform 0.2s;
  flex-shrink: 0;
  display: inline-block;
  opacity: 1;
}

.screensaver-thumbnails img.thumbnail:hover {
  border: 3px solid #00ffcc;
  transform: scale(1.05);
}

.screensaver-thumbnails img.thumbnail.selected {
  border: 3px solid #ffcc00;
}

.screensaver-controls {
  position: fixed;
  bottom: 140px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, rgba(30, 30, 30, 0.9), rgba(50, 50, 50, 0.9));
  padding: 20px;
  border-radius: 16px;
  width: 90%;
  max-width: 900px;
  z-index: 2;
  transition: opacity 0.3s ease, transform 0.3s ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  border: 1px solid #00ffcc;
}

.screensaver-controls:hover {
  transform: translateX(-50%) scale(1.02);
}

.screensaver:not(:hover) .screensaver-controls,
.screensaver:not(:hover) .screensaver-thumbnails {
  opacity: 0.5;
}

.screensaver-controls.hidden-panel,
.screensaver-thumbnails.hidden-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(20px);
}

.screensaver-settings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
  margin-bottom: 15px;
}

.screensaver-settings label {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
  color: #e0e0e0;
}

.screensaver-settings label[for="screensaver-prompt"] {
  grid-column: 1 / -1;
}

.screensaver-settings textarea,
.screensaver-settings input,
.screensaver-settings select {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #707070;
  background-color: #333333;
  color: #e0e0e0;
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.screensaver-settings textarea:focus,
.screensaver-settings input:focus,
.screensaver-settings select:focus {
  border-color: #00ffcc;
  box-shadow: 0 0 5px rgba(0, 255, 204, 0.3);
  outline: none;
}

.screensaver-settings textarea {
  min-height: 80px;
  resize: vertical;
}

.screensaver-btn-group {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.screensaver-btn {
  background: linear-gradient(135deg, #404040, #505050);
  color: #e0e0e0;
  border: none;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.screensaver-btn:hover {
  background: linear-gradient(135deg, #505050, #606060);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 255, 204, 0.2);
}

.screensaver-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.screensaver canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  pointer-events: none;
}