:root {
  --bg: #070708;
  --bg-2: #0d0d0f;
  --panel: #121214;
  --panel-2: #18181b;
  --line: #2a2a2e;
  --line-soft: #1f1f23;
  --text: #ececef;
  --muted: #8b8b93;
  --soft: #b8b8c0;
  --white: #f5f5f7;
  --radius: 22px;
  --font-display: "Syne", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
}

.atmosphere {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 55% at 50% 18%, rgba(255, 255, 255, 0.05), transparent 55%),
    radial-gradient(ellipse 50% 40% at 80% 90%, rgba(255, 255, 255, 0.03), transparent 50%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  pointer-events: none;
  z-index: 0;
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.square {
  width: min(560px, 100%);
  aspect-ratio: 1 / 1;
  max-height: min(560px, 92dvh);
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.02) inset,
    0 30px 80px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 22px 22px 10px;
  border-bottom: 1px solid var(--line-soft);
}

.mark {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 4vw, 2rem);
  letter-spacing: 0.14em;
  color: var(--white);
  line-height: 1;
}

.tag {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.tag.is-live::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #cfcfd4;
  margin-right: 8px;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
  vertical-align: middle;
}

.modes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 12px 14px;
}

.mode {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 10px 0;
  border-radius: 12px;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.mode:hover {
  color: var(--soft);
  background: rgba(255, 255, 255, 0.03);
}

.mode.is-active {
  color: var(--white);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
}

.thread {
  flex: 1;
  overflow-y: auto;
  padding: 8px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.msg {
  max-width: 92%;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  animation: fadein 0.35s ease both;
}

@keyframes fadein {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.msg.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-soft);
  color: var(--soft);
}

.msg.user {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
}

.msg.media img,
.msg.media video {
  display: block;
  width: 100%;
  border-radius: 12px;
  margin-top: 8px;
  background: #000;
}

.msg code,
.msg pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
}

.msg pre {
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 10px;
  background: #0a0a0b;
  overflow-x: auto;
}

.composer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 14px;
  border-top: 1px solid var(--line-soft);
  background: rgba(0, 0, 0, 0.25);
}

.composer textarea {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 96px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  font: 500 0.95rem/1.35 var(--font-body);
  outline: none;
  transition: border-color 0.2s ease;
}

.composer textarea:focus {
  border-color: #4a4a52;
}

.composer textarea::placeholder {
  color: #5c5c66;
}

.send {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: var(--white);
  color: #111;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

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

.send:disabled {
  opacity: 0.4;
  cursor: wait;
  transform: none;
}

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

@media (max-width: 560px) {
  .stage {
    padding: 12px;
  }

  .square {
    aspect-ratio: auto;
    height: min(640px, 94dvh);
    max-height: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .square,
  .msg {
    animation: none;
  }
}
