:root {
  --hb-bg: #f5f7fb;
  --hb-panel: #ffffff;
  --hb-text: #142033;
  --hb-muted: #667085;
  --hb-border: #dfe6ef;
  --hb-primary: #0d6b78;
  --hb-primary-dark: #09515b;
  --hb-user: #0d6b78;
  --hb-assistant: #eef4f7;
  --hb-error: #b42318;
  --hb-success: #067647;
  --hb-shadow: 0 24px 70px rgba(16, 24, 40, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 0%, rgba(13, 107, 120, 0.18), transparent 35%),
    radial-gradient(circle at 85% 100%, rgba(9, 81, 91, 0.16), transparent 36%),
    var(--hb-bg);
  color: var(--hb-text);
}

button,
textarea {
  font: inherit;
}

.hb-app {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.hb-shell {
  width: min(100%, 760px);
  height: min(92vh, 860px);
  min-height: 620px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(223, 230, 239, 0.92);
  border-radius: 28px;
  box-shadow: var(--hb-shadow);
}

.hb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  background: linear-gradient(135deg, #082d38, #0d6b78);
  color: #ffffff;
}

.hb-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.hb-logo {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.hb-eyebrow {
  margin: 0 0 2px;
  font-size: 13px;
  line-height: 1.2;
  opacity: 0.82;
}

.hb-header h1 {
  margin: 0;
  font-size: clamp(20px, 4vw, 28px);
  line-height: 1.1;
  font-weight: 780;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hb-room-header {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.25;
  color: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hb-reset {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 9px 13px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  cursor: pointer;
}

.hb-reset:hover {
  background: rgba(255, 255, 255, 0.18);
}

.hb-status {
  padding: 10px 20px;
  border-bottom: 1px solid var(--hb-border);
  color: var(--hb-muted);
  font-size: 14px;
  background: #fbfcfe;
}

.hb-status.is-error {
  color: var(--hb-error);
  background: #fff4f2;
}

.hb-status.is-ready {
  color: var(--hb-success);
  background: #f3fbf7;
}

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

.hb-message {
  display: flex;
}

.hb-message-user {
  justify-content: flex-end;
}

.hb-message-assistant {
  justify-content: flex-start;
}

.hb-bubble {
  max-width: min(84%, 560px);
  padding: 13px 15px;
  border-radius: 18px;
  line-height: 1.48;
  font-size: 15px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.hb-message-assistant .hb-bubble {
  background: var(--hb-assistant);
  color: var(--hb-text);
  border-bottom-left-radius: 6px;
}

.hb-message-user .hb-bubble {
  background: var(--hb-user);
  color: #ffffff;
  border-bottom-right-radius: 6px;
}

.hb-message-system .hb-bubble {
  max-width: 100%;
  background: #fff4f2;
  color: var(--hb-error);
  border: 1px solid #fecdca;
}

.hb-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.hb-typing span {
  width: 7px;
  height: 7px;
  display: block;
  border-radius: 50%;
  background: var(--hb-muted);
  animation: hbPulse 1.1s infinite ease-in-out;
}

.hb-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.hb-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes hbPulse {
  0%, 80%, 100% { opacity: 0.28; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.hb-form {
  display: flex;
  gap: 10px;
  padding: 16px 20px 18px;
  border-top: 1px solid var(--hb-border);
  background: #ffffff;
}

.hb-form textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid var(--hb-border);
  border-radius: 16px;
  outline: none;
  color: var(--hb-text);
  background: #ffffff;
}

.hb-form textarea:focus {
  border-color: rgba(13, 107, 120, 0.65);
  box-shadow: 0 0 0 4px rgba(13, 107, 120, 0.12);
}

.hb-form textarea:disabled {
  background: #f2f4f7;
  cursor: not-allowed;
}

.hb-form button {
  min-width: 104px;
  border: 0;
  border-radius: 16px;
  padding: 0 18px;
  background: var(--hb-primary);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.hb-form button:hover:not(:disabled) {
  background: var(--hb-primary-dark);
}

.hb-form button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.hb-footer {
  padding: 0 20px 16px;
  color: var(--hb-muted);
  font-size: 13px;
  background: #ffffff;
}

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

@media (max-width: 640px) {
  .hb-app {
    padding: 0;
  }

  .hb-shell {
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    border-radius: 0;
    border: 0;
  }

  .hb-header {
    padding: 16px;
  }

  .hb-logo {
    width: 42px;
    height: 42px;
    border-radius: 14px;
  }

  .hb-reset {
    padding: 8px 10px;
    font-size: 13px;
  }

  .hb-room-header {
    font-size: 12px;
  }

  .hb-messages {
    padding: 18px 14px;
  }

  .hb-bubble {
    max-width: 90%;
  }

  .hb-form {
    padding: 12px 14px 14px;
  }

  .hb-form button {
    min-width: 86px;
    padding: 0 12px;
  }
}

/* Markdown rendering inside assistant messages */
.hb-message-assistant .hb-bubble p {
  margin: 0 0 10px;
}

.hb-message-assistant .hb-bubble p:last-child {
  margin-bottom: 0;
}

.hb-message-assistant .hb-bubble strong {
  font-weight: 760;
}

.hb-message-assistant .hb-bubble a {
  color: var(--hb-primary);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hb-message-assistant .hb-bubble a:hover {
  color: var(--hb-primary-dark);
}

.hb-message-assistant .hb-bubble ol,
.hb-message-assistant .hb-bubble ul {
  margin: 0 0 10px 20px;
  padding: 0;
}

.hb-message-assistant .hb-bubble li {
  margin: 4px 0;
}

.hb-md-spacer {
  height: 8px;
}
