:root {
  --bg-primary: #212121;
  --bg-secondary: #171717;
  --bg-tertiary: #2f2f2f;
  --bg-user-msg: #2f2f2f;
  --text-primary: #ececec;
  --text-secondary: #b4b4b4;
  --border-color: #383838;
  --accent-color: #10a37f;
  --hover-color: #212121;
  --sidebar-width: 260px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  transition: transform 0.2s ease;
  z-index: 100;
}

.sidebar-header {
  padding: 12px;
  display: flex;
  gap: 8px;
}

.btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s ease;
}

.btn:hover {
  background-color: var(--hover-color);
}

.btn-new-chat {
  flex: 1;
  justify-content: flex-start;
}

.btn-icon {
  padding: 8px;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item:hover, .chat-item.active {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.chat-item .chat-title {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chat-item .delete-btn {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 4px;
}

.chat-item:hover .delete-btn {
  opacity: 1;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-color);
}

.btn-footer {
  width: 100%;
  justify-content: flex-start;
  color: var(--text-secondary);
  border: none;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

.top-bar {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  gap: 12px;
}

.model-select {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.welcome-screen {
  max-width: 680px;
  width: 100%;
  margin: auto;
  text-align: center;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.avatar-logo {
  font-size: 48px;
  margin-bottom: 12px;
}

.welcome-screen h1 {
  font-size: 32px;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-secondary);
  margin-bottom: 32px;
  font-size: 14px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  width: 100%;
}

.prompt-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.15s ease;
}

.prompt-card:hover {
  background: var(--bg-tertiary);
}

.card-title {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 14px;
}

.card-sub {
  color: var(--text-secondary);
  font-size: 12px;
}

/* Messages */
.messages {
  width: 100%;
  max-width: 768px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 16px;
}

.message-row {
  display: flex;
  gap: 16px;
  width: 100%;
}

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

.message-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.user .message-bubble {
  background-color: var(--bg-user-msg);
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
}

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

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

.assistant .message-bubble {
  background-color: transparent;
  color: var(--text-primary);
  padding: 4px 0;
}

.cursor {
  display: inline-block;
  width: 8px;
  height: 15px;
  background-color: var(--text-primary);
  margin-left: 2px;
  animation: blink 1s infinite;
  vertical-align: middle;
}

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

.thinking-indicator {
  color: var(--text-secondary);
  font-style: italic;
  font-size: 14px;
}

/* Input Area */
.input-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px;
  position: relative;
}

.input-container {
  width: 100%;
  max-width: 768px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.btn-stop {
  position: absolute;
  top: -44px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
}

.btn-stop.hidden {
  display: none;
}

.chat-form {
  width: 100%;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  display: flex;
  align-items: flex-end;
  padding: 8px 12px;
  gap: 8px;
}

.chat-form textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  resize: none;
  max-height: 200px;
  outline: none;
  padding: 6px 4px;
}

.btn-send {
  background-color: var(--text-primary);
  color: var(--bg-primary);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
  flex-shrink: 0;
}

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

.disclaimer {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
}

.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .mobile-only {
    display: flex;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
}
