:root {
  --ink:        #151A17;
  --ink-soft:   #5C6560;
  --ink-faint:  #8B948E;
  --page:       #f5f1f1;
  --surface:    #FFFFFF;
  --line:       #f0d8d8;
  --pine:       #c81e28;
  --pine-deep:  #a9141f;
  --bronze:     #8A6B33;
  --bronze-bg:  #fff1f1;
  --radius:     14px;
  --radius-sm:  9px;
}

* { box-sizing: border-box; }

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

body {
  background: var(--page);
  color: var(--ink);
  font-family: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- shell ---------- */
.shell {
  position: fixed;
  z-index: 10;
  right: 24px;
  bottom: 24px;
  width: min(420px, calc(100vw - 32px));
  height: min(680px, calc(100vh - 112px));
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.14);
  animation: panel-in .2s ease-out;
}

.shell[hidden] { display: none; }

@keyframes panel-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.launcher {
  position: fixed;
  z-index: 9;
  right: 24px;
  bottom: 24px;
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: linear-gradient(135deg, #d81f2a, #b7121c);
  color: #ffffff;
  box-shadow: 0 10px 26px rgba(200, 30, 40, 0.28);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.launcher:hover { background: linear-gradient(135deg, #e62431, #a50f18); }
.launcher:focus-visible, .close-button:focus-visible { outline: 2px solid #d61d2b; outline-offset: 3px; }
.launcher[aria-expanded="true"] { display: none; }
.launcher-icon { display: grid; place-items: center; }

.masthead {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.close-button {
  margin-left: auto;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}
.close-button:hover { background: #F3F6F4; color: var(--ink); }

.beta-notice {
  display: flex;
  gap: 8px;
  padding: 10px 18px;
  background: var(--bronze-bg);
  color: #674F26;
  font-size: 12px;
  line-height: 1.45;
  flex-shrink: 0;
}
.beta-notice strong { letter-spacing: .04em; }

.mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #fff1f1;
  border: 1px solid rgba(200, 30, 40, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.masthead h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

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

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4C9A6B;
  flex-shrink: 0;
}
.dot.busy  { background: var(--bronze); }
.dot.error { background: #B4483F; }

/* ---------- thread ---------- */
.thread {
  flex: 1;
  min-height: 280px;
  overflow-y: auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.empty {
  margin: auto 0;
  text-align: center;
  padding: 20px 4px;
}

.empty-lead {
  margin: 0 0 20px;
  color: var(--ink-soft);
  font-size: 15px;
  max-width: 38ch;
  margin-inline: auto;
}

.starters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.starter {
  font: inherit;
  font-size: 14px;
  color: var(--pine);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 7px 15px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.starter:hover { border-color: var(--pine); background: #F3F6F4; }
.starter:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; }

/* ---------- messages ---------- */
.msg { display: flex; flex-direction: column; max-width: 84%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.bot  { align-self: flex-start; align-items: flex-start; }

.bubble {
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg.user .bubble {
  background: var(--pine);
  color: #F2F6F4;
  border-bottom-right-radius: 3px;
}

.msg.bot .bubble {
  background: #F4F6F3;
  border: 1px solid var(--line);
  border-bottom-left-radius: 3px;
}

.msg.bot.error .bubble {
  background: #FBEEEC;
  border-color: #E6C4BE;
  color: #7A2E27;
}

.tag {
  font-size: 11.5px;
  color: var(--ink-faint);
  margin-top: 5px;
  padding-inline: 3px;
}
.tag.kb     { color: var(--pine); }
.tag.ai     { color: var(--bronze); }

/* ---------- suggestion chips ---------- */
.chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 9px;
  width: 100%;
}

.chip {
  font: inherit;
  font-size: 14px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  cursor: pointer;
  color: var(--ink);
  transition: border-color .15s, background .15s;
}
.chip:hover { border-color: var(--pine); background: #F3F6F4; }
.chip:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; }

/* ---------- typing ---------- */
.typing { display: flex; gap: 4px; padding: 14px 15px; }
.typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink-faint);
  animation: pulse 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .18s; }
.typing span:nth-child(3) { animation-delay: .36s; }

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

@media (prefers-reduced-motion: reduce) {
  .typing span { animation: none; opacity: .6; }
  .thread { scroll-behavior: auto; }
  .shell { animation: none; }
}

@media (max-width: 560px) {
  .shell {
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
  }

  .launcher {
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
}

/* ---------- composer ---------- */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.composer textarea {
  flex: 1;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #F4F6F3;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  resize: none;
  max-height: 140px;
  line-height: 1.5;
}
.composer textarea:focus {
  outline: none;
  border-color: var(--pine);
  background: var(--surface);
}

.composer button {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--pine);
  color: #F2F6F4;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s;
}
.composer button:hover:not(:disabled) { background: var(--pine-deep); }
.composer button:disabled { background: var(--ink-faint); cursor: not-allowed; }
.composer button:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; }

.composer-note {
  margin: 0;
  padding: 0 18px 12px;
  font-size: 12.5px;
  color: #B4483F;
  min-height: 18px;
}
