:root {
  --bg: #0f1117;
  --surface: #161b22;
  --surface-hover: #1f242c;
  --border: #30363d;
  --text: #c9d1d9;
  --text-muted: #8b949e;
  --primary: #58a6ff;
  --primary-hover: #79b8ff;
  --danger: #f85149;
  --success: #238636;
  --radius: 8px;
  --gap: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); }

#app { display: flex; height: 100vh; }

#sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--gap);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  overflow-y: auto;
}

#sidebar h1 { font-size: 1.2rem; color: var(--primary); margin-bottom: 4px; }
#sidebar h3 { font-size: 0.85rem; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }

.status-item { display: flex; justify-content: space-between; font-size: 0.85rem; padding: 4px 0; border-bottom: 1px solid var(--border); }
.status-item .label { color: var(--text-muted); }

#model-panel, #settings-panel { margin-top: 8px; }
#model-status { font-size: 0.85rem; color: var(--text-muted); margin-top: 6px; }

label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 8px; }
label input, label select, label textarea {
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.85rem;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px; border: none; border-radius: var(--radius);
  font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: background 0.15s;
  width: 100%; margin-top: 6px;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { opacity: 0.9; }

#chat-container { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

#chat-messages {
  flex: 1; overflow-y: auto; padding: var(--gap); display: flex; flex-direction: column; gap: var(--gap);
}

.message {
  max-width: 80%; padding: 10px 14px; border-radius: var(--radius); font-size: 0.9rem; line-height: 1.5; word-wrap: break-word;
}
.message.user { align-self: flex-end; background: var(--primary); color: #fff; }
.message.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); }
.message.system { align-self: center; font-size: 0.8rem; color: var(--text-muted); max-width: 100%; text-align: center; }
.message .meta { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; }

#chat-input-area {
  display: flex; gap: var(--gap); padding: var(--gap); border-top: 1px solid var(--border); background: var(--surface);
  align-items: stretch;
}

#chat-input { flex: 1; min-height: 48px; max-height: 160px; resize: vertical; }
#task-type { width: 140px; }
#btn-send { width: 80px; align-self: stretch; }

#chat-input-area select { background: var(--bg); }

.typing-indicator { display: inline-flex; gap: 4px; align-items: center; }
.typing-indicator span { display: inline-block; width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%; animation: blink 1.4s infinite both; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

@media (max-width: 768px) {
  #sidebar { width: 100%; position: absolute; z-index: 10; transform: translateX(-100%); transition: transform 0.2s; }
  #sidebar.open { transform: translateX(0); }
  #chat-container { width: 100%; }
}
