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

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --border:    #2a2d3a;
  --accent:    #f97316;
  --accent-dim:#7c3d14;
  --text:      #e2e5f0;
  --muted:     #7a7f96;
  --user-bg:   #1e3a5f;
  --user-text: #cce4ff;
  --ai-bg:     #1a1d27;
  --ai-text:   #e2e5f0;
  --radius:    12px;
  --font:      system-ui, -apple-system, "Segoe UI", sans-serif;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
}

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

.header-inner h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.clear-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s, color 0.15s;
}
.clear-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Messages area */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  color: var(--muted);
}
.empty-icon { font-size: 40px; }

/* Message bubbles */
.message {
  display: flex;
  flex-direction: column;
  max-width: 88%;
}
.message.user   { align-self: flex-end; align-items: flex-end; }
.message.assistant { align-self: flex-start; align-items: flex-start; }

.bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.65;
}

.message.user .bubble {
  background: var(--user-bg);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
}

.message.assistant .bubble {
  background: var(--ai-bg);
  color: var(--ai-text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

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

.input-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.input-field {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  overflow-y: hidden;
  transition: border-color 0.15s;
  min-height: 48px;
  max-height: 160px;
}
.input-field:focus {
  outline: none;
  border-color: var(--accent);
}
.input-field::placeholder { color: var(--muted); }
.input-field:disabled { opacity: 0.5; }

.send-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 48px;
}
.send-btn:hover:not(:disabled) { background: #ea6b10; }
.send-btn:disabled { background: var(--accent-dim); cursor: not-allowed; }

.spinner { display: inline-block; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }
