:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #252540;
  --accent-pink: #ff6b9d;
  --accent-purple: #9d4edd;
  --accent-gradient: linear-gradient(135deg, #ff6b9d 0%, #ff8a5b 100%);
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --code-bg: #2d2d3a;
  --border-color: rgba(255, 255, 255, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  background: radial-gradient(ellipse at top, #1a1a3a 0%, var(--bg-primary) 50%);
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: rgba(15, 15, 26, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
}

.header-left h1 {
  font-size: 1.25rem;
  font-weight: 600;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-right {
  display: flex;
  gap: 0.5rem;
}

.icon-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  transform: scale(1.05);
}

.header-gradient {
  height: 3px;
  background: var(--accent-gradient);
}

/* Chat Container */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  scroll-behavior: smooth;
}

.chat-container::-webkit-scrollbar {
  width: 6px;
}

.chat-container::-webkit-scrollbar-track {
  background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

/* Messages */
.messages-list {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

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

.message.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.message-header {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  padding: 0 0.5rem;
}

.message-bubble {
  padding: 1rem 1.25rem;
  border-radius: 16px;
  line-height: 1.6;
  word-break: break-word;
}

.message.user .message-bubble {
  background: linear-gradient(135deg, var(--accent-purple) 0%, #7b2cbf 100%);
  border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

.message-text {
  font-size: 0.95rem;
}

.message-text h1, .message-text h2, .message-text h3 {
  color: var(--accent-pink);
}

.message-text code.inline-code {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
}

/* HTML Code Blocks */
.html-code-block {
  margin: 1rem 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--code-bg);
  border: 1px solid var(--border-color);
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--border-color);
}

.lang-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.launch-btn {
  background: var(--accent-gradient);
  border: none;
  color: white;
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Space Grotesk', sans-serif;
}

.launch-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 20px rgba(255, 107, 157, 0.4);
}

.code-content {
  padding: 1rem;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #e0e0e0;
}

.code-content code {
  white-space: pre-wrap;
}

/* Typing Indicator */
.typing-bubble {
  padding: 1rem 1.5rem;
}

.typing-indicator {
  display: flex;
  gap: 4px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--accent-pink);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 2rem;
}

.pig-mascot {
  margin-bottom: 1.5rem;
}

.pig-mascot img {
  width: 100px;
  height: auto;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.empty-state h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.empty-state p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.suggestions button {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.75rem 1.25rem;
  border-radius: 24px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Space Grotesk', sans-serif;
}

.suggestions button:hover {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  transform: translateY(-2px);
}

/* Input Area */
.input-area {
  padding: 1rem 1.5rem;
  background: rgba(15, 15, 26, 0.98);
  border-top: 1px solid var(--border-color);
}

.input-container {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.input-container textarea {
  flex: 1;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  color: var(--text-primary);
  padding: 1rem 1.25rem;
  border-radius: 16px;
  font-size: 1rem;
  font-family: 'Space Grotesk', sans-serif;
  resize: none;
  min-height: 52px;
  max-height: 200px;
  transition: border-color 0.2s ease;
}

.input-container textarea:focus {
  outline: none;
  border-color: var(--accent-purple);
  box-shadow: 0 0 20px rgba(157, 78, 221, 0.2);
}

.input-container textarea::placeholder {
  color: var(--text-secondary);
}

.send-btn {
  background: var(--accent-gradient);
  border: none;
  color: white;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 20px rgba(255, 107, 157, 0.4);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

/* Footer */
.app-footer {
  padding: 0.5rem;
  text-align: center;
}

.app-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.75rem;
  transition: color 0.2s ease;
}

.app-footer a:hover {
  color: var(--accent-pink);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

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

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 450px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.2s ease;
  line-height: 1;
}

.close-btn:hover {
  color: var(--accent-pink);
}

.modal-body {
  padding: 1.5rem;
}

.toggle-group {
  margin-bottom: 1.5rem;
}

.toggle-group label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.toggle-buttons {
  display: flex;
  gap: 0.5rem;
}

.toggle-btn {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Space Grotesk', sans-serif;
}

.toggle-btn.active {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  color: white;
}

.toggle-btn:hover:not(.active) {
  border-color: var(--accent-purple);
}

.config-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.config-section label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: -0.5rem;
}

.config-section input,
.config-section select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: 'Space Grotesk', sans-serif;
  transition: border-color 0.2s ease;
}

.config-section input:focus,
.config-section select:focus {
  outline: none;
  border-color: var(--accent-purple);
}

.config-section select {
  cursor: pointer;
}

.info-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: rgba(157, 78, 221, 0.1);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border-left: 3px solid var(--accent-purple);
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
}

.save-btn {
  width: 100%;
  background: var(--accent-gradient);
  border: none;
  color: white;
  padding: 0.9rem;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Space Grotesk', sans-serif;
}

.save-btn:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 20px rgba(255, 107, 157, 0.4);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-gradient);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 1001;
  animation: toastIn 0.3s ease;
  box-shadow: 0 4px 20px rgba(255, 107, 157, 0.4);
}

@keyframes toastIn {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* Responsive */
@media (max-width: 640px) {
  .app-header {
    padding: 0.75rem 1rem;
  }

  .chat-container {
    padding: 1rem;
  }

  .message {
    max-width: 95%;
  }

  .suggestions {
    flex-direction: column;
  }

  .suggestions button {
    width: 100%;
  }

  .input-area {
    padding: 0.75rem 1rem;
  }

  .input-hint {
    display: none;
  }
}