:root {
  --bg: #0d1117;
  --card: #161b22;
  --user: #1f6feb;
  --ai: #238636;
  --text: #e6edf3;
  --border: #30363d;
}

body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.chat-wrapper {
  width: 95vw;
  max-width: 1200px;
  height: 90vh;
  display: flex;
  flex-direction: row;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

header {
  text-align: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 1.2rem;
  background: #0b0f14;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

#log {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: fadeIn 0.25s ease;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.bubble {
  padding: 12px 16px;
  border-radius: 14px;
  max-width: 75%;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.user .bubble {
  background: var(--user);
  color: #fff;
  border-bottom-right-radius: 4px;
  margin-left: auto;
}

.assistant .bubble {
  background: var(--ai);
  color: #fff;
  border-bottom-left-radius: 4px;
  margin-right: auto;
}

pre code {
  background: #0b0f14 !important;
  padding: 10px;
  border-radius: 8px;
  display: block;
  overflow-x: auto;
  font-size: 0.9rem;
}

#controls {
  display: flex;
  padding: 16px;
  gap: 8px;
  border-top: 1px solid var(--border);
  background: #0b0f14;
}

textarea {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 1rem;
  resize: none;
  background: #161b22;
  color: var(--text);
}

button {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  color: white;
  font-weight: 500;
  transition: all 0.2s;
}

#send {
  background: var(--user);
}

#clear {
  background: #dc2626;
}

button:hover {
  opacity: 0.9;
}

.buttons {
  display: flex;
  flex-direction: column;
  row-gap: 8px;
}

.sidebar {
  width: 250px;
  background: #0b0f14;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px;
  overflow-y: auto;
}

.new-chat-btn {
  background: var(--ai);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
}

.new-chat-btn:hover {
  opacity: 0.9;
}

.chat-item {
  padding: 10px;
  background: var(--card);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.chat-item.active {
  background: var(--user);
}

.chat-item:hover:not(.active) {
  background: #21262d;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
  .chat-wrapper {
    flex-direction: column;
    height: 95vh;
    width: 98vw;
  }

  .sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 30vh;
  }

  .main-content {
    height: auto;
    flex: 2;
  }

  #log {
    padding: 12px;
  }

  .bubble {
    max-width: 85%;
  }

  textarea {
    font-size: 1rem;
    padding: 10px;
  }

  header {
    font-size: 1.1rem;
    padding: 12px;
  }

  .buttons {
    flex-direction: row;
    gap: 8px;
  }

  #controls {
    flex-direction: column;
    padding: 12px;
  }

  #controls textarea,
  #controls .buttons {
    width: 100%;
  }
}