:root {
  color-scheme: light dark;
  --bg: #f7f7f8;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e2e2e5;
  --accent: #4f46e5;
  --accent-contrast: #ffffff;
  --danger: #dc2626;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --surface: #1f1f24;
    --text: #f2f2f3;
    --muted: #9a9aa2;
    --border: #333338;
    --accent: #818cf8;
    --accent-contrast: #16161a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

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

.brand-group {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.tagline {
  font-size: 0.85rem;
  color: var(--text-muted, #6b7280);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-nav a:not(.button) {
  color: var(--text);
  text-decoration: none;
}

.header-email {
  color: var(--muted);
  font-size: 0.9rem;
}

.inline-form { display: inline; }

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  text-decoration: underline;
  font-size: 0.9rem;
  cursor: pointer;
}

.auth-switch {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.button, button, .button-danger {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  text-decoration: none;
  font-size: 0.95rem;
  cursor: pointer;
}

.button-danger { background: var(--danger); color: #fff; }

.goal-form, .goal-form label {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.goal-form input, .goal-form textarea {
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  margin-bottom: 1rem;
}

.goal-form button { align-self: flex-start; }

.error { color: var(--danger); }

.lede { color: var(--muted); margin-bottom: 1.5rem; }

.chat-thread {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-message {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.chat-message p { margin: 0; white-space: pre-wrap; }

.chat-message.user {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

.chat-message.assistant { align-self: flex-start; }

.chat-message-role {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.7;
  margin-bottom: 0.25rem;
}

.chat-empty { color: var(--muted); margin-bottom: 2rem; }
