:root {
  --sage: #a3b19b;
  --sage-dark: #86967d;
  --sage-soft: #dce2d9;
  --honey: #f59e0b;
  --text: #1c1e21;
  --muted: #94a3b8;
  --page: #ffffff;
  --white: #ffffff;
  --shadow: rgba(28, 30, 33, .14);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--page);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  color: var(--text);
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--page);
}

#app::before {
  content: "";
  position: fixed;
  z-index: 4;
  top: 0;
  left: 0;
  right: 0;
  height: calc(env(safe-area-inset-top) + 152px);
  pointer-events: none;
  background: linear-gradient(180deg, #ffffff 0%, #ffffff 34%, rgba(255,255,255,.92) 68%, rgba(255,255,255,0) 100%);
}

#chatWindow {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: calc(env(safe-area-inset-top) + 96px) 12px 60px;
  background: var(--page);
}

#messagesContainer {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
}

.floating,
.composer {
  position: fixed;
  left: 12px;
  right: 12px;
  z-index: 5;
}

.header-island {
  top: calc(env(safe-area-inset-top) + 8px);
  min-height: 64px;
  padding: 10px 10px 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,.96);
  border-radius: 20px;
  box-shadow: 0 8px 24px var(--shadow);
}

.user-info {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--sage);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}

.details {
  min-width: 0;
}

.name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  line-height: 20px;
  font-weight: 700;
}

.status {
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  line-height: 15px;
  color: var(--muted);
}

.small-round,
.round-btn {
  border: 0;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--white);
  color: var(--muted);
  box-shadow: 0 4px 16px rgba(28,30,33,.12);
}

.small-round {
  width: 40px;
  height: 40px;
  font-size: 16px;
  font-weight: 800;
}

.composer {
  bottom: max(-8px, calc(6px - env(safe-area-inset-bottom)));
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.composer > * {
  pointer-events: auto;
}

.round-btn {
  width: 50px;
  height: 50px;
}

.round-btn.primary {
  background: var(--sage);
  color: #fff;
}

.round-btn svg,
.small-round svg,
.play-btn svg {
  width: 24px;
  height: 24px;
  display: block;
  fill: currentColor;
}

.input-island {
  height: 50px;
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-radius: 25px;
  background: var(--white);
  box-shadow: 0 4px 16px rgba(28,30,33,.12);
}

#messageInput {
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
  color: var(--text);
}

#messageInput::placeholder {
  color: var(--muted);
}

.message-row {
  display: flex;
  width: 100%;
}

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

.message-row.other {
  justify-content: flex-start;
}

.bubble {
  max-width: 76%;
  min-width: 64px;
  padding: 10px 12px 8px;
  border-radius: 16px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(28,30,33,.08);
  overflow: hidden;
}

.mine .bubble {
  border-bottom-right-radius: 4px;
  background: var(--sage);
  color: #fff;
}

.other .bubble {
  border-bottom-left-radius: 4px;
}

.time {
  margin-top: 4px;
  text-align: right;
  font-size: 10px;
  line-height: 12px;
  color: currentColor;
  opacity: .72;
}

.media-img,
.media-video {
  width: min(76vw, 420px);
  max-height: 58vh;
  object-fit: cover;
  display: block;
  border-radius: 14px;
  background: #111;
}

.bubble:has(.media-img),
.bubble:has(.media-video) {
  padding: 0;
  line-height: 0;
}

.voice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 214px;
  padding: 10px;
}

.bubble:has(.voice) {
  padding: 0;
}

.play-btn {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--sage);
  box-shadow: 0 3px 10px rgba(28,30,33,.12);
}

.other .play-btn {
  background: var(--sage);
  color: #fff;
}

.voice-wave {
  height: 22px;
  min-width: 136px;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  color: currentColor;
}

.voice-bar {
  width: 3px;
  min-height: 4px;
  border-radius: 2px;
  background: currentColor;
  opacity: .32;
  transition: opacity .05s linear;
}

.voice-bar.played {
  opacity: .95;
}

.sheet {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(58px, calc(72px - env(safe-area-inset-bottom)));
  z-index: 8;
  padding: 10px;
  border-radius: 20px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 18px 50px rgba(28,30,33,.18);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.sheet.hidden {
  display: none;
}

.sheet button {
  border: 0;
  min-height: 58px;
  border-radius: 14px;
  background: var(--sage-soft);
  color: var(--text);
  font-weight: 700;
}
