:root {
  color-scheme: dark;
  --bg: #02030a;
  --bg-deep: #050716;
  --panel: rgba(12, 16, 29, 0.82);
  --panel-strong: rgba(14, 19, 34, 0.95);
  --panel-soft: rgba(10, 14, 24, 0.8);
  --text: #f6fbff;
  --muted: #a8b4d2;
  --cyan: #5ff3ff;
  --cyan-soft: rgba(95, 243, 255, 0.14);
  --magenta: #ff4fd8;
  --magenta-soft: rgba(255, 79, 216, 0.14);
  --lime: #cbff6f;
  --rainbow-band: linear-gradient(
    90deg,
    #ff5f6d 0%,
    #ffb347 16%,
    #fff56b 32%,
    #54ffb0 48%,
    #5ff3ff 64%,
    #7f7dff 82%,
    #ff6fe3 100%
  );
  --line: rgba(123, 147, 194, 0.2);
  --line-strong: rgba(95, 243, 255, 0.38);
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
  --glow: 0 0 0 1px rgba(95, 243, 255, 0.08), 0 0 34px rgba(95, 243, 255, 0.1);
  --radius-xl: 34px;
  --radius-lg: 28px;
  --radius-md: 22px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI Variable", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top center, rgba(95, 243, 255, 0.12), transparent 24%),
    radial-gradient(circle at 82% 14%, rgba(255, 79, 216, 0.12), transparent 20%),
    radial-gradient(circle at 50% 8%, rgba(255, 213, 91, 0.14), transparent 26%),
    radial-gradient(circle at 18% 20%, rgba(203, 255, 111, 0.06), transparent 18%),
    linear-gradient(180deg, #060810 0%, #02030a 56%, #010106 100%);
  overflow-x: hidden;
  position: relative;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background:
    linear-gradient(rgba(95, 243, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(95, 243, 255, 0.07) 1px, transparent 1px);
  background-size: 58px 58px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 90%);
  opacity: 0.38;
}

body::after {
  background:
    radial-gradient(circle at center, transparent 0 62%, rgba(0, 0, 0, 0.5) 100%),
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.02) 0 2px,
      transparent 2px 4px
    );
  opacity: 0.5;
}

.app-shell {
  min-height: 100vh;
  padding: 24px 22px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar,
.chat-log,
.composer-shell {
  width: min(100%, 980px);
  margin-left: auto;
  margin-right: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(14, 19, 34, 0.92), rgba(8, 11, 20, 0.92)) padding-box,
    var(--rainbow-band) border-box;
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(18px);
  position: relative;
  overflow: hidden;
}

.topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(255, 95, 109, 0.08), transparent 24%, rgba(95, 243, 255, 0.08) 58%, rgba(255, 111, 227, 0.08));
  pointer-events: none;
}

.brand-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand-subtitle {
  margin: 0;
  max-width: 42rem;
  color: rgba(246, 251, 255, 0.82);
  font-size: 0.98rem;
  line-height: 1.55;
}

.status-line,
.message-author,
.composer-hint {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--muted);
}

.status-line {
  background: var(--rainbow-band);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 18px rgba(95, 243, 255, 0.12);
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 0.92;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-family: "Eurostile", "Avenir Next Condensed", "Space Grotesk", sans-serif;
  color: var(--text);
  text-shadow:
    0 0 30px rgba(95, 243, 255, 0.22),
    0 0 60px rgba(255, 79, 216, 0.08);
}

.exit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  color: var(--cyan);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  background: rgba(9, 12, 22, 0.78);
  border: 1px solid var(--line-strong);
  box-shadow: var(--glow);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.exit-button:hover,
.exit-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(69, 229, 255, 0.52);
  box-shadow:
    var(--glow),
    0 0 30px rgba(69, 229, 255, 0.18);
  outline: none;
}

.chat-stage {
  flex: 1;
  min-height: 0;
}

.chat-log {
  height: calc(100vh - 318px);
  overflow-y: auto;
  padding: 28px 18px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(9, 13, 23, 0.92), rgba(4, 7, 14, 0.94)) padding-box,
    linear-gradient(120deg, rgba(95, 243, 255, 0.26), rgba(255, 95, 109, 0.18), rgba(127, 125, 255, 0.22), rgba(84, 255, 176, 0.22)) border-box;
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.02),
    0 0 42px rgba(95, 243, 255, 0.06);
  scrollbar-width: thin;
  scrollbar-color: rgba(95, 243, 255, 0.25) transparent;
  position: relative;
  isolation: isolate;
}

.chat-log::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 95, 109, 0.08), transparent 18%),
    radial-gradient(circle at 88% 10%, rgba(95, 243, 255, 0.1), transparent 20%),
    radial-gradient(circle at 54% 0%, rgba(255, 245, 107, 0.06), transparent 28%);
  pointer-events: none;
  z-index: 0;
}

.chat-log > * {
  position: relative;
  z-index: 1;
}

.message {
  max-width: min(78%, 740px);
  padding: 18px 20px;
  border-radius: 26px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise-in 220ms ease both;
  backdrop-filter: blur(14px);
}

.message--assistant {
  align-self: flex-start;
  background:
    linear-gradient(180deg, rgba(15, 21, 37, 0.96), rgba(8, 12, 21, 0.94));
  border-color: rgba(95, 243, 255, 0.2);
  box-shadow:
    var(--shadow),
    inset 2px 0 0 rgba(95, 243, 255, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.message--assistant .message-author {
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(95, 243, 255, 0.22);
}

.message--user {
  align-self: flex-end;
  background:
    linear-gradient(180deg, rgba(31, 17, 45, 0.95), rgba(15, 10, 26, 0.94));
  border-color: rgba(255, 79, 216, 0.22);
  box-shadow:
    var(--shadow),
    inset -2px 0 0 rgba(255, 79, 216, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.message--user .message-author {
  color: #ff9aea;
  text-shadow: 0 0 16px rgba(255, 79, 216, 0.22);
}

.message p {
  margin: 0;
  font-size: 1.04rem;
  line-height: 1.72;
}

.message-author {
  margin-bottom: 8px;
}

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

.typing span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(95, 243, 255, 0.82);
  box-shadow: 0 0 18px rgba(95, 243, 255, 0.36);
  animation: pulse 900ms infinite ease-in-out;
}

.typing span:nth-child(2) {
  animation-delay: 120ms;
}

.typing span:nth-child(3) {
  animation-delay: 240ms;
}

.composer-shell {
  position: sticky;
  bottom: 18px;
  padding-top: 8px;
}

.composer-hint {
  margin-bottom: 10px;
  padding-left: 8px;
  color: rgba(246, 251, 255, 0.62);
}

.chat-form {
  padding: 18px 20px 16px;
  border-radius: var(--radius-xl);
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(23, 28, 46, 0.96), rgba(12, 15, 26, 0.98)) padding-box,
    linear-gradient(120deg, rgba(255, 95, 109, 0.36), rgba(255, 245, 107, 0.28), rgba(95, 243, 255, 0.34), rgba(255, 79, 216, 0.34)) border-box;
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    0 0 40px rgba(95, 243, 255, 0.08);
  position: relative;
  overflow: hidden;
}

.chat-form::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, rgba(95, 243, 255, 0.8), rgba(255, 79, 216, 0.45), transparent 92%);
}

.chat-form::after {
  content: "";
  position: absolute;
  inset: auto -18% -52% 36%;
  height: 180px;
  background: radial-gradient(circle, rgba(95, 243, 255, 0.22), rgba(255, 79, 216, 0.12), transparent 68%);
  filter: blur(22px);
  pointer-events: none;
}

.composer {
  display: block;
}

textarea {
  width: 100%;
  resize: none;
  border: 0;
  background: transparent;
  color: var(--text);
  min-height: 88px;
  max-height: 220px;
  padding: 8px 2px 20px;
  font: inherit;
  font-size: clamp(1.15rem, 2vw, 1.3rem);
  line-height: 1.55;
}

textarea::placeholder {
  color: rgba(246, 251, 255, 0.58);
}

textarea:focus-visible {
  outline: none;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.composer-glyph {
  font-size: 2.6rem;
  line-height: 1;
  background: var(--rainbow-band);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 24px rgba(255, 79, 216, 0.18);
}

.send-button {
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 1.5rem;
  color: #041019;
  background:
    linear-gradient(135deg, #ff5f6d 0%, #ffcb57 20%, #65ffa9 40%, #5ff3ff 58%, #7f7dff 78%, #ff6fe3 100%);
  box-shadow:
    0 0 0 1px rgba(95, 243, 255, 0.16),
    0 0 24px rgba(95, 243, 255, 0.28);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    filter 180ms ease;
}

.send-button:hover,
.send-button:focus-visible {
  transform: translateY(-1px) scale(1.02);
  box-shadow:
    0 0 0 1px rgba(95, 243, 255, 0.2),
    0 0 32px rgba(95, 243, 255, 0.44);
  filter: saturate(1.08);
  outline: none;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 18px 14px 22px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .chat-log {
    height: calc(100vh - 360px);
    padding-left: 14px;
    padding-right: 14px;
  }

  .message {
    max-width: 100%;
  }

  .chat-form {
    padding: 16px 16px 14px;
  }

  .brand-subtitle {
    max-width: 100%;
  }

  textarea {
    min-height: 72px;
    font-size: 1.08rem;
  }
}
