:root {
  color-scheme: dark;
  --bg: #242424;
  --bg-raised: #2e2e2e;
  --ink: #f7f1f2;
  --muted: #b9aeb1;
  --pink: #f3a8bc;
  --pink-deep: #e48aa3;
  --bubble-me: #f3a8bc;
  --bubble-me-ink: #2a1820;
  --bubble-them: #353535;
  --line: rgba(243, 168, 188, 0.18);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Nunito, ui-rounded, ui-sans-serif, system-ui, sans-serif;
}

body {
  min-height: 100dvh;
}

#app {
  height: 100dvh;
  max-width: 42rem;
  margin: 0 auto;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.screen {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.who-screen {
  align-items: center;
  justify-content: center;
  padding: calc(2rem + var(--safe-top)) 1.5rem calc(2rem + var(--safe-bottom));
  text-align: center;
}

.who-screen .mascot {
  width: 168px;
  height: auto;
  margin-bottom: 0.4rem;
}

.brand {
  margin: 0;
  font-size: 2.15rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.who-row {
  display: flex;
  gap: 0.8rem;
  width: min(22rem, 100%);
  margin-top: 1.4rem;
}

.who-btn {
  flex: 1;
  border: 0;
  border-radius: 1.4rem;
  padding: 0.95rem 0.75rem;
  background: var(--bg-raised);
  color: var(--ink);
  font-weight: 800;
  font-size: 1.05rem;
}

.who-btn:hover,
.who-btn:focus-visible {
  background: var(--pink);
  color: var(--bubble-me-ink);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: calc(0.7rem + var(--safe-top)) 1rem 0.7rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.chat-header .mascot {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.header-copy {
  min-width: 0;
  flex: 1;
}

.header-copy h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.header-copy p {
  margin: 0.05rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.switch-who {
  border: 0;
  background: transparent;
  color: var(--pink);
  font-weight: 800;
  font-size: 0.85rem;
  padding: 0.4rem;
}

.messages {
  flex: 1;
  overflow: auto;
  padding: 1rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 16rem;
}

.empty img {
  width: 120px;
  height: auto;
}

.empty p {
  margin: 0.4rem 0 0;
}

.day-label,
.new-label {
  align-self: center;
  margin: 0.55rem 0 0.15rem;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.new-label {
  color: var(--pink);
}

.bubble-row {
  display: flex;
}

.bubble-row.mine {
  justify-content: flex-end;
}

.bubble-stack {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-width: min(78%, 28rem);
}

.bubble-row.mine .bubble-stack {
  align-items: flex-end;
}

.bubble {
  width: fit-content;
  max-width: 100%;
  padding: 0.45rem 0.8rem;
  border-radius: 1.1rem;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble-row.mine .bubble {
  background: var(--bubble-me);
  color: var(--bubble-me-ink);
  border-bottom-right-radius: 0.35rem;
}

.bubble-row.theirs .bubble {
  background: var(--bubble-them);
  color: var(--ink);
  border-bottom-left-radius: 0.35rem;
}

.bubble-meta {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0 0.15rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.delete-msg {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.delete-msg:hover,
.delete-msg:focus-visible {
  color: var(--pink);
}

.bubble--image {
  padding: 0.3rem;
  overflow: hidden;
}

.bubble-image {
  display: block;
  max-width: min(70vw, 16rem);
  max-height: 18rem;
  border-radius: 0.85rem;
  object-fit: cover;
}

.bubble-text {
  display: block;
  padding: 0.15rem 0.35rem 0.2rem;
}

.bubble-image + .bubble-text {
  margin-top: 0.2rem;
}

.photo-preview {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem 0;
}

.photo-preview[hidden] {
  display: none;
}

.photo-preview img {
  width: 4.2rem;
  height: 4.2rem;
  object-fit: cover;
  border-radius: 0.8rem;
}

.photo-clear {
  width: 1.6rem;
  height: 1.6rem;
  border: 0;
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1;
}

.photo-btn {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 2.45rem;
  height: 2.7rem;
  border-radius: 999px;
  background: transparent;
  color: var(--pink);
  cursor: pointer;
}

.photo-btn input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.photo-btn svg {
  width: 1.25rem;
  height: 1.25rem;
}

.composer {
  display: flex;
  gap: 0.35rem;
  align-items: flex-end;
  padding: 0.75rem 0.9rem calc(0.75rem + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.composer textarea {
  flex: 1;
  resize: none;
  min-height: 2.7rem;
  max-height: 8rem;
  border: 0;
  border-radius: 1.2rem;
  padding: 0.7rem 0.95rem;
  background: var(--bg-raised);
  color: var(--ink);
  outline: none;
}

.composer textarea::placeholder {
  color: var(--muted);
}

.composer button[type='submit'] {
  flex: none;
  width: 2.7rem;
  height: 2.7rem;
  border: 0;
  border-radius: 999px;
  background: var(--pink);
  color: var(--bubble-me-ink);
  font-weight: 800;
  font-size: 1.15rem;
}

.composer button[type='submit']:disabled {
  opacity: 0.45;
}

.error {
  margin: 0 1rem 0.4rem;
  color: var(--pink-deep);
  font-size: 0.88rem;
}

.zzz {
  display: inline-block;
  margin-left: 0.2rem;
  color: var(--pink);
  animation: drift 2.4s ease-in-out infinite;
}

@keyframes drift {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  50% {
    transform: translateY(-4px);
    opacity: 1;
  }
}
