#settings-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

#settings-panel {
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  background: var(--bg-secondary);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  overflow: hidden;
}

#settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-tertiary);
}

#settings-header h1 {
  font-size: 22px;
  font-weight: 600;
}

#settings-close {
  width: 40px;
  height: 40px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
}

#settings-close:hover {
  background: var(--border);
  color: var(--text-primary);
}

#settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.settings-section {
  margin-bottom: 32px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.setting-item {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-item.full-width {
  width: 100%;
}

.setting-item label {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.setting-item input[type="text"],
.setting-item input[type="password"],
.setting-item select,
.setting-item textarea {
  padding: 12px 16px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: 8px;
  font-size: 15px;
  border: 1px solid var(--border);
  transition: border-color 0.2s ease;
}

.setting-item input:focus,
.setting-item select:focus,
.setting-item textarea:focus {
  border-color: var(--accent);
}

.setting-item textarea {
  resize: vertical;
  min-height: 80px;
}

.setting-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

.setting-item input[type="range"] {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  appearance: none;
  -webkit-appearance: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

.setting-item input[type="range"] + span {
  font-size: 14px;
  color: var(--text-secondary);
  margin-left: 12px;
}

.setting-item:has(input[type="range"]) {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
}

.setting-item:has(input[type="range"]) label {
  width: 100%;
}

.setting-item:has(input[type="checkbox"]) {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.provider-settings {
  margin-top: 12px;
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.provider-settings.hidden {
  display: none;
}

#settings-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

#settings-footer button {
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
}

@media (max-width: 600px) {
  #settings-overlay {
    padding: 0;
  }
  
  #settings-panel {
    max-height: 100vh;
    border-radius: 0;
  }
  
  .setting-item input[type="range"] {
    width: calc(100% - 50px);
  }
}

#chat-container {
  position: fixed;
  bottom: 80px;
  left: 20px;
  right: 20px;
  max-width: 600px;
  margin: 0 auto;
  max-height: 60vh;
  background: var(--bg-secondary);
  border-radius: 16px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 50;
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-message {
  display: flex;
  width: 100%;
}

.chat-message.user {
  justify-content: flex-end;
}

.chat-message.assistant {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--bg-tertiary);
}

.chat-message.user .message-bubble {
  background: var(--accent);
  border-bottom-right-radius: 4px;
}

.chat-message.assistant .message-bubble {
  border-bottom-left-radius: 4px;
}

.message-content {
  font-size: 15px;
  line-height: 1.4;
  word-wrap: break-word;
}

.chat-message.streaming .message-content {
  opacity: 0.9;
}

.chat-message.streaming .message-content::after {
  content: '|';
  animation: cursor-blink 1s infinite;
}

@keyframes cursor-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.message-time {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
  text-align: right;
}

.chat-message.user .message-time {
  color: rgba(255, 255, 255, 0.7);
}

#chat-input-container {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
}

#chat-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: 24px;
  font-size: 15px;
  border: 1px solid var(--border);
}

#chat-input:focus {
  border-color: var(--accent);
}

#chat-send {
  padding: 12px 20px;
  background: var(--accent);
  color: var(--text-primary);
  border-radius: 24px;
  font-weight: 500;
}

#chat-send:hover {
  background: var(--accent-hover);
}