:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #6b7280;
  --accent: #1d6f42;
  --accent-ink: #ffffff;
  --border: #e2e6ea;
  --user-bubble: #e8f0ec;
  --error: #b00020;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.app {
  max-width: 760px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem 1rem;
}

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

.tagline {
  margin: 0.25rem 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.account {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.account-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signout {
  color: var(--muted);
  text-decoration: underline;
}

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

.turn { max-width: 100%; }

.turn-user {
  align-self: flex-end;
  background: var(--user-bubble);
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  white-space: pre-wrap;
  max-width: 85%;
}

.turn-model {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
}

.turn-model :first-child { margin-top: 0; }
.turn-model :last-child { margin-bottom: 0; }
.turn-model a { color: var(--accent); }
.turn-model pre {
  background: #f0f2f4;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  overflow-x: auto;
}
.turn-model code {
  background: #f0f2f4;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  font-size: 0.9em;
}
.turn-model pre code { background: none; padding: 0; }

.loading {
  color: var(--muted);
  font-style: italic;
  padding: 0.5rem 0;
}

.error {
  color: var(--error);
  background: #fdecef;
  border: 1px solid #f5c2cd;
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  margin: 0.5rem 0;
}

.hidden { display: none; }

.ask-form {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.question {
  width: 100%;
  resize: vertical;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  background: var(--panel);
}

.question:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.btn {
  font: inherit;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-secondary {
  background: var(--panel);
  color: var(--ink);
}
