:root {
  --violet: #4a2e82;
  --violet-light: #7a58c2;
  --gold: #e3a72e;
  --gold-light: #f4c569;
  --bg: #faf8f3;
  --text: #241b33;
  --bubble-user: #16181d;
  --bubble-assistant: #ffffff;

  /* Landing-page palette, defined here so every page shares one source.
     landing.css relies on these too. */
  --hero-yellow: #ffc91f;
  --ink: #16181d;
  --ink-soft: #1f232b;
  --ink-line: #2a2e37;
  --card-line: #e6d9ae;
}

* { box-sizing: border-box; }

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

.logo-mark { flex-shrink: 0; }

.subtitle {
  margin: 0;
  font-size: 0.88rem;
  color: #6b5a2a;
}

.chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 28px 24px;
}

.message {
  max-width: 80%;
  padding: 14px 18px;
  border-radius: 18px;
  line-height: 1.5;
  font-size: 0.95rem;
}

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

.message.assistant {
  align-self: flex-start;
  background: var(--bubble-assistant);
  border: 1px solid var(--card-line);
  border-bottom-left-radius: 6px;
  box-shadow: 0 14px 30px -26px rgba(0, 0, 0, 0.6);
}

.message.user {
  align-self: flex-end;
  background: var(--bubble-user);
  color: white;
  border-bottom-right-radius: 6px;
}

.sources {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #e2ddd0;
  font-size: 0.8rem;
}

.sources summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
}

.citation {
  margin-top: 8px;
}

.citation-label {
  font-weight: 600;
  color: #555;
  margin-bottom: 2px;
}

.citation blockquote {
  margin: 0;
  padding: 6px 10px;
  border-left: 3px solid var(--hero-yellow);
  background: #faf8f3;
  color: #444;
  font-size: 0.78rem;
  line-height: 1.4;
  white-space: pre-wrap;
}

.message.error {
  align-self: flex-start;
  background: #fbeaea;
  color: #8a2c2c;
  border: 1px solid #e7b8b8;
}

.chat-input-row {
  display: block;
  padding: 16px 24px 22px;
  border-top: 1px solid var(--card-line);
  background: white;
}

#chat-input {
  flex: 1;
  padding: 13px 16px;
  border: 1px solid #d8d2c2;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.95rem;
}

#chat-input:focus {
  outline: none;
  border-color: var(--ink);
}

#send-btn {
  background: var(--ink);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 0 24px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

#send-btn:hover { background: #23262e; }
#send-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* --- Auth / pricing / account pages --- */

/* Auth / pricing / account pages share the landing page's yellow ground and
   floating white card, so moving between them feels like one product. */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--hero-yellow);
}

/* No coloured bar — the logo sits straight on the yellow, as in the hero. */
.page-header {
  width: 100%;
  background: transparent;
  color: var(--text);
  padding: 26px 20px 10px;
  text-align: center;
}

.page-header h1 {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-header .logo-mark { width: 40px; height: 40px; }

.logo-link {
  display: inline-flex;
  color: inherit;
  text-decoration: none;
}

.card {
  width: 100%;
  max-width: 440px;
  background: white;
  border: 1px solid var(--card-line);
  border-radius: 20px;
  padding: 36px 32px;
  margin: 28px 20px 48px;
  box-shadow: 0 24px 50px -40px rgba(0, 0, 0, 0.6);
}

.card h2 {
  margin: 0 0 22px;
  font-size: 1.35rem;
  color: var(--text);
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #444;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d8d2c2;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.95rem;
}

.field input:focus {
  outline: none;
  border-color: var(--ink);
}

/* Dark ink rather than gold: on a white card floating on yellow, gold blends
   into the surround — ink reads as the primary action from across the page. */
.btn-primary {
  width: 100%;
  background: var(--ink);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.btn-primary:hover { background: #23262e; transform: translateY(-2px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-google {
  width: 100%;
  background: white;
  color: var(--text);
  border: 1.5px solid #d8d2c2;
  border-radius: 12px;
  padding: 13px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: block;
  transition: border-color 0.15s ease;
}

.btn-google:hover { border-color: var(--ink); }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0;
  color: #999;
  font-size: 0.8rem;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid #e2ddd0;
}

.form-note {
  margin-top: 16px;
  font-size: 0.85rem;
  color: #666;
  text-align: center;
}

.form-note a { color: var(--text); font-weight: 600; }

.form-error {
  background: #fbeaea;
  color: #8a2c2c;
  border: 1px solid #e7b8b8;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: none;
}

.form-error.visible { display: block; }

.plan-price {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text);
  margin: 8px 0;
}

.plan-price span {
  font-size: 0.9rem;
  font-weight: 400;
  color: #7a7a7a;
}

.plan-features {
  list-style: none;
  padding: 0;
  margin: 22px 0;
}

/* Same ticked list as the landing page's plan cards */
.plan-features li {
  position: relative;
  padding: 9px 0 9px 24px;
  border-bottom: 1px solid #f0ede5;
  font-size: 0.9rem;
}

.plan-features li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--ink);
  font-weight: 700;
}

.status-badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 18px;
}

.status-badge.active {
  background: var(--hero-yellow);
  color: var(--ink);
}

.status-badge.inactive {
  background: #f0ede5;
  color: #777;
}

.btn-secondary {
  width: 100%;
  background: white;
  color: var(--text);
  border: 1.5px solid #d8d2c2;
  border-radius: 12px;
  padding: 13px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  margin-top: 12px;
}

.btn-secondary:hover { border-color: var(--ink); }

/* --- Chat app: sidebar + conversation area --- */

.chat-body { height: 100vh; overflow: hidden; }

.chat-layout { display: flex; height: 100vh; }

/* Same dark ground as the landing page's benefits section, with the yellow
   used as the accent — so the app reads as the same product as the site. */
.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  width: 280px;
  transform: translateX(-100%);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--ink);
  color: #e9e7f0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 12px;
}

.sidebar.open { transform: translateX(0); }

/* The open panel covers the logo that opened it, so it carries its own way out. */
.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 10px;
}

.sidebar-heading {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8b909b;
}

.sidebar-close {
  display: flex;
  padding: 6px;
  background: none;
  border: none;
  border-radius: 8px;
  color: #b7bbc6;
  cursor: pointer;
}

.sidebar-close:hover { background: rgba(255, 255, 255, 0.08); color: white; }

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 6px 16px;
  color: white;
  border-bottom: 1px solid var(--ink-line);
}

.sidebar-brand .logo-mark { width: 34px; height: 34px; }

.new-chat-btn {
  background: var(--hero-yellow);
  color: var(--ink);
  border: none;
  border-radius: 12px;
  padding: 11px 12px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.new-chat-btn:hover { background: #ffd75a; }

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

.conversation-empty {
  margin: 0;
  padding: 8px 6px;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.6);
}

.conversation-row {
  display: flex;
  align-items: center;
  border-radius: 8px;
}

.conversation-row:hover { background: rgba(255, 255, 255, 0.07); }
.conversation-row.active {
  background: var(--ink-soft);
  box-shadow: inset 3px 0 0 var(--hero-yellow);
}

.conversation-open {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  background: none;
  border: none;
  color: inherit;
  font-family: inherit;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-delete {
  padding: 6px 10px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.55);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.conversation-delete:hover { color: white; }

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 12px;
  font-size: 0.8rem;
  border-top: 1px solid var(--ink-line);
}

.sidebar-email {
  color: rgba(255, 255, 255, 0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer a { color: white; }

.chat-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.chat-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 22px;
  background: var(--hero-yellow);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.chat-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-overlay { display: none; }

.sidebar-overlay:not([hidden]) {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(0, 0, 0, 0.4);
}

/* Logo doubles as the button that reveals the conversation list. */
.chat-logo-btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
  background: none;
  border: none;
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
}

.chat-logo-btn:hover { background: rgba(0, 0, 0, 0.08); }
.chat-logo-btn[aria-expanded="true"] { background: rgba(0, 0, 0, 0.12); }

/* A readable column in the middle rather than text spanning the whole width */
.chat-thread {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-composer {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* While retrieval and the model's first token are still pending. A steady
   line of text reads as a frozen screen; a slow pulse says the request is
   alive without competing with the answer once it starts arriving. */
.message.pending p,
.trial-msg.pending p {
  opacity: 0.6;
  animation: pending-pulse 1.6s ease-in-out infinite;
}

@keyframes pending-pulse {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 0.85; }
}

@media (prefers-reduced-motion: reduce) {
  .message.pending p,
  .trial-msg.pending p { animation: none; }
}
