* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --primary-active: #4338ca;
  --background: #0a0a0a;
  --surface: #141414;
  --surface-hover: #1a1a1a;
  --border: #262626;
  --text-primary: #ffffff;
  --text-secondary: #a3a3a3;
  --error: #ef4444;
  --success: #10b981;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--background);
}

#controls {
  position: absolute;
  top: 24px;
  left: 24px;
  display: flex;
  gap: 12px;
  padding: 16px;
  background: rgba(20, 20, 20, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

#chatId {
  width: 200px;
  height: 40px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

#chatId::placeholder {
  color: var(--text-secondary);
  font-weight: 400;
}

#chatId:hover {
  background-color: var(--surface-hover);
  border-color: #363636;
}

#chatId:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#chatId:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#loadBtn {
  height: 40px;
  padding: 0 24px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  background-color: var(--primary-color);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  outline: none;
  transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

#loadBtn:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

#loadBtn:active {
  background-color: var(--primary-active);
  transform: translateY(0);
}

#loadBtn:disabled {
  background-color: #4b5563;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#loadingOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 300ms ease;
}

#loadingOverlay.active {
  opacity: 1;
  visibility: visible;
}

.loading-container {
  text-align: center;
}

.loading-text {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.loading-bar {
  width: 300px;
  height: 4px;
  background: var(--surface);
  border-radius: 2px;
  overflow: hidden;
}

.loading-progress {
  height: 100%;
  background: var(--primary-color);
  transition: width 300ms ease;
  border-radius: 2px;
}

.error-message {
  position: fixed;
  top: 24px;
  right: 24px;
  min-width: 300px;
  padding: 16px 20px;
  background-color: var(--error);
  color: white;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  animation: slideIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes slideIn {
  from {
    transform: translateX(calc(100% + 24px));
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@media (max-width: 640px) {
  #controls {
    top: 16px;
    left: 16px;
    right: 16px;
    flex-direction: column;
    gap: 8px;
  }
  
  #chatId {
    width: 100%;
  }
  
  #loadBtn {
    width: 100%;
  }
}

:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}