:root {
  --cf-green: #2ecc71;
  --cf-green-dark: #27ae60;
  --cf-navy: #1c2733;
  --cf-bg: #f4f6f8;
  --cf-border: #d9e1e8;
  --cf-text: #1f2933;
  --cf-muted: #6b7b8c;
  --fade-duration: 0.35s;
}

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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--cf-bg);
  color: var(--cf-text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* HEADER */
header {
  background: var(--cf-navy);
  color: white;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

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

.brand-logo {
  height: 28px;
}

.brand-title {
  font-size: 18px;
  font-weight: 600;
}

.brand-subtitle {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
}

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

.user-chip {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: rgba(0,0,0,0.2);
  border-radius: 999px;
  font-size: 13px;
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.btn-secondary {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.6);
  color: white;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
}

/* MAIN */
.main-shell {
  flex: 1;
  padding: 24px 16px;
  display: flex;
  justify-content: center;
}

.chat-container {
  max-width: 900px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* STATUS BAR */
.status-bar {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--cf-muted);
}

.status-pill {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--cf-border);
}

/* SIGN-IN OVERLAY */
.signin-overlay {
  position: fixed;
  inset: 70px 0 0 0;
  background: rgba(244,246,248,0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}

.signin-card {
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid var(--cf-border);
  padding: 24px 20px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 25px rgba(15,23,42,0.18);
}

.signin-title {
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 18px;
}

.signin-subtitle {
  font-size: 13px;
  color: var(--cf-muted);
  margin-bottom: 16px;
}

/* PRE-CHAT */
.pre-chat {
  margin-top: 40px;
  text-align: center;
  opacity: 1;
  transition: opacity var(--fade-duration) ease;
}

.prechat-title {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--cf-navy);
}

.prechat-subtitle {
  font-size: 14px;
  color: var(--cf-muted);
  margin-bottom: 20px;
}

.prechat-input {
  width: 100%;
  max-width: 700px;
  min-height: 140px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--cf-border);
  font-size: 16px;
  resize: vertical;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(15,23,42,0.06);
}

.btn-primary {
  background: var(--cf-green);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 15px;
}

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

/* CONVERSATION */
.conversation {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  opacity: 0;
  transition: opacity var(--fade-duration) ease;
}

.conversation.visible {
  opacity: 1;
}

.hidden {
  display: none !important;
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-radius: 16px;
}

/* Inline document-style blocks */
.message-block {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
}

/* User = normal text (slightly bolder) */
.message-block.user .message-bubble {
  font-size: 15px;
  line-height: 1.55;
  font-weight: 500;
  color: var(--cf-text);
}

/* Assistant = slightly larger font */
.message-block.assistant .message-bubble {
  font-size: 16px;
  line-height: 1.6;
  color: var(--cf-text);
}

.message-bubble {
  white-space: pre-wrap;
}

/* WAITING INDICATOR */
.waiting-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
  color: var(--cf-muted);
  font-size: 14px;
  max-width: 780px;
  margin: 0 auto;
}

.dot {
  width: 8px;
  height: 8px;
  background: var(--cf-green);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* CHAT FOOTER */
.chat-footer {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  max-width: 900px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.chat-input {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--cf-border);
  font-size: 14px;
  resize: none;
  min-height: 42px;
  max-height: 120px;
}

/* NEW CHAT BUTTON */
.new-chat-btn {
  margin-top: 10px;
  background: var(--cf-navy);
  color: white;
  padding: 8px 16px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  align-self: flex-start;
}

.error-banner {
  display: none;
  background: rgba(220,38,38,0.06);
  border-radius: 8px;
  border: 1px solid rgba(220,38,38,0.5);
  color: #b91c1c;
  padding: 6px 10px;
  font-size: 12px;
  margin-bottom: 6px;
  max-width: 780px;
  margin-left: auto;
  margin-right: auto;
}