:root {
  --bg: #e9e9dd;
  --surface: #dfdfd3;
  --surface-2: #d8d8cc;
  --border: #ccccc0;
  --border-light: #d4d4c8;
  --text: #212120;
  --text-muted: #888;
  --text-mid: #555;
  --accent: #eadc21;
  --accent-subtle: rgba(234, 220, 33, 0.07);
  --yellow: #eadc21;
  --radius: 8px;
  --col: 640px;
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Gate ─────────────────────────────────────────── */

#gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

#gate.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.gate-brand {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.5rem;
}

.gate-title {
  font-size: clamp(3rem, 10vw, 5rem);
  font-weight: 300;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.gate-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 3rem;
  text-align: center;
  line-height: 1.7;
}

.gate-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 300px;
  padding: 0 1.5rem;
}

.gate-input {
  width: 100%;
  background: #fff;
  border: 0.5px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius);
  outline: none;
  text-align: center;
  letter-spacing: 0.15em;
  transition: border-color 0.2s;
}

.gate-input:focus { border-color: var(--accent); }
.gate-input.error { border-color: #c0392b; animation: shake 0.35s ease; }

.gate-error { font-size: 0.75rem; color: #c0392b; min-height: 1em; text-align: center; }
.gate-hint  { font-size: 0.68rem; color: var(--text-muted); letter-spacing: 0.05em; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-8px); }
  75%       { transform: translateX(8px); }
}

/* ── Chat shell ───────────────────────────────────── */

#chat {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

#chat.visible { opacity: 1; visibility: visible; }

/* ── Header ───────────────────────────────────────── */

.chat-header {
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 0 2rem;
  height: 48px;
  flex-shrink: 0;
  background: var(--bg);
}

.header-inner {
  width: 100%;
  max-width: var(--col);
  display: flex;
  align-items: stretch;
}

.header-left {
  background: var(--yellow);
  display: flex;
  align-items: center;
  gap: 0.3em;
  padding: 0 1rem;
  color: var(--text);
  white-space: nowrap;
  flex: 1;
}

.header-name {
  font-size: 14pt;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.header-chatfolio {
  font-size: 14pt;
  font-weight: 800;
  font-style: italic;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: stretch;
}

/* ── Text-button (header actions) ─────────────────── */

.text-button {
  position: relative;
  overflow: hidden;
  background: #fff;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 11pt;
  font-weight: 500;
  font-style: italic;
  letter-spacing: 0.03em;
  color: var(--text);
  text-decoration: none;
  width: 130px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.text-button .text {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  line-height: 1;
  transition: top 0.2s ease-in-out;
  z-index: 7;
}

.text-button .text p {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  line-height: 1;
  margin: 0;
}

.text-button .rect2 {
  position: absolute;
  top: 0; left: 50%;
  width: 100%; height: 100%;
  opacity: 0;
  background-color: var(--yellow);
  transform: translate(-50%, 0);
  transition: opacity 0.2s ease;
  z-index: 6;
}

.text-button:hover .text        { top: -100%; }
.text-button:hover .rect2       { opacity: 0.8; }
.text-button:not(:hover) .rect2 { opacity: 0; }

.btn-icon {
  width: 12px;
  height: 12px;
  object-fit: contain;
  flex-shrink: 0;
}

#mailBtn .btn-icon { width: 16px; height: 16px; }

/* separator between header buttons */
.header-right .text-button + .text-button {
  border-left: 0.5px solid var(--border);
}

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

.messages {
  flex: 1;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 2.5rem max(1rem, calc((100% - var(--col)) / 2));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2rem;
  scroll-behavior: smooth;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, black 48px);
  mask-image: linear-gradient(to bottom, transparent 0, black 48px);
}

.messages.centered { justify-content: center; }

.messages::-webkit-scrollbar        { width: 2px; }
.messages::-webkit-scrollbar-track  { background: transparent; }
.messages::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 2px; }

/* All messages constrained to column */
.message {
  width: 100%;
  max-width: var(--col);
  animation: msgIn 0.25s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Hero section ─────────────────────────────────── */

.hero-section {
  display: flex;
  align-items: stretch;
  gap: calc(3.25rem - 10px);
  width: 100%;
  max-width: var(--col);
  height: 165px;
  padding-bottom: 0;
}

.hero-photo {
  width: 165px;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
  flex-shrink: 0;
}

.hero-brand {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
}

.hero-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left center;
  display: block;
}

/* ── Chips grid (initial A/B/C options) ───────────── */

.chips-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 0.75rem;
  width: 100%;
}

/* Intro card — variant headline above first Brixx message */
.message.intro-card {
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--text-mid);
  font-style: italic;
  padding-bottom: 1.75rem;
  margin-bottom: 0.25rem;
}

.message.intro-card::before { content: '\201C\00a0'; }
.message.intro-card::after  { content: '\00a0\201D'; }

/* User message — right-aligned within column */
.message.user {
  display: flex;
  justify-content: flex-end;
}

.message.user > span {
  background: var(--surface-2);
  border: 0.5px solid var(--border);
  border-radius: 14px 14px 3px 14px;
  padding: 0.7rem 1rem;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  max-width: 75%;
}

/* Assistant message — left-aligned within column */
.message.assistant {}

.message-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.message-content {
  font-size: 0.875rem;
  line-height: 1.85;
  color: var(--text);
}

.message-content p            { margin-bottom: 0.85rem; }
.message-content p:last-child { margin-bottom: 0; }
.message-content strong       { color: var(--text); font-weight: 600; }
.message-content em           { color: var(--text-mid); font-style: italic; }

.message-content a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 0.5px solid rgba(33,33,32,0.3);
  transition: border-color 0.15s;
}
.message-content a:hover { border-color: var(--text); }

/* WhatsApp number — destacado como CTA */
.message-content .whatsapp-link {
  color: #25d366;
  border-bottom-color: rgba(37, 211, 102, 0.35);
  font-weight: 500;
}
.message-content .whatsapp-link:hover { border-bottom-color: #25d366; }

/* Blockquote — quote-block do Expofacic */
.message-content blockquote {
  padding: 0.85rem 1.1rem;
  margin: 1rem 0;
  background: var(--yellow);
  border-radius: 6px;
  font-style: italic;
  line-height: 1.75;
}

.message-content blockquote p { margin-bottom: 0; }

/* Divider */
.message-content hr {
  border: none;
  border-top: 0.5px solid var(--border);
  margin: 1.25rem 0;
}

/* Inline code */
.message-content code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  background: var(--surface);
  padding: 0.15em 0.45em;
  border-radius: 3px;
  color: var(--text-mid);
  border: 0.5px solid var(--border);
}

/* ── Option chips ─────────────────────────────────── */

.option-chip {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  background: transparent;
  border: 1px solid var(--text);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.8rem;
  line-height: 1.5;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
  text-align: left;
  width: 100%;
}

.option-chip:hover {
  border-color: transparent;
  background: #fff;
}

/* In chips-grid, fill full height */
.chips-grid .option-chip { height: 100%; margin-top: 0; }

/* Chips fora de grid (ex: links na narrativa) */
.option-chip + .option-chip { margin-top: 0.6rem; }

.option-chip .arrow { color: var(--accent); flex-shrink: 0; }

/* ── Streaming cursor ─────────────────────────────── */

.cursor {
  display: inline-block;
  width: 1.5px;
  height: 0.85em;
  background: #fff;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.75s infinite;
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ── Input area ───────────────────────────────────── */

.chat-input-area {
  padding: 0 2rem;
  margin-bottom: 50px;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg);
}

.chat-input-inner {
  position: relative;
  width: 100%;
  max-width: var(--col);
}

.chat-input {
  width: 100%;
  background: #fff;
  border: 0.5px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 0.85rem 3.5rem 0.85rem 1.25rem;
  border-radius: 28px;
  outline: none;
  resize: none;
  height: 100px;
  line-height: 1.6;
  transition: border-color 0.2s;
  display: block;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.10);
}

.chat-input:focus        { border-color: #bbb; }
.chat-input::placeholder { color: var(--text-muted); }

.send-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  transition: opacity 0.15s, transform 0.1s;
}

.send-btn img { width: 100%; height: 100%; display: block; }

.send-btn:hover:not(:disabled)  { opacity: 0.75; }
.send-btn:active:not(:disabled) { transform: scale(0.92); }
.send-btn:disabled              { opacity: 0.25; cursor: not-allowed; }

/* ── Project images ───────────────────────────────── */

.message-content img {
  max-width: 100%;
  width: 100%;
  display: block;
  border-radius: var(--radius);
  margin: 0.75rem 0;
  border: 0.5px solid var(--border);
}

/* ── Video embeds ─────────────────────────────────── */

.video-wrap {
  width: 100%;
  max-width: 100%;
  margin: 1rem 0;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 0.5px solid var(--border);
}

.video-wrap iframe { width: 100%; height: 100%; border: none; display: block; }

.video-wrap video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}

/* ── Lightbox ─────────────────────────────────────── */

.message-content img { cursor: zoom-in; }

#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(33, 33, 32, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 300;
  padding: 2rem 1.5rem 4rem;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  cursor: zoom-out;
}

#lightbox.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#lightbox img {
  width: 90vw;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
  animation: lightboxIn 0.25s cubic-bezier(0.34, 1.26, 0.64, 1) both;
  cursor: default;
  flex-shrink: 0;
  transition: width 0.2s ease;
}

.lightbox-zoom {
  position: fixed;
  top: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  z-index: 301;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

#lightbox.visible ~ .lightbox-zoom,
.lightbox-zoom.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.lightbox-zoom-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--yellow);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  transition: transform 0.1s, background 0.15s;
  flex-shrink: 0;
}

.lightbox-zoom-btn:hover  { background: #d4c91a; }
.lightbox-zoom-btn:active { transform: scale(0.92); }

.lightbox-zoom-btn svg {
  width: 20px;
  height: 20px;
}

@keyframes lightboxIn {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ── Welcome overlay ─────────────────────────────── */

#welcome-overlay {
  position: fixed;
  inset: 0;
  background: rgba(33, 33, 32, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

#welcome-overlay.visible { opacity: 1; visibility: visible; }
#welcome-overlay.hiding  { opacity: 0; visibility: hidden; }

.welcome-wrap {
  position: relative;
  max-width: 780px;
  width: 100%;
  animation: cardIn 0.4s cubic-bezier(0.34, 1.26, 0.64, 1) both;
}

.welcome-card {
  background: #f5f5ee;
  border-radius: 20px;
  display: flex;
  gap: 0;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
}

@keyframes cardIn {
  from { transform: scale(0.92) translateY(12px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.welcome-close {
  position: absolute;
  top: -16px;
  right: -16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  border: none;
  font-size: 1.3rem;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.15s, transform 0.1s;
  box-shadow: 0 4px 14px rgba(0,0,0,0.28);
  line-height: 1;
}

.welcome-close:hover  { background: #d4c91a; }
.welcome-close:active { transform: scale(0.92); }

.welcome-left {
  width: 220px;
  flex-shrink: 0;
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  background: #eaeae0;
}

.welcome-photo {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
}

.welcome-name {
  font-size: 0.95rem;
  font-weight: 700;
  font-style: italic;
  text-align: center;
  color: var(--text);
}

.welcome-titles {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.8;
}

.welcome-right {
  flex: 1;
  padding: 2.5rem 2rem 2.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  justify-content: center;
}

.welcome-greeting {
  font-size: 1.15rem;
  line-height: 1.5;
  color: var(--text);
}

.welcome-greeting strong {
  font-size: 1.2rem;
  font-weight: 700;
}

.welcome-right p {
  font-size: 0.875rem;
  line-height: 1.75;
  color: var(--text);
}

/* ── Welcome chips (entry selection) ─────────────── */

.welcome-chips {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
  margin-top: 0.5rem;
  animation: msgIn 0.3s ease;
}

.welcome-chip {
  background: transparent;
  border: 1px solid var(--text);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.5;
  padding: 0.9rem 1.1rem;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.18s, background 0.18s;
  width: 100%;
}

.welcome-chip:hover { background: #fff; border-color: transparent; }

/* ── Safe area (notch / home bar iOS) ────────────── */

.chat-input-area { padding-bottom: max(1.25rem, env(safe-area-inset-bottom)); }

/* ── Mobile ───────────────────────────────────────── */

@media (max-width: 680px) {
  .messages         { padding: 1.5rem 1rem; }
  .chat-input-area  { padding: 0 1rem; margin-bottom: max(30px, env(safe-area-inset-bottom)); }
  .chat-header      { padding: 0 1rem; }
  .header-left      { font-size: 0.62rem; }
  .text-button      { width: 100px; }
  .hero-section     { height: 110px; }
  .hero-photo       { width: 110px; }
  .chips-grid       { grid-template-columns: 1fr; }

  .welcome-card     { flex-direction: column; max-height: 90dvh; overflow-y: auto; }
  .welcome-left     { width: 100%; flex-direction: row; padding: 1.5rem; gap: 1rem; align-items: center; }
  .welcome-photo    { width: 72px; height: 72px; flex-shrink: 0; }
  .welcome-name, .welcome-titles { text-align: left; }
  .welcome-right    { padding: 1.25rem 1.5rem 2rem; }
  .welcome-close    { top: 10px; right: 10px; }
}
