:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2f3d;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #6c9eff;
  --user: #2d4a7a;
  --assistant: #252830;
}

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

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#app {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  max-width: 1200px;
  margin: 0 auto;
}

header {
  grid-column: 1 / -1;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

header h1 { font-size: 1.25rem; }
.subtitle { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.mode-toggle { font-size: 0.9rem; cursor: pointer; }
.status { font-size: 0.8rem; color: var(--muted); }
.status.ok { color: #6dd58c; }

.sidebar {
  padding: 1rem;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.sidebar h2 { font-size: 0.95rem; margin-bottom: 0.75rem; }

#upload-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#upload-form button,
#send-btn {
  background: var(--accent);
  color: #0f1117;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

.hint { font-size: 0.75rem; color: var(--muted); margin-top: 0.5rem; }

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

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.message { display: flex; }
.message.user { justify-content: flex-end; }
.message.assistant { justify-content: flex-start; }

.bubble {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  font-size: 0.95rem;
}

.user .bubble { background: var(--user); }
.assistant .bubble { background: var(--assistant); border: 1px solid var(--border); }

.steps {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px dashed var(--border);
  padding-top: 0.5rem;
}

footer {
  grid-column: 1 / -1;
  padding: 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

#chat-form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

#input {
  flex: 1;
  resize: none;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  font: inherit;
}

@media (max-width: 768px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
}
