:root {
  --ink: #07121f;
  --ink-2: #0c1c30;
  --panel: #11263d;
  --foam: #e8f4ff;
  --mist: #9bb6ce;
  --mint: #3dffc2;
  --coral: #ff6b4a;
  --amber: #ffc857;
  --line: rgba(232, 244, 255, 0.12);
  --font-display: "Syne", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, sans-serif;
  --radius: 18px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body.chat-page {
  font-family: var(--font-body);
  color: var(--foam);
  background:
    radial-gradient(70% 45% at 15% -10%, rgba(255, 200, 87, 0.16), transparent 55%),
    radial-gradient(55% 40% at 95% 20%, rgba(61, 255, 194, 0.12), transparent 50%),
    var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.chat-page.is-embed {
  min-height: 100dvh;
}

.chat-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 920px;
  margin: 0 auto;
  padding: clamp(0.75rem, 3vw, 1.25rem);
}

.chat-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.chat-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.chat-brand img {
  width: 36px;
  height: 36px;
}

.chat-brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 3vw, 1.55rem);
  letter-spacing: -0.03em;
}

.chat-brand p {
  margin: 0.2rem 0 0;
  color: var(--mist);
  font-size: 0.92rem;
  max-width: 36rem;
}

.chat-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.chat-controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--mist);
}

.chat-controls select {
  border: 1px solid var(--line);
  background: rgba(17, 38, 61, 0.9);
  color: var(--foam);
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  font: inherit;
}

.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(12, 28, 48, 0.82);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chat-feed {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 280px;
  max-height: calc(100dvh - 220px);
}

.bubble {
  max-width: 88%;
  padding: 0.75rem 0.95rem;
  border-radius: 16px;
  font-size: 0.96rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble.user {
  align-self: flex-end;
  background: rgba(61, 255, 194, 0.14);
  border: 1px solid rgba(61, 255, 194, 0.35);
}

.bubble.assistant {
  align-self: flex-start;
  background: rgba(17, 38, 61, 0.95);
  border: 1px solid var(--line);
}

.bubble.system {
  align-self: center;
  color: var(--mist);
  font-size: 0.85rem;
  background: transparent;
  border: 0;
  text-align: center;
}

.bubble.thinking {
  opacity: 0.7;
  font-style: italic;
}

.chat-compose {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--line);
  background: rgba(7, 18, 31, 0.65);
}

.chat-compose input[type="text"] {
  flex: 1 1 12rem;
  min-width: 0;
  border: 1px solid var(--line);
  background: rgba(17, 38, 61, 0.85);
  color: var(--foam);
  border-radius: 999px;
  padding: 0.75rem 1rem;
  font: inherit;
}

.chat-compose input:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 2px;
}

.chat-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.chat-btn:hover {
  transform: translateY(-1px);
}

.chat-btn:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 2px;
}

.chat-btn-mint {
  background: var(--mint);
  color: #042017;
}

.chat-btn-ghost {
  background: rgba(17, 38, 61, 0.9);
  color: var(--foam);
  border: 1px solid var(--line);
}

.chat-btn.is-active {
  background: var(--coral);
  color: #fff;
}

.chat-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.chat-footer {
  margin-top: 0.55rem;
  font-size: 0.78rem;
  color: var(--mist);
  text-align: center;
}

.chat-footer a {
  color: var(--mint);
}

body[dir="rtl"] .bubble.user {
  align-self: flex-start;
}

body[dir="rtl"] .bubble.assistant {
  align-self: flex-end;
}

@media (max-width: 560px) {
  .chat-feed {
    max-height: calc(100dvh - 240px);
  }

  .chat-btn span.label {
    display: none;
  }
}
