:root {
  --bg:           #0c0c0c;
  --surface:      #131313;
  --surface2:     #191919;
  --border:       #222;
  --border-light: #2e2e2e;
  --text:         #c8c8c8;
  --text-dim:     #555;
  --text-dimmer:  #383838;
  --accent:       #b89050;
  --accent-bg:    #1a140a;
  --user-bg:      #181818;
  --danger:       #7a2020;
  --danger-text:  #d07070;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Login ────────────────────────────────────────────────────────────────── */

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.login-box {
  width: 100%;
  max-width: 400px;
}

.login-logo {
  margin-bottom: 2.5rem;
}

.login-logo h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
}

.login-logo p {
  margin-top: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  font-style: italic;
}

.login-box form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-box input[type="email"] {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

.login-box input[type="email"]:focus {
  border-color: var(--accent);
}

.btn {
  padding: 0.7rem 1.25rem;
  background: var(--accent);
  color: #0c0c0c;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  letter-spacing: 0.01em;
}

.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border-light);
}

.btn-ghost:hover {
  opacity: 1;
  color: var(--text);
  border-color: var(--text-dim);
}

.msg-box {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.msg-box.error {
  background: var(--danger);
  color: var(--danger-text);
  border: 1px solid #5a1515;
}

.msg-box.success {
  background: var(--accent-bg);
  color: #c8a870;
  border: 1px solid #3a2a10;
}

.dev-link {
  display: block;
  margin-top: 0.5rem;
  word-break: break-all;
  font-family: ui-monospace, 'Cascadia Code', Menlo, monospace;
  font-size: 0.78rem;
  opacity: 0.8;
}

/* ── Chat layout ──────────────────────────────────────────────────────────── */

.chat-wrap {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

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

.chat-header-left {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.chat-header-left h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.chat-header-left span {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-style: italic;
}

.chat-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-email {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  border-radius: 3px;
}

/* ── Messages ─────────────────────────────────────────────────────────────── */

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 0;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

.message {
  display: flex;
  padding: 0.6rem 1.25rem;
  gap: 0.75rem;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  margin-top: 2px;
}

.message.assistant .message-avatar {
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid #3a2a10;
}

.message.user .message-avatar {
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.message-body {
  flex: 1;
  min-width: 0;
}

.message-content {
  display: inline-block;
  padding: 0.65rem 0.9rem;
  border-radius: 4px;
  font-size: 0.93rem;
  line-height: 1.65;
  max-width: 100%;
}

.message.assistant .message-content {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.message.user .message-content {
  background: var(--user-bg);
  border: 1px solid var(--border-light);
  color: var(--text);
  text-align: right;
}

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

/* Markdown inside assistant messages */
.message-content p { margin-bottom: 0.6em; }
.message-content p:last-child { margin-bottom: 0; }
.message-content strong { color: #e0c080; }
.message-content em { color: #aaa; }
.message-content code {
  font-family: ui-monospace, 'Cascadia Code', Menlo, monospace;
  font-size: 0.85em;
  background: #1f1f1f;
  padding: 0.1em 0.3em;
  border-radius: 3px;
  color: #c08060;
}
.message-content pre {
  background: #111;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  margin: 0.5em 0;
}
.message-content pre code {
  background: none;
  padding: 0;
  color: #b0b0b0;
}
.message-content ul, .message-content ol {
  padding-left: 1.4em;
  margin: 0.4em 0;
}
.message-content li { margin: 0.15em 0; }
.message-content blockquote {
  border-left: 3px solid var(--border-light);
  padding-left: 0.75rem;
  color: var(--text-dim);
  margin: 0.5em 0;
}
.message-content h1, .message-content h2, .message-content h3 {
  color: #ddd;
  margin: 0.5em 0 0.25em;
}

/* Loading dots */
.loading-dots span {
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-dim);
  margin: 0 2px;
  animation: blink 1.2s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.9); }
  40%           { opacity: 1;   transform: scale(1.1); }
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-dimmer);
  font-size: 0.88rem;
}

.empty-state strong {
  display: block;
  font-size: 1.1rem;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

/* ── Input area ───────────────────────────────────────────────────────────── */

.chat-input-area {
  flex-shrink: 0;
  padding: 0.85rem 1.25rem 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.input-inner {
  display: flex;
  gap: 0.5rem;
  max-width: 800px;
  margin: 0 auto;
  align-items: flex-end;
}

.input-inner textarea {
  flex: 1;
  resize: none;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.93rem;
  line-height: 1.5;
  padding: 0.65rem 0.85rem;
  outline: none;
  max-height: 160px;
  overflow-y: auto;
  transition: border-color 0.15s;
  field-sizing: content;
  min-height: 42px;
}

.input-inner textarea:focus { border-color: var(--accent); }
.input-inner textarea:disabled { opacity: 0.4; }
.input-inner textarea::placeholder { color: var(--text-dimmer); }

.send-btn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.send-btn svg { width: 16px; height: 16px; fill: #0c0c0c; }

.input-hint {
  text-align: center;
  margin-top: 0.4rem;
  font-size: 0.72rem;
  color: var(--text-dimmer);
}
