

:root {
  --primary-color: #2563eb;
  --surface-muted: #f8fafc;
  --border: #dbe3f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --user-bubble: #e0edff;
  --assistant-bubble: #ffffff;
  --error: #b91c1c;
  --widget-font-family: "Trebuchet MS", "Avenir Next", sans-serif;
  --widget-font-size: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #ffffff;
  color: var(--text);
  font-family: var(--widget-font-family);
  font-size: var(--widget-font-size);
  line-height: 1.5;
}

.chat-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.chat-header {
  padding: 20px 20px 16px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 12px;
  position: relative;
}

.chat-title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-align: center;
}

.chat-heading {
  min-width: 0;
  text-align: center;
}

.chat-subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.9em;
  line-height: 1.35;
  white-space: pre-line;
  text-align: center;
}

.chat-header-actions {
  position: absolute;
  right: 16px;
  top: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-lang-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-lang-row[hidden] {
  display: none;
}

.chat-lang-button {
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.chat-lang-button:hover {
  background: color-mix(in srgb, var(--primary-color) 8%, transparent);
  transform: translateY(-1px);
}

.chat-lang-button[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--primary-color) 45%, var(--border));
  background: color-mix(in srgb, var(--primary-color) 10%, white);
}

.chat-icon {
  width: 18px;
  height: 18px;
  display: block;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

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

.message-content {
  display: flex;
  min-width: 0;
  max-width: 82%;
  flex-direction: column;
  align-items: flex-start;
}

.message {
  max-width: 82%;
  border-radius: 18px;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-content > .message {
  max-width: 100%;
}

.message.user {
  background: var(--user-bubble);
  padding: 10px 14px;
  border-bottom-right-radius: 18px;
}

.message.assistant {
  background: transparent;
  padding: 0;
  border-radius: 0;
}

.message.error {
  background: #fef2f2;
  color: var(--error);
  padding: 10px 14px;
}

.message.markdown {
  white-space: normal;
}

.message.markdown > :first-child {
  margin-top: 0;
}

.message.markdown > :last-child {
  margin-bottom: 0;
}

.message.markdown h1,
.message.markdown h2,
.message.markdown h3,
.message.markdown h4,
.message.markdown h5,
.message.markdown h6 {
  margin: 0.8em 0 0.35em;
  line-height: 1.25;
}

.message.markdown h1 {
  font-size: 1.45em;
}

.message.markdown h2 {
  font-size: 1.3em;
}

.message.markdown h3 {
  font-size: 1.15em;
}

.message.markdown p,
.message.markdown ul,
.message.markdown ol,
.message.markdown blockquote,
.message.markdown pre {
  margin: 0.55em 0;
}

.message.markdown ul,
.message.markdown ol {
  padding-left: 1.4em;
}

.message.markdown blockquote {
  border-left: 3px solid color-mix(in srgb, var(--primary-color) 45%, var(--border));
  padding-left: 0.8em;
  color: var(--text-muted);
}

.message.markdown code {
  border-radius: 5px;
  background: var(--surface-muted);
  padding: 0.12em 0.35em;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9em;
}

.message.markdown pre {
  overflow-x: auto;
  border-radius: 10px;
  background: #0f172a;
  color: #f8fafc;
  padding: 0.8em;
}

.message.markdown pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.message a {
  color: var(--primary-color);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.message.thinking {
  background: transparent;
  padding: 0;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  flex: 0 0 32px;
  object-fit: cover;
  background: #fff;
}

.message-feedback {
  display: flex;
  gap: 2px;
  margin: 6px 0 0;
}

.feedback-button {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  padding: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.62;
  transition: color 140ms ease, background 140ms ease, opacity 140ms ease;
}

.feedback-button:hover:not(:disabled),
.feedback-button:focus-visible,
.feedback-button.selected {
  background: color-mix(in srgb, var(--primary-color) 9%, transparent);
  color: var(--primary-color);
  opacity: 1;
}

.feedback-button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary-color) 30%, white);
  outline-offset: 1px;
}

.feedback-button:disabled {
  cursor: wait;
  opacity: 0.38;
}

.feedback-icon {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.feedback-button.negative .feedback-icon {
  transform: rotate(180deg);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 12px;
  background: transparent;
}

.chat-suggestions[hidden] {
  display: none;
}

.chat-suggestion {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid color-mix(in srgb, var(--primary-color) 24%, var(--border));
  border-radius: 12px;
  background: color-mix(in srgb, var(--primary-color) 5%, white);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.chat-suggestion::after {
  content: "→";
  flex: 0 0 auto;
  margin-left: 12px;
  color: var(--primary-color);
  font-size: 18px;
  line-height: 1;
}

.chat-suggestion:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--primary-color);
  background: color-mix(in srgb, var(--primary-color) 10%, white);
}

.chat-suggestion:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary-color) 35%, white);
  outline-offset: 2px;
}

.chat-suggestion:disabled {
  cursor: wait;
  opacity: 0.6;
}

.typing-indicator {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 116px;
}

.typing-label {
  font-size: 0.82em;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.typing-shimmer {
  position: relative;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, var(--primary-color) 14%, var(--surface-muted));
}

.typing-shimmer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -45%;
  width: 45%;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    transparent 0%,
    color-mix(in srgb, var(--primary-color) 85%, white) 50%,
    transparent 100%
  );
  animation: typing-shimmer-sweep 1.3s ease-in-out infinite;
}

@keyframes typing-shimmer-sweep {
  0% {
    left: -45%;
  }

  100% {
    left: 100%;
  }
}

.chat-compose {
  padding: 16px 20px 8px;
  background: #ffffff;
}

.chat-form {
  display: flex;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #ffffff;
  padding: 6px 8px 6px 18px;
}

.chat-input {
  flex: 1;
  min-height: 24px;
  max-height: 120px;
  resize: none;
  border: none;
  border-radius: 0;
  padding: 8px 0;
  color: var(--text);
  background: transparent;
  box-shadow: none;
  font: inherit;
}

.chat-input:focus {
  outline: none;
}

.chat-submit {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  width: 36px;
  flex: 0 0 36px;
  min-height: 36px;
  padding: 0;
  cursor: pointer;
  box-shadow: none;
  transition: color 160ms ease, background 160ms ease;
}

.chat-submit:hover:not(:disabled) {
  color: var(--primary-color);
  background: color-mix(in srgb, var(--primary-color) 8%, transparent);
}

.chat-submit:disabled {
  opacity: 0.6;
  cursor: wait;
  box-shadow: none;
}

.chat-submit-icon {
  width: 20px;
  height: 20px;
  display: block;
  margin: 0 auto;
}

.chat-submit.loading .chat-submit-icon {
  opacity: 0.5;
}

.chat-footer {
  padding: 10px 20px 16px;
  text-align: center;
  font-size: 0.82em;
  color: var(--text-muted);
}

.chat-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.chat-footer .chat-footer-brand {
  color: var(--user-buble);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-footer .chat-footer-reset {
  text-decoration: underline;
  text-underline-offset: 2px;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--text-muted);
  cursor: pointer;
}

.chat-footer-divider {
  margin: 0 6px;
}