:root {
  --bg: #0f0f12;
  --surface: #18181c;
  --border: #2a2a30;
  --text: #e8e8ec;
  --muted: #8888a0;
  --accent: #7c6cf9;
  --accent-hover: #9588ff;
  --user-msg: #2d2a3e;
  --bot-msg: #1e1d26;
  --radius: 12px;
  --font: 'DM Sans', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.logo-icon {
  font-size: 1.25rem;
  color: var(--accent);
}

.logo h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.tagline {
  margin-left: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.api-status {
  font-size: 0.75rem;
  color: var(--muted);
}

.api-status.connected {
  color: #6ee7b7;
}

.api-status.error {
  color: #f87171;
}

/* Main chat area */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

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

.welcome {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0;
}

.welcome p {
  margin: 0 0 0.5rem 0;
}

.welcome.hidden {
  display: none;
}

.msg {
  max-width: 90%;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user {
  align-self: flex-end;
  background: var(--user-msg);
  border: 1px solid var(--border);
}

.msg.assistant {
  align-self: flex-start;
  background: var(--bot-msg);
  border: 1px solid var(--border);
}

.msg .role-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.msg.error {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.3);
  color: #fca5a5;
}

/* Input */
.input-area {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.input-area input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}

.input-area input::placeholder {
  color: var(--muted);
}

.input-area input:focus {
  outline: none;
  border-color: var(--accent);
}

.input-area button {
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.input-area button:hover {
  background: var(--accent-hover);
}

.input-area button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Scrollbar */
.chat::-webkit-scrollbar {
  width: 6px;
}

.chat::-webkit-scrollbar-track {
  background: transparent;
}

.chat::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Setup panel (when API offline) */
.setup-panel {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 18, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
}
.setup-panel.hidden {
  display: none;
}
.setup-box {
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.setup-title {
  margin: 0 0 0.35rem 0;
  font-weight: 600;
  font-size: 1.1rem;
}
.setup-desc {
  margin: 0 0 1rem 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}
.setup-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.setup-row input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}
.setup-row input:focus {
  outline: none;
  border-color: var(--accent);
}
.setup-row button {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.setup-row button:hover {
  background: var(--accent-hover);
}
.setup-steps {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.setup-steps summary {
  cursor: pointer;
  color: var(--accent);
}
.setup-steps ol {
  margin: 0.5rem 0 0 1.25rem;
  padding: 0;
  line-height: 1.6;
}
.setup-steps code {
  background: var(--bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}
.setup-steps a {
  color: var(--accent);
}
