:root {
  --primary: #1877f2;
  --primary-hover: #166fe5;
  --bg-color: #f0f2f5;
  --card-bg: #ffffff;
  --text-main: #050505;
  --text-muted: #65676b;
  --border-color: #e4e6eb;
  --success: #31a24c;
  --error: #fa383e;
}

* {
  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-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-container {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.logo-area h1 {
  font-size: 24px;
  font-weight: 700;
  color: #1c1e21;
}

.subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border-color);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #94a3b8;
}

.dot.connected {
  background-color: var(--success);
  box-shadow: 0 0 0 3px rgba(49, 162, 76, 0.2);
}

.dot.disconnected {
  background-color: #ef4444;
}

.card {
  background: var(--card-bg);
  padding: 20px 24px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
}

.card h2 {
  font-size: 18px;
  margin-bottom: 6px;
}

.card p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: background 0.15s ease;
}

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

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

.btn-secondary {
  background: #e4e6eb;
  color: #050505;
}

.btn-secondary:hover {
  background: #d8dadf;
}

.btn-send {
  background: var(--primary);
  color: white;
  gap: 6px;
  padding: 0 20px;
  height: 48px;
}

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

.btn-send:disabled {
  background: #bcc0c4;
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

.success-msg {
  color: var(--success) !important;
  font-weight: 600;
  margin-bottom: 8px !important;
}

.details-box {
  background: #f7f8fa;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  color: #334155;
  margin-bottom: 12px;
  border: 1px solid #edf0f2;
}

.chat-card {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 520px;
}

.chat-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-header h3 {
  font-size: 15px;
}

.model-select-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.model-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.model-dropdown {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  font-size: 12px;
  background: #f8fafc;
  color: #1e293b;
  font-weight: 500;
  outline: none;
}

.model-dropdown:focus {
  border-color: var(--primary);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

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

.message.bot {
  align-self: flex-start;
}

.message-content {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user .message-content {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.bot .message-content {
  background: #e4e6eb;
  color: #050505;
  border-bottom-left-radius: 4px;
}

.token-badge {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding-left: 6px;
  display: flex;
  gap: 8px;
}

.cache-saved {
  color: var(--success);
  font-weight: 600;
}

.chat-input-area {
  padding: 14px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

#chat-input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  height: 48px;
  outline: none;
}

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

.app-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.app-footer a {
  color: var(--text-muted);
  text-decoration: underline;
}
