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

:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --primary: #e8590c;
  --primary-hover: #d04a0a;
  --danger: #dc3545;
  --danger-hover: #bb2d3b;
  --text: #1a1a1a;
  --text-secondary: #666666;
  --border: #e0e0e0;
  --ai-bubble: #fff3e0;
  --user-bubble: #e8590c;
  --user-text: #ffffff;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --radius: 12px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

/* ── Screens ─────────────────────────────────────────────────────────── */

.screen {
  height: 100%;
}

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

.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
  padding: 24px;
  text-align: center;
}

.login-container h1 {
  font-size: 2.5rem;
  color: var(--primary);
}

.tagline {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 16px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
}

.login-form input {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.login-form input:focus {
  border-color: var(--primary);
}

.divider {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 320px;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-google {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 100%;
  max-width: 320px;
}

.btn-google:hover {
  background: var(--bg);
}

/* ── Buttons ──────────────────────────────────────────────────────────── */

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

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

.btn-small {
  padding: 6px 12px;
  font-size: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-small:hover {
  background: var(--bg);
}

.btn-danger {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
}

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

#chat-screen {
  display: flex;
  flex-direction: column;
}

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

.chat-header h1 {
  font-size: 1.3rem;
  color: var(--primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-email {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

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

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  display: flex;
  max-width: 80%;
}

.message.ai {
  align-self: flex-start;
}

.message.user {
  align-self: flex-end;
}

.message-content {
  padding: 10px 16px;
  border-radius: var(--radius);
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

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

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

.message.typing .message-content {
  background: var(--ai-bubble);
  color: var(--text-secondary);
  font-style: italic;
}

/* ── Input bar ────────────────────────────────────────────────────────── */

.input-bar {
  padding: 12px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#chat-form {
  display: flex;
  gap: 10px;
}

#chat-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

#chat-input:focus {
  border-color: var(--primary);
}

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .chat-header {
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .user-email {
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
  }

  .message {
    max-width: 90%;
  }

  .messages {
    padding: 12px;
  }

  .input-bar {
    padding: 10px 12px;
  }

  .login-container h1 {
    font-size: 2rem;
  }
}
