*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg: #0f172a;
  --bg-alt: #111827;
  --bg-panel: #020617;
  --border: #1f2937;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.1);
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --danger: #f97373;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1e293b, #020617);
  color: var(--text);
  height: 100vh;
}

#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */

.header {
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, #020617, #0b1120);
}

.header h1 {
  font-size: 1.25rem;
  margin: 0;
}

.subtitle {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  font-size: 0.9rem;
}

.header select {
  margin-left: 0.25rem;
  padding: 0.2rem 0.4rem;
  border-radius: 0.35rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.header button {
  padding: 0.3rem 0.7rem;
  border-radius: 0.4rem;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text-muted);
  cursor: pointer;
}

.header button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Layout  */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(260px, 1fr);
  gap: 0;
  min-height: 0;
}

/* Chat panel */

.chat-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(15,23,42,0.9), rgba(15,23,42,0.98));
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.5rem;
}

.msg {
  margin-bottom: 0.9rem;
  max-width: 80ch;
}

.msg-role {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.msg.user .msg-bubble {
  background: var(--accent-soft);
  border: 1px solid rgba(56, 189, 248, 0.4);
  align-self: flex-end;
}

.msg.assistant .msg-bubble {
  background: rgba(15,23,42,0.9);
  border: 1px solid var(--border);
}

.msg-bubble {
  padding: 0.6rem 0.75rem;
  border-radius: 0.6rem;
  white-space: pre-wrap;
  line-height: 1.4;
  font-size: 0.95rem;
}

/* Input */

.chat-input {
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  gap: 0.5rem;
  background: #020617;
}

.chat-input textarea {
  flex: 1;
  resize: none;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 0.5rem 0.6rem;
  font-size: 0.95rem;
}

.chat-input textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.4);
}

.chat-input button {
  padding: 0.45rem 0.9rem;
  border-radius: 0.5rem;
  border: none;
  background: var(--accent);
  color: #0b1120;
  font-weight: 600;
  cursor: pointer;
}

.chat-input button:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Side panel */

.side-panel {
  padding: 1rem;
  background: radial-gradient(circle at top right, #0b1120, #020617);
  font-size: 0.9rem;
  overflow-y: auto;
}

.side-panel h2,
.side-panel h3 {
  margin: 0.2rem 0 0.4rem;
}

.info-block {
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  padding: 0.6rem 0.7rem;
  margin-bottom: 0.8rem;
  background: rgba(15,23,42,0.7);
}

.info-block div {
  margin-bottom: 0.2rem;
}

.info-block div:last-child {
  margin-bottom: 0;
}

.sources-list {
  list-style: none;
  padding-left: 0;
  margin: 0;
  font-size: 0.8rem;
}

.sources-list li {
  border-radius: 0.5rem;
  border: 1px dashed var(--border);
  padding: 0.35rem 0.45rem;
  margin-bottom: 0.3rem;
  background: rgba(15,23,42,0.7);
}

.source-path {
  color: var(--text-muted);
}

.source-score {
  color: var(--accent);
}

/* Mobile */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    border-top: 1px solid var(--border);
  }
}

