#ast-chat-root {
  max-width: 800px;
  margin: 0 auto;
  border: 1px solid #e1e5e9;
  border-radius: 16px;
  background: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  display: flex;
  flex-direction: column;
  height: 600px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.ast-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #fafbfc;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ast-bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 20px;
  word-wrap: break-word;
  line-height: 1.4;
  font-size: 15px;
  animation: slideIn 0.3s ease-out;
  position: relative;
}

.ast-bubble-user {
  background: linear-gradient(135deg, #007AFF 0%, #0056CC 100%);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.ast-bubble-assistant {
  background: #ffffff;
  color: #1d1d1f;
  align-self: flex-start;
  border: 1px solid #e1e5e9;
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ast-bubble-system {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
  align-self: center;
  text-align: center;
  font-size: 14px;
  border-radius: 12px;
  max-width: 90%;
}

.ast-input {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: #ffffff;
  border-top: 1px solid #e1e5e9;
}

.ast-input input,
.ast-input textarea {
  flex: 1;
  padding: 12px 20px;
  border: 2px solid #e1e5e9;
  border-radius: 25px;
  outline: none;
  font-size: 15px;
  background: #f8f9fa;
  transition: all 0.2s ease;
  font-family: inherit;
  resize: none;
}

.ast-input input:focus,
.ast-input textarea:focus {
  border-color: #007AFF;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.ast-input button {
  padding: 12px 24px;
  background: linear-gradient(135deg, #007AFF 0%, #0056CC 100%);
  color: white;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.ast-input button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
}

.ast-input button:active {
  transform: translateY(0);
}

.ast-input button:disabled {
  background: #8e8e93;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.ast-loading {
  display: inline-block;
  animation: pulse 1.5s ease-in-out infinite;
}

/* Loading button state */
.ast-btn-loading {
  position: relative;
}
.ast-btn-loading::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border: 2px solid rgba(255,255,255,0.6);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes restorePulse {
  0% { 
    opacity: 0.3; 
    transform: scale(0.95); 
  }
  50% { 
    opacity: 0.8; 
    transform: scale(1.02); 
  }
  100% { 
    opacity: 0.3; 
    transform: scale(0.95); 
  }
}

.ast-bubble-visible {
  animation: popupBounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.ast-bubble-popup {
  animation: popupBounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  opacity: 0;
  transform: scale(0.3) translateY(20px);
}

.ast-bubble-popup.ast-bubble-popup {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.ast-restore-loading {
  animation: restorePulse 1.5s ease-in-out infinite;
  background: linear-gradient(45deg, #f0f8ff, #e6f3ff);
  border-left: 4px solid #007cba;
}

@keyframes slideIn {
  from { 
    opacity: 0; 
    transform: translateY(20px) scale(0.95); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0) scale(1); 
  }
}

@keyframes popupIn {
  from { 
    opacity: 0; 
    transform: scale(0.8) translateY(10px); 
  }
  to { 
    opacity: 1; 
    transform: scale(1) translateY(0); 
  }
}

@keyframes popupBounce {
  0% { 
    opacity: 0; 
    transform: scale(0.3) translateY(20px); 
  }
  50% { 
    opacity: 0.8; 
    transform: scale(1.05) translateY(-5px); 
  }
  100% { 
    opacity: 1; 
    transform: scale(1) translateY(0); 
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Scrollbar styling */
.ast-messages::-webkit-scrollbar {
  width: 6px;
}

.ast-messages::-webkit-scrollbar-track {
  background: transparent;
}

.ast-messages::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.ast-messages::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Options styling */
.ast-options-container {
  background: #ffffff;
  border: 1px solid #e1e5e9;
  border-radius: 12px;
  padding: 20px;
  margin: 16px 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  animation: popupIn 0.4s ease-out;
}

.ast-options-title {
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 16px;
  font-size: 16px;
}

.ast-options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.ast-option-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: #f8f9fa;
  border: 2px solid #e1e5e9;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.ast-option-item:hover {
  background: #e3f2fd;
  border-color: #007AFF;
}

.ast-option-item input[type="checkbox"] {
  margin-right: 12px;
  width: 18px;
  height: 18px;
  accent-color: #007AFF;
}

.ast-option-item input[type="checkbox"]:checked + .ast-option-text {
  color: #007AFF;
  font-weight: 600;
}

.ast-option-item:has(input[type="checkbox"]:checked) {
  background: #e3f2fd;
  border-color: #007AFF;
}

.ast-option-text {
  flex: 1;
  font-size: 15px;
  color: #1d1d1f;
  transition: all 0.2s ease;
}

.ast-option-button {
  width: 100%;
  padding: 12px 16px;
  background: #f8f9fa;
  border: 2px solid #e1e5e9;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  color: #1d1d1f;
  transition: all 0.2s ease;
  text-align: left;
}

.ast-option-button:hover {
  background: #e3f2fd;
  border-color: #007AFF;
  color: #007AFF;
}

.ast-option-button:active {
  transform: translateY(1px);
}

.ast-options-actions {
  display: flex;
  justify-content: center;
  padding-top: 16px;
  border-top: 1px solid #e1e5e9;
}

.ast-submit-options {
  padding: 12px 24px;
  background: linear-gradient(135deg, #007AFF 0%, #0056CC 100%);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.ast-submit-options:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.4);
}

.ast-submit-options:disabled {
  background: #8e8e93;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Actions (Retry / Reconnect) */
.ast-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  animation: popupIn 0.4s ease-out;
}
.ast-action-button {
  padding: 10px 16px;
  border-radius: 8px;
  border: 2px solid #e1e5e9;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  animation: popupBounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.ast-action-button:hover {
  background: #e3f2fd;
  border-color: #007AFF;
  color: #007AFF;
  transform: scale(1.05);
}

/* Network Notifications */
.ast-network-notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  max-width: 400px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  animation: popupBounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  border-left: 4px solid #007AFF;
}

.ast-notification-content {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
}

.ast-notification-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.ast-notification-text {
  flex: 1;
  font-size: 14px;
  color: #1d1d1f;
  line-height: 1.4;
}

.ast-notification-close {
  background: none;
  border: none;
  font-size: 18px;
  color: #8e8e93;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.ast-notification-close:hover {
  background: #f0f0f0;
  color: #1d1d1f;
}

.ast-notification-success {
  border-left-color: #34c759;
}

.ast-notification-error {
  border-left-color: #ff3b30;
}

.ast-notification-info {
  border-left-color: #007AFF;
}

/* Long Wait Overlay */
.ast-long-wait-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ast-long-wait-overlay.ast-long-wait-visible {
  opacity: 1;
}

.ast-long-wait-content {
  background: #ffffff;
  border-radius: 16px;
  padding: 2rem;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.ast-long-wait-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e5e7eb;
  border-top-color: #007AFF;
  border-radius: 50%;
  margin: 0 auto 1.5rem;
  animation: spin 1s linear infinite;
}

.ast-long-wait-content h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #111827;
}

.ast-long-wait-content p {
  margin: 0.5rem 0;
  color: #6b7280;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.ast-long-wait-hint {
  font-size: 0.875rem !important;
  color: #9ca3af !important;
  margin-top: 1rem !important;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Top Controls */
.ast-top-controls {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: #ffffff;
  border-bottom: 1px solid #e1e5e9;
  flex-wrap: wrap;
  align-items: center;
}

.ast-top-control-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  background: #ffffff;
  border: 1px solid #e1e5e9;
  border-radius: 8px;
  color: #374151;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.ast-top-control-btn:hover {
  background: #f9fafb;
  border-color: #007AFF;
  color: #007AFF;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 122, 255, 0.1);
}

.ast-top-control-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 122, 255, 0.1);
}

.ast-top-control-btn svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.ast-top-control-btn span {
  white-space: nowrap;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  #ast-chat-root {
    height: 500px;
    margin: 10px;
    border-radius: 12px;
  }
  
  .ast-bubble {
    max-width: 85%;
    font-size: 14px;
  }
  
  .ast-input {
    padding: 12px 16px;
  }
  
  .ast-input input,
  .ast-input textarea {
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  .ast-options-container {
    margin: 12px 0;
    padding: 16px;
  }
  
  .ast-option-item {
    padding: 10px 12px;
  }
  
  .ast-option-button {
    padding: 10px 12px;
  }
}