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

:root {
  --bg: #0a0a0b;
  --surface: #141416;
  --surface-2: #1c1c20;
  --surface-3: #252529;
  --border: #2a2a30;
  --text: #e4e4e7;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --accent: #f97316;
  --accent-dim: rgba(249, 115, 22, 0.12);
  --radius: 12px;
}

body {
  font-family: 'Noto Sans SC', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #f97316, #fb923c);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
}

.header-title { font-size: 16px; font-weight: 600; }
.header-subtitle { font-size: 12px; color: var(--text-3); }

.settings-btn, .clear-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
  font-family: inherit;
}

.clear-btn { padding: 8px 10px; }
.settings-btn:hover, .clear-btn:hover { background: var(--surface-3); color: var(--text); }

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  background: #ef4444;
}
.status-dot.connected { background: #22c55e; }

.skill-bar {
  display: flex; gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  background: var(--surface);
}
.skill-bar::-webkit-scrollbar { display: none; }

.skill-chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  transition: all 0.2s;
  font-family: inherit;
}
.skill-chip:hover { border-color: var(--accent); color: var(--text); }
.skill-chip.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.chat-container::-webkit-scrollbar { width: 4px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }
.chat-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.welcome {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  flex: 1; gap: 20px;
  text-align: center; padding: 40px;
}

.welcome-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, #f97316, #fb923c);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 24px; color: #fff;
}
.welcome h2 { font-size: 22px; font-weight: 600; }
.welcome p { color: var(--text-2); font-size: 14px; max-width: 400px; line-height: 1.6; }

.welcome-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px; width: 100%; max-width: 600px; margin-top: 8px;
}

.welcome-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px; cursor: pointer;
  transition: all 0.2s; text-align: left;
}
.welcome-card:hover { border-color: var(--accent); background: var(--surface-3); }
.welcome-card .card-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.welcome-card .card-desc { font-size: 12px; color: var(--text-3); line-height: 1.4; }

.message {
  display: flex; gap: 12px;
  max-width: 800px; width: 100%; margin: 0 auto;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0; margin-top: 2px;
}
.message-avatar.user { background: var(--surface-3); }
.message-avatar.assistant {
  background: linear-gradient(135deg, #f97316, #fb923c);
  color: #fff; font-weight: 700; font-size: 12px;
}

.message-content { flex: 1; min-width: 0; }

.message-role {
  font-size: 12px; font-weight: 600;
  color: var(--text-3); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: 0.5px;
}

.message-body { font-size: 14px; line-height: 1.7; color: var(--text); }
.message-body p { margin-bottom: 8px; }
.message-body p:last-child { margin-bottom: 0; }
.message-body strong { font-weight: 600; color: #fff; }
.message-body h1, .message-body h2, .message-body h3 { margin: 16px 0 8px; font-weight: 600; color: #fff; }
.message-body h1 { font-size: 18px; }
.message-body h2 { font-size: 16px; }
.message-body h3 { font-size: 15px; }
.message-body ul, .message-body ol { margin: 8px 0; padding-left: 20px; }
.message-body li { margin-bottom: 4px; }

.message-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 16px; margin: 8px 0;
  background: var(--accent-dim);
  border-radius: 0 8px 8px 0;
}

.message-body code {
  background: var(--surface-3);
  padding: 2px 6px; border-radius: 4px;
  font-size: 13px; font-family: 'SF Mono', monospace;
}

.message-body pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 16px; margin: 8px 0; overflow-x: auto;
}
.message-body pre code { background: none; padding: 0; }

.message-body table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.message-body th, .message-body td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.message-body th { background: var(--surface-2); font-weight: 600; }
.message-body hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.typing-indicator { display: flex; gap: 4px; padding: 4px 0; }
.typing-indicator span {
  width: 6px; height: 6px;
  background: var(--text-3); border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

.error-msg {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px; padding: 10px 14px;
  color: #fca5a5; font-size: 13px;
}

.input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

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

.input-box {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text); font-size: 14px; font-family: inherit;
  resize: none; outline: none;
  min-height: 44px; max-height: 160px;
  line-height: 1.5; transition: border-color 0.2s;
}
.input-box:focus { border-color: var(--accent); }
.input-box::placeholder { color: var(--text-3); }

.send-btn {
  width: 44px; height: 44px;
  border-radius: 10px; border: none;
  background: var(--accent); color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; flex-shrink: 0;
}
.send-btn:hover { background: #ea580c; }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.send-btn svg { width: 18px; height: 18px; }

.input-hint {
  text-align: center; font-size: 11px;
  color: var(--text-3); margin-top: 8px;
}

.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); z-index: 100;
  align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 90%; max-width: 480px; padding: 24px;
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal h3 { font-size: 18px; font-weight: 600; margin-bottom: 20px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }

.form-group input, .form-group select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px;
  color: var(--text); font-size: 14px; font-family: inherit;
  outline: none; transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--accent); }
.form-group select { cursor: pointer; }
.form-group select option { background: var(--surface-2); }
.form-group .hint { font-size: 11px; color: var(--text-3); margin-top: 4px; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

.btn {
  padding: 8px 20px; border-radius: 8px;
  font-size: 14px; font-family: inherit;
  cursor: pointer; border: 1px solid var(--border); transition: all 0.2s;
}
.btn-secondary { background: var(--surface-2); color: var(--text-2); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #ea580c; }

@media (max-width: 640px) {
  .header { padding: 10px 14px; }
  .skill-bar { padding: 10px 14px; }
  .chat-container { padding: 14px; }
  .input-area { padding: 12px 14px; }
  .welcome-cards { grid-template-columns: 1fr 1fr; }
  .welcome { padding: 20px; }
}
