:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #e7edf5;
  color: #172033;
  --content-max: 960px;
  --side-pad: clamp(0.75rem, 4vw, 1.5rem);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 12% 0, rgba(80, 170, 255, 0.2), transparent 22rem),
    linear-gradient(180deg, #d9e8f6 0%, #e8eef6 45%, #d8e4ee 100%);
}

.shell {
  min-height: 100dvh;
}

.panel {
  display: flex;
  width: 100%;
  min-height: 100dvh;
  flex-direction: column;
  background: #e7edf5;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem var(--side-pad);
  border-bottom: 1px solid rgba(120, 143, 171, 0.28);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 8px rgba(45, 67, 94, 0.08);
  backdrop-filter: blur(14px);
}

.topbar-avatar {
  display: grid;
  width: 2.6rem;
  height: 2.6rem;
  flex: 0 0 2.6rem;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #2aabee, #229ed9);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 900;
}

h1,
.topbar p {
  margin: 0;
}

h1 {
  color: #142136;
  font-size: 1.05rem;
  line-height: 1.2;
}

.topbar p {
  color: #6a788b;
  font-size: 0.82rem;
}

.chat-log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.85rem;
  overflow-y: auto;
  padding: 1rem var(--side-pad) 1.25rem;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.45) 0 0.08rem, transparent 0.09rem),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.35) 0 0.08rem, transparent 0.09rem),
    #dbe8f2;
  background-size: 2.8rem 2.8rem;
}

.message-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-row {
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
}

.user-row {
  flex-direction: row-reverse;
}

.avatar {
  display: grid;
  width: 2.1rem;
  height: 2.1rem;
  flex: 0 0 2.1rem;
  place-items: center;
  border-radius: 50%;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.user-avatar {
  background: #5dbd73;
  color: #0d341a;
}

.bot-avatar {
  background: #2aabee;
  color: #ffffff;
}

.bubble {
  max-width: min(42rem, 76%);
  padding: 0.55rem 0.75rem 0.65rem;
  border-radius: 16px;
  box-shadow: 0 1px 1px rgba(32, 42, 68, 0.08);
  overflow-wrap: anywhere;
}

.user-bubble {
  border-bottom-right-radius: 4px;
  background: #d9fdd3;
  color: #142136;
}

.bot-bubble {
  border-bottom-left-radius: 4px;
  background: #ffffff;
  color: #22314a;
}

.is-safe .bot-bubble {
  border: 1px solid #b7ebc8;
  background: #eefcf4;
  color: #14532d;
}

.is-censored .bot-bubble {
  border: 1px solid #ffd0d8;
  background: #fff1f2;
  color: #8a1230;
}

.speaker {
  margin-bottom: 0.15rem;
  font-size: 0.72rem;
  font-weight: 900;
  color: #2a7fb4;
}

.bubble-text {
  margin: 0;
  line-height: 1.42;
}

.composer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 0.55rem var(--side-pad) 0.8rem;
  border-top: 1px solid rgba(120, 143, 171, 0.25);
  background: rgba(232, 238, 246, 0.94);
  backdrop-filter: blur(14px);
}

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

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 0.55rem;
}

textarea {
  width: 100%;
  max-height: 8rem;
  resize: none;
  padding: 0.82rem 1rem;
  border: 1px solid rgba(159, 177, 199, 0.42);
  border-radius: 20px;
  background: #ffffff;
  color: #172033;
  font: inherit;
}

textarea:focus {
  border-color: #6d5dfc;
  outline: 3px solid rgba(109, 93, 252, 0.18);
}

textarea:disabled {
  cursor: wait;
  opacity: 0.7;
}

.status {
  min-height: 1.15rem;
  margin: 0 0 0.3rem 0.25rem;
  color: #6a788b;
  font-size: 0.82rem;
}

button {
  display: grid;
  width: 3rem;
  height: 3rem;
  flex: 0 0 3rem;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #20a8ff 0%, #0788e8 100%);
  color: #ffffff;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 800;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 2px 5px rgba(11, 108, 184, 0.32);
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

button:hover:not(:disabled) {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 4px 10px rgba(11, 108, 184, 0.36);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  box-shadow:
    inset 0 1px 3px rgba(6, 68, 118, 0.28),
    0 1px 3px rgba(11, 108, 184, 0.28);
  transform: translateY(1px) scale(0.98);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.send-icon {
  width: 1.65rem;
  height: 1.65rem;
  margin-left: -0.1rem;
  fill: currentColor;
}

@media (max-width: 640px) {
  .bubble {
    max-width: calc(100% - 2.75rem);
  }

  .avatar {
    width: 1.95rem;
    height: 1.95rem;
    flex-basis: 1.95rem;
  }
}

@media (min-width: 900px) {
  :root {
    --side-pad: max(2rem, calc((100vw - var(--content-max)) / 2));
  }

  .panel {
    background:
      linear-gradient(90deg, rgba(37, 64, 94, 0.1), transparent 16%, transparent 84%, rgba(37, 64, 94, 0.1)),
      #e7edf5;
  }

  .chat-log {
    gap: 1rem;
  }

  .bubble {
    max-width: min(38rem, 70%);
  }
}
