:root {
  --bg: #ece3d2;
  --bg-2: #e3d8c2;
  --surface: #fbf8f1;
  --surface-2: #f2ebdb;
  --ink: #2a2620;
  --ink-soft: #6a6253;
  --ink-faint: #9c9384;
  --pine: #2f4a3f;
  --pine-soft: #3d6153;
  --terracotta: #bf5a35;
  --terracotta-soft: #d38a63;
  --line: #e4dcc9;
  --user-ink: #f6f1e6;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --shadow: 0 1px 2px rgba(42, 38, 32, 0.04), 0 22px 55px -22px rgba(42, 38, 32, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 620px at 12% -8%, rgba(191, 90, 53, 0.08), transparent 55%),
    radial-gradient(1000px 560px at 100% 108%, rgba(47, 74, 63, 0.1), transparent 55%),
    var(--bg);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: clamp(0px, 3vw, 40px);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* panel */
.chat {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 468px;
  height: min(772px, 100vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

/* header */
.chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--pine);
}

.brand__mark svg {
  width: 24px;
  height: 24px;
}

.brand__mark .peak {
  fill: none;
  stroke: #f4efe3;
  stroke-width: 2.1;
  stroke-linejoin: round;
}

.brand__mark .sun {
  fill: var(--terracotta);
}

.brand__name {
  display: block;
  font-family: var(--display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.005em;
}

.brand__role {
  display: block;
  margin-top: 1px;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ink-soft);
}

.status__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pine-soft);
  box-shadow: 0 0 0 0 rgba(61, 97, 83, 0.4);
  animation: breathe 3.4s ease-in-out infinite;
}

@keyframes breathe {
  50% { box-shadow: 0 0 0 4px rgba(61, 97, 83, 0.14); }
}

/* messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
  width: 7px;
}

.messages::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 8px;
}

.msg {
  max-width: 85%;
  display: flex;
  flex-direction: column;
  gap: 5px;
  animation: rise 0.4s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

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

.msg--user {
  align-self: flex-end;
  align-items: flex-end;
}

.msg--agent {
  align-self: flex-start;
  align-items: flex-start;
}

.msg__bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg--user .msg__bubble {
  background: var(--pine);
  color: var(--user-ink);
  border-bottom-right-radius: 5px;
}

.msg--agent .msg__bubble {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}

.msg__bubble a {
  color: var(--terracotta);
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid rgba(191, 90, 53, 0.35);
  word-break: break-all;
}

.msg__meta {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 6px;
  font-size: 11px;
  color: var(--ink-faint);
}

.msg__meta .tag {
  color: var(--pine);
  background: rgba(47, 74, 63, 0.08);
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.03em;
}

.msg__sources {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 1px 4px 0;
}

.source {
  font-size: 10px;
  color: var(--pine);
  background: rgba(47, 74, 63, 0.06);
  border: 1px solid rgba(47, 74, 63, 0.14);
  padding: 2px 9px;
  border-radius: 999px;
  text-transform: capitalize;
  letter-spacing: 0.01em;
}

/* welcome */
.welcome {
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
}

.welcome > * {
  animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

/* rotating emblem, a nod to the byld flywheel */
.emblem {
  position: relative;
  width: 128px;
  height: 128px;
  display: grid;
  place-items: center;
}

.emblem__ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: var(--ink-soft);
  animation: rotate 30s linear infinite;
}

.emblem__ring text {
  font-family: var(--font);
  font-size: 8.4px;
  font-weight: 500;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}

.emblem__core {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--pine);
}

.emblem__core svg {
  width: 34px;
  height: 34px;
}

.emblem__core .peak {
  fill: none;
  stroke: #f4efe3;
  stroke-width: 2;
  stroke-linejoin: round;
}

.emblem__core .sun {
  fill: var(--terracotta);
}

@keyframes rotate {
  to { transform: rotate(360deg); }
}

.welcome__title {
  font-family: var(--display);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.welcome__title em {
  font-style: italic;
  color: var(--terracotta);
}

.welcome__sub {
  margin: -8px auto 4px;
  max-width: 300px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.chips {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  width: 100%;
}

.chip {
  max-width: 92%;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
  animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.25, 1) both;
  transition: transform 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.chip:hover {
  transform: translateY(-2px);
  border-color: var(--terracotta);
  color: var(--terracotta);
}

/* thinking indicator, quiet by design */
.dots {
  display: inline-flex;
  gap: 5px;
  padding: 15px 17px;
}

.dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-faint);
  animation: pulse 1.3s ease-in-out infinite;
}

.dots span:nth-child(2) { animation-delay: 0.18s; }
.dots span:nth-child(3) { animation-delay: 0.36s; }

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

/* composer */
.composer {
  padding: 14px 16px 8px;
  border-top: 1px solid var(--line);
}

.composer__field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 5px 5px 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.composer__field:focus-within {
  border-color: var(--pine-soft);
  box-shadow: 0 0 0 3px rgba(47, 74, 63, 0.1);
}

.composer__input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink);
  padding: 9px 10px;
  font-size: 14.5px;
  font-family: inherit;
  outline: none;
}

.composer__input::placeholder {
  color: var(--ink-faint);
}

.composer__send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--terracotta);
  color: #fbf5ec;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.16s ease, background 0.16s ease;
}

.composer__send:hover:not(:disabled) {
  transform: translateX(1px);
  background: #a94d2c;
}

.composer__send:disabled {
  opacity: 0.4;
  cursor: default;
}

.composer__send svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.disclaimer {
  margin: 0;
  padding: 4px 16px 14px;
  text-align: center;
  font-size: 10.5px;
  color: var(--ink-faint);
}

@media (prefers-reduced-motion: reduce) {
  .emblem__ring,
  .status__dot,
  .dots span { animation: none; }
}
