:root {
  /* Brand board palette */
  --forest: #1b3b34;
  --sage: #5c6f63;
  --seafoam: #a7c5b9;
  --clay: #d7c6b1;
  --lilac: #7d6ba6;
  --night: #1e1b2e;

  --bg: #f0ece4;
  --card: #fbf9f5;
  --ink: #2a3230;
  --ink-soft: #5c6f63;
  --seafoam-soft: #e2ece7;
  --clay-soft: #ede2d2;
  --line: #d9d2c4;

  --font-body: "Inter", system-ui, sans-serif;
  --font-head: "Playfair Display", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  position: relative;
  overflow-x: hidden;
}

/* Subtle mycelial/root line-work texture — reads as texture, not illustration. */
.root-motif {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='400' height='400'><path d='M20 380 C 60 300, 40 260, 90 220 C 130 190, 110 150, 150 110 C 180 80, 170 50, 210 10' stroke='%231b3b34' stroke-width='2' fill='none'/><path d='M90 220 C 60 210, 40 190, 10 195' stroke='%231b3b34' stroke-width='1.5' fill='none'/><path d='M150 110 C 175 120, 195 110, 220 130' stroke='%231b3b34' stroke-width='1.5' fill='none'/><path d='M210 10 C 230 30, 260 30, 280 55' stroke='%231b3b34' stroke-width='1.5' fill='none'/><path d='M20 380 C 10 350, -10 340, -20 310' stroke='%231b3b34' stroke-width='1.5' fill='none'/></svg>");
  background-repeat: repeat;
  background-size: 400px 400px;
}

.view {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.view[hidden] {
  display: none;
}

.card,
.chat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(27, 59, 52, 0.08);
  overflow: hidden;
}

.card {
  width: 100%;
  max-width: 420px;
}

/* Gate — forest brand panel, per brand board */
.brand-panel {
  background: var(--forest);
  color: #f3efe6;
  text-align: center;
  padding: 36px 32px 30px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  color: #e9e3d4;
  margin-bottom: 10px;
}

.brand-panel h1 {
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 38px;
  letter-spacing: 0.01em;
  margin: 0;
  color: #f3efe6;
}

.tagline {
  margin: 8px 0 0;
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--seafoam);
}

.gate-body {
  padding: 28px 36px 36px;
}

.subtitle {
  margin: 0 0 20px;
  color: var(--ink-soft);
  font-size: 14px;
  letter-spacing: 0.02em;
  text-align: center;
}

form label {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  margin: 18px 0 6px;
}

form input,
form textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  background: #fff;
}

form input:focus,
form textarea:focus {
  outline: none;
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(167, 197, 185, 0.35);
}

button {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 15px;
  border: none;
  border-radius: 8px;
  background: var(--forest);
  color: #f3efe6;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.15s ease;
}

button:hover {
  background: #274f45;
}

button:disabled {
  background: var(--sage);
  opacity: 0.6;
  cursor: default;
}

.error {
  color: #a04a3a;
  font-size: 13.5px;
  margin: 14px 0 0;
}

#gate-form button {
  margin-top: 26px;
  width: 100%;
}

/* Chat view */
.chat-card {
  width: 100%;
  max-width: 640px;
  height: min(720px, 88vh);
  display: flex;
  flex-direction: column;
}

.chat-header {
  background: var(--forest);
  padding: 14px 24px;
  flex-shrink: 0;
}

.chat-wordmark {
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 20px;
  color: #f3efe6;
}

.thread {
  flex: 1;
  overflow-y: auto;
  padding: 32px 36px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.msg {
  max-width: 82%;
  padding: 13px 17px;
  border-radius: 14px;
  white-space: pre-wrap;
  font-size: 15.5px;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--seafoam-soft);
  color: var(--ink);
  border: 1px solid #cbdcd3;
  border-bottom-left-radius: 4px;
}

.msg.user {
  align-self: flex-end;
  background: var(--clay-soft);
  color: var(--ink);
  border: 1px solid #ddd0ba;
  border-bottom-right-radius: 4px;
}

/* Typing indicator — three pulsing dots in an assistant-style bubble */
.msg.typing {
  align-self: flex-start;
  background: var(--seafoam-soft);
  border: 1px solid #cbdcd3;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 16px 18px;
}

.msg.typing .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sage);
  animation: typing-pulse 1.2s infinite ease-in-out;
}

.msg.typing .dot:nth-child(2) {
  animation-delay: 0.18s;
}

.msg.typing .dot:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes typing-pulse {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.send-row {
  display: flex;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.send-row textarea {
  flex: 1;
  resize: none;
  max-height: 140px;
}

.send-row button {
  align-self: flex-end;
}

@media (max-width: 520px) {
  .gate-body {
    padding: 24px;
  }
  .thread {
    padding: 22px 20px;
  }
}
