:root {
  font-size: 1.125rem;
  --bg0: #FFF;
  --bg1: rgba(206,206,206,.5);
  --bg2: #e74266;
  --fg0: #000;
  --fg1: rgba(0,0,0,.5);
  --a0: #0076FF;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg0: #0a0a0a;
    --bg1: rgba(206,206,206,.125);
    --bg2: #e74266;
    --fg0: #FFF;
    --fg1: rgba(206,206,206,.5);
  }
}

@media (min-width: 600px) { :root { font-size: 1.25rem; } }
@media (min-width: 900px) { :root { font-size: 1.5rem; } }

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

body, html {
  background: var(--bg0);
  color: var(--fg0);
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, sans-serif;
  height: 100%;
  position: relative;
}

.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  padding-bottom: 1rem;
}

.input-area {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem;
  background: var(--bg0);
  border-top: 1px solid var(--bg1);
  display: flex;
  gap: .5rem;
  flex-shrink: 0;
}

.message-row {
  display: flex;
  margin-bottom: .25rem;
}

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

.bubble {
  overflow: hidden;
  display: inline-block;
  margin: 0 0 .125rem 0;
  padding: .5rem .85rem;
  line-height: 1.25rem;
  border-radius: 1.25rem;
  transform-origin: 0 100%;
  vertical-align: middle;
  max-width: 85%;
}

.bubble.left {
  background: var(--bg1);
  border-bottom-left-radius: 0;
}

.bubble.right {
  background: var(--bg2);
  color: #fff;
  border-bottom-right-radius: 0;
  transform-origin: 100% 100%;
}

.bubble span.message {
  display: inline;
  line-height: 1.3;
}

.bubble .loading {
  white-space: pre;
  font-size: 1.5rem;
  line-height: 1rem;
}

.bubble .loading b {
  display: inline-block;
  color: var(--fg1);
  animation: pulse .6s infinite alternate;
}

.bubble .loading b:nth-child(2) { animation-delay: .1s; }
.bubble .loading b:nth-child(3) { animation-delay: .2s; }

@keyframes pulse {
  to {
    opacity: .3;
    transform: scale(.8);
  }
}

.input-area input {
  flex: 1;
  padding: .6rem 1rem;
  border: 1px solid var(--bg1);
  border-radius: 1.5rem;
  font-size: 1rem;
  background: var(--bg0);
  color: var(--fg0);
  outline: none;
}

.input-area input:focus {
  border-color: var(--bg2);
}

.input-area button {
  padding: .6rem 1.2rem;
  border: none;
  border-radius: 1.5rem;
  background: var(--bg2);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}

.input-area button:disabled {
  opacity: .5;
  cursor: not-allowed;
}
