:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --green: #008069;
  --green-dark: #075e54;
  --mint: #d9fdd3;
  --line: #d8dbd6;
  --text: #202c33;
  --muted: #667781;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #efeae2;
  color: var(--text);
}

.phone {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr) auto;
  position: relative;
  overflow: hidden;
  background: #efeae2;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  background: var(--green-dark);
  color: white;
  z-index: 3;
}

.star {
  width: 34px;
  height: 34px;
  display: none;
  place-items: center;
  font-size: 24px;
  color: #ffd54a;
  opacity: 0;
  transform: scale(0.86);
  transition: opacity 160ms ease, transform 160ms ease;
}

.star.online {
  display: grid;
  opacity: 1;
  transform: scale(1);
}

.hidden {
  display: none !important;
}

.login-panel {
  position: absolute;
  inset: 64px 0 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #efeae2;
  z-index: 5;
}

.login-box {
  width: min(100%, 330px);
  display: grid;
  gap: 10px;
}

.login-box input,
#textInput {
  width: 100%;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 16px;
  background: white;
  outline: none;
}

.login-box input:focus,
#textInput:focus {
  border-color: #8ed4c6;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 700;
  color: white;
  background: var(--green);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.login-msg {
  min-height: 20px;
  font-size: 13px;
  color: #b3261e;
  text-align: center;
}

.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 12px 10px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-image:
    radial-gradient(circle at 15px 15px, rgb(0 0 0 / 3%) 1px, transparent 1px),
    radial-gradient(circle at 40px 35px, rgb(0 0 0 / 2%) 1px, transparent 1px);
  background-size: 56px 56px;
}

.bubble {
  max-width: 86%;
  position: relative;
  display: grid;
  gap: 5px;
  padding: 8px 10px 7px;
  border-radius: 8px;
  background: white;
  box-shadow: 0 1px 0.5px rgb(0 0 0 / 13%);
  touch-action: manipulation;
}

.bubble.mine {
  align-self: flex-end;
  background: var(--mint);
}

.bubble.theirs {
  align-self: flex-start;
}

.bubble.selected {
  outline: 2px solid rgb(0 128 105 / 28%);
  margin-bottom: 42px;
}

.content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.38;
}

.quote {
  display: grid;
  gap: 2px;
  padding: 7px 8px 7px 10px;
  border-left: 4px solid var(--green);
  border-radius: 6px;
  background: rgb(0 128 105 / 9%);
}

.mine .quote {
  background: rgb(255 255 255 / 55%);
}

.quote-content {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: #526068;
}

.bubble img {
  display: block;
  max-width: 320px;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 6px;
  background: #dde2dd;
}

.meta {
  justify-self: end;
  font-size: 11px;
  color: var(--muted);
}

.message-actions {
  position: absolute;
  bottom: -42px;
  right: 0;
  display: none;
  grid-template-columns: repeat(2, max-content);
  gap: 6px;
  padding: 5px;
  border-radius: 8px;
  background: rgb(32 44 51 / 92%);
  box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
  z-index: 4;
}

.theirs .message-actions {
  right: auto;
  left: 0;
}

.selected .message-actions {
  display: grid;
}

.message-actions button {
  min-width: 58px;
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 6px;
  background: transparent;
  color: white;
  font-size: 14px;
  white-space: nowrap;
}

.message-actions button:hover,
.message-actions button:focus-visible {
  background: rgb(255 255 255 / 14%);
}

.composer {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 64px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px max(8px, env(safe-area-inset-bottom));
  background: #f0f2f5;
  border-top: 1px solid var(--line);
}

.reply-preview {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 6px 6px 6px 8px;
  border-radius: 8px;
  background: white;
}

.reply-strip {
  width: 4px;
  height: 100%;
  border-radius: 99px;
  background: var(--green);
}

.reply-text {
  min-width: 0;
}

.reply-content {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: #526068;
}

.cancel-reply {
  width: 30px;
  height: 30px;
  min-height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  padding: 0;
  background: #e9edef;
  color: #54656f;
  font-size: 20px;
  line-height: 1;
}

.cancel-reply:hover {
  background: #dde3e6;
}

.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #54656f;
  cursor: pointer;
  font-size: 30px;
  line-height: 1;
}

.icon-btn:hover {
  background: #e1e6e8;
}

.icon-btn input {
  display: none;
}

@media (hover: hover) {
  .bubble:hover {
    outline: 2px solid rgb(0 128 105 / 16%);
  }
}

@media (min-width: 760px) {
  body {
    display: grid;
    place-items: center;
    background:
      linear-gradient(#00a884 0 130px, transparent 130px),
      #e5ddd5;
  }

  .phone {
    width: min(calc(100vw - 48px), 920px);
    height: min(calc(100vh - 48px), 760px);
    min-height: 560px;
    box-shadow: 0 18px 48px rgb(0 0 0 / 20%);
  }

  .messages {
    padding: 18px 24px;
  }

  .bubble {
    max-width: min(72%, 560px);
  }
}

@supports (height: 100dvh) {
  .phone {
    height: 100dvh;
    min-height: 100dvh;
  }

  @media (min-width: 760px) {
    .phone {
      height: min(calc(100dvh - 48px), 760px);
      min-height: 560px;
    }
  }
}
