:root {
  --cimed-yellow: #f5c400;
  --cimed-yellow-deep: #e0b200;
  --cimed-yellow-soft: #ffe89a;
  --ink: #1c1d1a;
  --ink-soft: #5a5c54;
  --surface: #ffffff;
  --bg: #f7f6f1;
  --border: #e9e7dd;
  --agent-bubble: #ffffff;
  --shadow-sm: 0 1px 2px rgba(28, 29, 26, 0.06);
  --shadow-md: 0 10px 30px rgba(28, 29, 26, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Figtree", -apple-system, sans-serif;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(
      circle at 100% 0%,
      rgba(245, 196, 0, 0.22),
      transparent 42%
    ),
    radial-gradient(
      circle at 0% 100%,
      rgba(245, 196, 0, 0.1),
      transparent 38%
    ),
    radial-gradient(rgba(28, 29, 26, 0.05) 1px, transparent 1px);
  background-size: auto, auto, 22px 22px;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 860px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 0 16px;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 4px 14px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-family: "Sora", sans-serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
  background: linear-gradient(145deg, var(--cimed-yellow), var(--cimed-yellow-deep));
  box-shadow: 0 6px 16px rgba(245, 196, 0, 0.4);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-name {
  font-family: "Sora", sans-serif;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.3px;
}

.brand-sub {
  font-size: 12.5px;
  color: var(--ink-soft);
  font-weight: 500;
  margin-top: 2px;
}

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

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 6px 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2bbf6a;
  box-shadow: 0 0 0 3px rgba(43, 191, 106, 0.18);
}

.status.is-busy .status-dot {
  background: var(--cimed-yellow-deep);
  box-shadow: 0 0 0 3px rgba(245, 196, 0, 0.25);
}

.status.is-error .status-dot {
  background: #e0533c;
  box-shadow: 0 0 0 3px rgba(224, 83, 60, 0.2);
}

.btn-clear {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.btn-clear:hover {
  color: var(--ink);
  border-color: var(--cimed-yellow);
}

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

.thread::-webkit-scrollbar {
  width: 8px;
}
.thread::-webkit-scrollbar-thumb {
  background: rgba(28, 29, 26, 0.14);
  border-radius: 8px;
}

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

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

.msg .bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg .meta {
  font-size: 11.5px;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 0 6px;
}

/* Mensagem do agente */
.msg.agent {
  align-self: flex-start;
}
.msg.agent .bubble {
  background: var(--agent-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm);
}

/* Mensagem do usuario */
.msg.user {
  align-self: flex-end;
  align-items: flex-end;
}
.msg.user .bubble {
  background: linear-gradient(145deg, var(--cimed-yellow), var(--cimed-yellow-deep));
  color: var(--ink);
  border-bottom-right-radius: 6px;
  font-weight: 500;
  box-shadow: 0 6px 16px rgba(245, 196, 0, 0.32);
}

/* Mensagem de erro */
.msg.error .bubble {
  background: #fdecea;
  border: 1px solid #f4c4ba;
  color: #9a2d18;
}

/* Indicador de digitacao */
.typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 14px 18px;
}
.typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cimed-yellow-deep);
  animation: blink 1.2s infinite ease-in-out both;
}
.typing span:nth-child(2) {
  animation-delay: 0.18s;
}
.typing span:nth-child(3) {
  animation-delay: 0.36s;
}
@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

/* ---------- Composer ---------- */
.composer {
  padding: 10px 0 18px;
}

.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 8px 8px 8px 18px;
  box-shadow: var(--shadow-md);
  transition: border-color 0.15s ease;
}

.composer-inner:focus-within {
  border-color: var(--cimed-yellow);
  box-shadow: var(--shadow-md), 0 0 0 4px rgba(245, 196, 0, 0.16);
}

.input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: transparent;
  max-height: 160px;
  padding: 8px 0;
}

.input::placeholder {
  color: #a3a59c;
}

.send {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: linear-gradient(145deg, var(--cimed-yellow), var(--cimed-yellow-deep));
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease;
  box-shadow: 0 6px 14px rgba(245, 196, 0, 0.4);
}

.send:hover:not(:disabled) {
  transform: translateY(-1px);
}
.send:active:not(:disabled) {
  transform: translateY(0);
}
.send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.hint {
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-soft);
  margin: 9px 0 0;
}

.hint kbd {
  font-family: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 11px;
}

@media (max-width: 600px) {
  .msg {
    max-width: 88%;
  }
  .brand-sub {
    font-size: 12px;
  }
}
