:root {
  --accent: #ea580c;
  --accent-2: #f97316;
  --accent-3: #e11d48;
  --grad: linear-gradient(135deg, #fb923c 0%, #f97316 35%, #ea580c 70%, #c2410c 100%);
  --accent-50: rgba(234, 88, 12, 0.08);
  --accent-100: rgba(234, 88, 12, 0.16);
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: rgba(15, 23, 42, 0.07);
  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --glass-edge: rgba(255, 255, 255, 0.75);
  --blur: blur(22px) saturate(170%);
  --danger: #f43f5e;
  --ok: #10b981;
  --warn: #f59e0b;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --shadow-sm: 0 1px 2px rgba(60, 30, 10, 0.06);
  --shadow-md: 0 10px 30px -10px rgba(60, 30, 10, 0.18);
  --shadow-lg: 0 30px 60px -20px rgba(60, 30, 10, 0.35);
  --col: 820px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  background: #fbf6f2;
  color: var(--text);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
::selection { background: rgba(234, 88, 12, 0.25); }

.i {
  width: 20px; height: 20px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- animated backdrop ---------- */
.bg { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.bg i {
  position: absolute;
  width: 55vmax; height: 55vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  will-change: transform;
}
.bg i:nth-child(1) { background: #fed7aa; top: -20vmax; left: -15vmax; animation: drift1 26s ease-in-out infinite alternate; }
.bg i:nth-child(2) { background: #fecdd3; bottom: -25vmax; right: -15vmax; animation: drift2 32s ease-in-out infinite alternate; }
.bg i:nth-child(3) { background: #fde68a; top: 30%; left: 40%; width: 35vmax; height: 35vmax; opacity: 0.4; animation: drift3 28s ease-in-out infinite alternate; }
@keyframes drift1 { to { transform: translate(18vmax, 12vmax) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-16vmax, -10vmax) scale(1.1); } }
@keyframes drift3 { to { transform: translate(-20vmax, 10vmax) scale(0.9); } }

/* ---------- shell ---------- */
.app {
  position: relative;
  z-index: 1;
  height: var(--app-h, 100dvh);
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 14px;
}
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* ---------- header ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 18px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-radius: 14px;
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  animation: drop-in 0.6s var(--ease) both;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  position: relative;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--grad);
  box-shadow: 0 6px 16px -4px rgba(234, 88, 12, 0.6);
  overflow: hidden;
}
.logo::after {
  content: "";
  position: absolute;
  inset: 7px 7px 9px 9px;
  border-radius: 50% 50% 50% 4px;
  background: rgba(255, 255, 255, 0.95);
}
.brand-name {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.03em;
  background: linear-gradient(90deg, #7c2d12, #c2410c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  width: 236px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.05);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.06);
}
.tab {
  position: relative;
  z-index: 1;
  border: 0;
  background: none;
  padding: 8px 10px;
  border-radius: 7px;
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  transition: color 0.3s var(--ease);
}
.tab:hover { color: var(--text-2); }
.tab[aria-selected="true"] { color: #fff; }
.tab-indicator {
  position: absolute;
  top: 4px; bottom: 4px; left: 4px;
  width: calc(50% - 4px);
  border-radius: 7px;
  background: var(--grad);
  box-shadow: 0 6px 16px -6px rgba(234, 88, 12, 0.7);
  transition: transform 0.45s var(--spring);
}
.tabs[data-mode="private"] .tab-indicator { transform: translateX(100%); }

.me {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--glass-edge);
  background: rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  padding: 3px 14px 3px 3px;
  max-width: 220px;
  min-width: 0;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s;
}
.me:hover { background: rgba(255, 255, 255, 0.9); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.me:active { transform: scale(0.97); }
.me-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; font-size: 14px; }

.avatar {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35), 0 2px 6px rgba(60, 30, 10, 0.15);
}
.avatar.sm { width: 30px; height: 30px; font-size: 11.5px; }

/* ---------- buttons ---------- */
.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 9px;
  border: 1px solid var(--glass-edge);
  background: rgba(255, 255, 255, 0.6);
  color: var(--text-2);
  text-decoration: none;
  transition: transform 0.2s var(--ease), background 0.2s, color 0.2s, box-shadow 0.2s;
}
.icon-btn:hover { background: #fff; color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn .i { width: 19px; height: 19px; }
.icon-btn.flat { border-color: transparent; background: transparent; color: var(--muted); box-shadow: none; }
.icon-btn.flat:hover { background: var(--accent-50); color: var(--accent); transform: none; box-shadow: none; }
.icon-btn.danger:hover { color: var(--danger); }
.icon-btn.light { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.18); color: #fff; }
.icon-btn.light:hover { background: rgba(255, 255, 255, 0.26); color: #fff; }
.badge {
  position: absolute;
  top: -7px; right: -7px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--grad);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 18px;
  border: 2px solid #fff;
  box-sizing: content-box;
}
.primary, .secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 10px;
  padding: 12px 20px;
  font-weight: 600;
  font-size: 14.5px;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), filter 0.2s;
}
.primary {
  position: relative;
  overflow: hidden;
  border: 0;
  background: var(--grad);
  color: #fff;
  box-shadow: 0 10px 24px -10px rgba(234, 88, 12, 0.8);
}
.primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.7s var(--ease);
}
.primary:hover { transform: translateY(-1px); box-shadow: 0 14px 30px -10px rgba(234, 88, 12, 0.9); }
.primary:hover::after { transform: translateX(100%); }
.primary:active { transform: scale(0.97); }
.secondary { border: 1px solid var(--line); background: rgba(255, 255, 255, 0.7); color: var(--text-2); }
.secondary:hover { background: #fff; }

/* ---------- main area ---------- */
.body { flex: 1; display: flex; gap: 14px; min-height: 0; }
.chat {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.42);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-md);
  animation: rise 0.6s 0.05s var(--ease) both;
}

.roombar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
}
.room-info { flex: 1; min-width: 0; }
.room-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.room-sub { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.status-dot { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.status-dot.on { background: var(--ok); }
.status-dot.on::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--ok);
  animation: ping 2s var(--ease) infinite;
}
.status-dot.off { background: var(--danger); }
@keyframes ping { from { transform: scale(0.5); opacity: 0.8; } to { transform: scale(1.6); opacity: 0; } }
.room-actions { display: flex; gap: 8px; flex-shrink: 0; }

.offline {
  flex-shrink: 0;
  padding: 7px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #9a3412;
  background: linear-gradient(90deg, rgba(254, 243, 199, 0.85), rgba(254, 215, 170, 0.85));
  animation: slide-down 0.3s var(--ease);
}

/* ---------- messages ---------- */
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* the conversation sits in a centred column instead of spanning the screen */
  padding: 18px max(18px, calc((100% - var(--col)) / 2)) 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  scrollbar-width: thin;
  scrollbar-color: rgba(234, 88, 12, 0.25) transparent;
}
.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb { background: rgba(234, 88, 12, 0.2); border-radius: 8px; }

.row { display: flex; gap: 8px; align-items: flex-end; }
.row.mine { flex-direction: row-reverse; }
.row:not(.grouped) { margin-top: 12px; }
.row .avatar { width: 30px; height: 30px; font-size: 11px; }
.row.grouped .avatar { visibility: hidden; height: 0; }
.row.mine .avatar { display: none; }

.bubble {
  max-width: min(460px, 70%);
  padding: 9px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 14px -6px rgba(60, 30, 10, 0.15);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  transform-origin: bottom left;
}
.row:not(.mine):not(.grouped) .bubble { border-bottom-left-radius: 4px; }
.row.mine .bubble {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 10px 24px -12px rgba(234, 88, 12, 0.9);
  transform-origin: bottom right;
}
.row.mine.grouped .bubble { border-bottom-right-radius: 12px; border-top-right-radius: 4px; }
.row:not(.mine).grouped .bubble { border-top-left-radius: 4px; }
.row.live .bubble { animation: bubble-in 0.45s var(--spring) both; }
.row.live:not(.mine) .avatar { animation: fade-in 0.3s var(--ease) both; }
@keyframes bubble-in { from { opacity: 0; transform: translateY(10px) scale(0.92); } }

.author { font-size: 12.5px; font-weight: 700; margin-bottom: 1px; }
.row.grouped .author, .row.mine .author { display: none; }
.text { white-space: pre-wrap; }
.text a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.row.mine .text a { color: #fff; }
.time {
  float: right;
  font-size: 10.5px;
  color: var(--faint);
  margin: 8px 0 -5px 10px;
  font-variant-numeric: tabular-nums;
}
.row.mine .time { color: rgba(255, 255, 255, 0.75); }
.emoji-only .text { font-size: 36px; line-height: 1.2; }
.bubble.emoji-only { background: transparent !important; border-color: transparent !important; box-shadow: none !important; padding: 0 2px; }
.row.mine .bubble.emoji-only .time { color: var(--faint); }

/* media inside a bubble */
.bubble.has-media { padding: 4px; }
.bubble.has-media .author { padding: 4px 10px 2px; }
.bubble.has-media .text { padding: 4px 10px 5px; }
.media {
  position: relative;
  display: block;
  border-radius: 9px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.06);
  max-width: 300px;
}
.media img, .media video {
  display: block;
  width: 100%;
  max-height: 340px;
  object-fit: cover;
}
.media img { cursor: zoom-in; transition: transform 0.4s var(--ease); }
.media:hover img { transform: scale(1.03); }
.media video { background: #000; object-fit: contain; }
.media .time-over {
  position: absolute;
  right: 8px; bottom: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.45);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 10.5px;
  pointer-events: none;
}
.media:has(video) .time-over { bottom: auto; top: 8px; }

.system, .day {
  align-self: center;
  margin: 14px 0 4px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--glass-edge);
}
.system.live { animation: fade-in 0.4s var(--ease) both; }
.day { font-weight: 600; color: var(--text-2); letter-spacing: 0.01em; }

.empty {
  margin: auto;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-align: center;
  animation: rise 0.6s var(--ease) both;
}
.empty b { font-size: 17px; letter-spacing: -0.02em; }
.empty span { color: var(--muted); font-size: 14px; }

.jump {
  position: absolute;
  right: 22px;
  bottom: 96px;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--glass-edge);
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  color: var(--accent);
  display: grid; place-items: center;
  box-shadow: var(--shadow-md);
  z-index: 3;
  animation: pop-in 0.4s var(--spring);
}
.jump.new::after {
  content: "";
  position: absolute;
  top: 1px; right: 1px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--accent-3);
  border: 2px solid #fff;
}

.typing {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 0 max(18px, calc((100% - var(--col)) / 2)) 6px;
  font-size: 12.5px;
  color: var(--muted);
  animation: fade-in 0.25s var(--ease);
}
.dots { display: inline-flex; gap: 3px; padding: 7px 10px; background: rgba(255, 255, 255, 0.85); border-radius: 999px; box-shadow: var(--shadow-sm); }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent-2); animation: bounce 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { opacity: 0.35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

/* ---------- composer ---------- */
.composer-wrap {
  flex-shrink: 0;
  position: relative;
  padding: 6px 18px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.composer {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  max-width: var(--col);
  margin: 0 auto;
  padding: 5px;
  border-radius: 14px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-md);
  transition: box-shadow 0.3s var(--ease), transform 0.3s var(--ease);
}
.composer:focus-within { box-shadow: 0 0 0 4px var(--accent-100), var(--shadow-md); }
.composer textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  border: 0;
  background: transparent;
  padding: 9px 8px;
  max-height: 140px;
  outline: none;
  line-height: 1.45;
}
.composer textarea::placeholder { color: var(--faint); }
.send {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 0;
  background: var(--grad);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 8px 18px -8px rgba(234, 88, 12, 0.9);
  transition: transform 0.3s var(--spring), opacity 0.25s, box-shadow 0.25s;
}
.send .i { width: 18px; height: 18px; transition: transform 0.3s var(--spring); }
.send:hover:not(:disabled) .i { transform: translate(2px, -2px) rotate(-8deg); }
.send:disabled { opacity: 0.35; cursor: default; box-shadow: none; transform: scale(0.94); }
.send:not(:disabled):active { transform: scale(0.88); }

.tray {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  max-width: var(--col);
  margin: 0 auto 10px;
  padding: 4px 2px;
}
.thumb {
  position: relative;
  width: 76px; height: 76px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-md);
  animation: pop-in 0.35s var(--spring) both;
}
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .kind {
  position: absolute; left: 6px; bottom: 6px;
  width: 20px; height: 20px;
  border-radius: 7px;
  display: grid; place-items: center;
  background: rgba(15, 23, 42, 0.5);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #fff;
}
.thumb .kind .i { width: 10px; height: 10px; fill: currentColor; stroke: none; }
.thumb .rm {
  position: absolute; top: 5px; right: 5px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 0;
  display: grid; place-items: center;
  background: rgba(15, 23, 42, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #fff;
  padding: 0;
  transition: transform 0.2s var(--spring), background 0.2s;
}
.thumb .rm:hover { transform: scale(1.12); background: var(--danger); }
.thumb .rm .i { width: 12px; height: 12px; stroke-width: 2.8; }
.thumb .bar { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.7); overflow: hidden; }
.thumb .bar i { display: block; height: 100%; background: var(--grad); transition: width 0.2s; }
.thumb.done::after { content: ""; position: absolute; inset: 0; background: rgba(234, 88, 12, 0.2); }


.emoji-pop {
  position: absolute;
  left: 18px;
  bottom: calc(100% - 4px);
  width: min(340px, calc(100vw - 36px));
  max-height: 290px;
  overflow-y: auto;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  border-radius: 14px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-lg);
  z-index: 10;
  transform-origin: bottom left;
  animation: pop-in 0.3s var(--spring);
}
.emoji-pop button {
  border: 0;
  background: none;
  font-size: 22px;
  line-height: 1;
  aspect-ratio: 1;
  border-radius: 8px;
  padding: 0;
  transition: transform 0.2s var(--spring), background 0.2s;
}
.emoji-pop button:hover { background: var(--accent-50); transform: scale(1.22); }

.drop {
  position: absolute;
  inset: 10px;
  z-index: 20;
  display: grid; place-items: center;
  border: 2px dashed rgba(234, 88, 12, 0.6);
  border-radius: 14px;
  background: rgba(255, 247, 237, 0.85);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--accent);
  font-weight: 700;
  font-size: 17px;
  pointer-events: none;
  animation: fade-in 0.2s var(--ease);
}

/* ---------- app install, notifications, away ---------- */
.top-right { justify-self: end; display: flex; align-items: center; gap: 8px; min-width: 0; }
.bell-btn.on { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 8px 18px -8px rgba(234, 88, 12, 0.9); }
.bell-btn.on:hover { color: #fff; background: var(--grad); }
.ios-hint {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 8px 12px 0;
  padding: 6px 6px 6px 14px;
  border-radius: 12px;
  font-size: 13px;
  color: var(--text-2);
  background: rgba(255, 247, 237, 0.9);
  border: 1px solid #fed7aa;
  animation: rise 0.4s var(--ease) both;
}
.ios-hint .i { width: 16px; height: 16px; vertical-align: -3px; color: var(--accent); }
.ios-hint .icon-btn { width: 30px; height: 30px; }
.people li.away { opacity: 0.6; }
.people li.away .avatar::after { background: var(--faint); }
.people li.away .you { color: var(--muted); background: rgba(15, 23, 42, 0.05); }

/* ---------- GIFs ---------- */
.media.is-gif { max-width: 260px; background: transparent; }
.media .gif { display: block; width: 100%; max-height: 300px; object-fit: cover; }

.gif-btn {
  height: 38px;
  padding: 0 9px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  transition: background 0.2s, color 0.2s;
}
.gif-btn:hover { background: var(--accent-50); color: var(--accent); }

.ai-btn.on { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 8px 18px -8px rgba(234, 88, 12, 0.9); }
.ai-btn.on:hover { color: #fff; background: var(--grad); }

.suggest {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: var(--col);
  margin: 0 auto 8px;
  padding: 6px;
  border-radius: 12px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-md);
  animation: rise 0.4s var(--spring) both;
}
.suggest .mood {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  font-size: 20px;
  border-radius: 9px;
  background: var(--accent-50);
}
.sg-list {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.sg-list::-webkit-scrollbar { display: none; }
.sg-list .gif-tile { height: 72px; flex-shrink: 0; scroll-snap-align: start; }
.sg-list .gif-tile:nth-child(n) { animation: pop-in 0.35s var(--spring) both; }
.sg-list .gif-tile:nth-child(2) { animation-delay: 0.03s; }
.sg-list .gif-tile:nth-child(3) { animation-delay: 0.06s; }
.sg-list .gif-tile:nth-child(4) { animation-delay: 0.09s; }
.sg-list .gif-tile:nth-child(5) { animation-delay: 0.12s; }
.sg-list .gif-tile:nth-child(n+6) { animation-delay: 0.15s; }
.sg-close { width: 32px; height: 32px; flex-shrink: 0; }

.gif-tile {
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.06);
  transition: transform 0.2s var(--spring), box-shadow 0.2s;
}
.gif-tile:hover { transform: scale(1.05); box-shadow: var(--shadow-md); }
.gif-tile:active { transform: scale(0.96); }
.gif-tile video, .gif-tile img { display: block; height: 100%; width: auto; object-fit: cover; }

.gif-pop {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: calc(100% - 4px);
  max-width: 460px;
  height: min(420px, 60vh);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 14px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-lg);
  z-index: 10;
  transform-origin: bottom left;
  animation: pop-in 0.3s var(--spring);
}
.gif-field > .i { width: 17px; height: 17px; color: var(--faint); }
.gif-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  columns: 2 140px;
  column-gap: 6px;
}
.gif-grid .gif-tile { display: block; width: 100%; margin-bottom: 6px; break-inside: avoid; }
.gif-grid .gif-tile video, .gif-grid .gif-tile img { width: 100%; height: auto; }
.gif-empty { padding: 30px 0; text-align: center; color: var(--muted); font-size: 14px; column-span: all; }
.gif-foot { font-size: 10.5px; color: var(--faint); text-align: right; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600; }
.gif-foot:empty { display: none; }

/* ---------- private join ---------- */
.join {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  overflow-y: auto;
}
.join-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  padding: 36px 26px 26px;
  text-align: center;
  border-radius: 18px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-lg);
  animation: rise 0.6s var(--ease) both;
}
.orb {
  width: 64px; height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff 0%, #fed7aa 25%, #f97316 60%, #c2410c 100%);
  box-shadow: 0 16px 36px -10px rgba(234, 88, 12, 0.8), inset -6px -8px 16px rgba(124, 45, 18, 0.35);
  animation: float 5s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-8px); } }
.join-card h1 { font-size: 22px; margin: 0 0 22px; letter-spacing: -0.03em; }
#join-form { display: flex; flex-direction: column; gap: 10px; }
.field {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 4px 4px 16px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  transition: box-shadow 0.25s var(--ease), border-color 0.25s;
}
.field:focus-within { border-color: rgba(234, 88, 12, 0.4); box-shadow: 0 0 0 4px var(--accent-100); }
.field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 9px 2px;
  outline: none;
  font-weight: 600;
}
.field input::placeholder { color: var(--faint); font-weight: 500; }
.field .icon-btn { width: 36px; height: 36px; }
.join-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* ---------- people panel ---------- */
.people {
  width: 280px;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.5);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-md);
  animation: rise 0.6s 0.1s var(--ease) both;
}
.people-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 63px;
  padding: 0 12px 0 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--line);
}
.people-head b {
  margin-left: 6px;
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--grad);
  color: #fff;
  font-size: 11.5px;
}
.close-people { display: none; }
.people ul { list-style: none; margin: 0; padding: 10px; overflow-y: auto; }
.people li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
  min-width: 0;
  transition: background 0.2s, transform 0.2s var(--ease);
  animation: fade-in 0.35s var(--ease) both;
}
.people li:hover { background: rgba(255, 255, 255, 0.75); transform: translateX(2px); }
.people li span.n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.people li .you {
  margin-left: auto;
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-50);
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.people li .avatar { position: relative; }
.people li .avatar::after {
  content: "";
  position: absolute;
  right: -1px; bottom: -1px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--ok);
  border: 2px solid #fff;
}
.people-btn { display: none; }

/* ---------- dialog, lightbox, toast ---------- */
dialog {
  border: 1px solid var(--glass-edge);
  border-radius: 16px;
  padding: 26px;
  width: min(360px, calc(100vw - 32px));
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog[open] { animation: pop-in 0.35s var(--spring); }
dialog::backdrop { background: rgba(60, 30, 10, 0.25); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog h2 { margin: 0 0 16px; font-size: 19px; letter-spacing: -0.02em; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.dialog-actions .primary, .dialog-actions .secondary { padding: 10px 18px; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 64px 16px 16px;
  background: rgba(15, 23, 42, 0.8);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  animation: fade-in 0.2s var(--ease);
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; object-fit: contain; box-shadow: var(--shadow-lg); animation: zoom-in 0.35s var(--spring); }
.lb-bar { position: absolute; top: 14px; right: 14px; display: flex; gap: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translate(-50%, 16px) scale(0.96);
  padding: 10px 18px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.35s var(--spring);
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-lg);
  z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* ---------- shared keyframes ---------- */
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes drop-in { from { opacity: 0; transform: translateY(-10px); } }
@keyframes slide-down { from { opacity: 0; transform: translateY(-100%); } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.9); } }
@keyframes zoom-in { from { opacity: 0; transform: scale(0.85); } }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .people {
    position: fixed;
    top: 10px; right: 10px; bottom: 10px;
    width: min(300px, calc(100vw - 40px));
    z-index: 30;
    background: var(--glass-strong);
    box-shadow: var(--shadow-lg);
    transform: translateX(calc(100% + 20px));
    transition: transform 0.45s var(--spring);
    animation: none;
  }
  .people.open { transform: none; }
  .close-people { display: inline-grid; }
  .people-btn { display: inline-grid; }
  .bubble { max-width: 78%; }
}
@media (max-width: 600px) {
  .app { padding: 0; gap: 0; }
  .top {
    grid-template-columns: auto 1fr;
    border-radius: 0;
    border-width: 0 0 1px;
    padding: 8px 12px;
    padding-top: max(8px, env(safe-area-inset-top));
    row-gap: 8px;
  }
  .tabs { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  .me { max-width: 100%; }
  .chat { border-radius: 0; border: 0; box-shadow: none; background: rgba(255, 255, 255, 0.3); }
  .roombar { padding: 10px 14px; }
  .messages { padding-left: 12px; padding-right: 12px; }
  .typing { padding-left: 12px; padding-right: 12px; }
  .composer-wrap { padding: 6px 10px max(10px, env(safe-area-inset-bottom)); }
  .media { max-width: 240px; }
  .gif-pop { left: 10px; right: 10px; }
  .gif-btn { padding: 0 6px; }
  .jump { right: 14px; bottom: 84px; }
}

/* ---------- phones: gradient header, overlapping glass room card, compact type ---------- */
@media (max-width: 600px) {
  body { font-family: "Plus Jakarta Sans", Inter, system-ui, sans-serif; font-size: 14px; }
  /* Animated blurred blobs are heavy on phones; a still wash looks calmer and costs nothing. */
  .bg i { display: none; }
  .bg {
    background:
      radial-gradient(55% 35% at 0% 30%, rgba(234, 88, 12, 0.12), transparent 70%),
      radial-gradient(50% 30% at 100% 55%, rgba(225, 29, 72, 0.08), transparent 70%),
      radial-gradient(60% 35% at 20% 100%, rgba(124, 58, 237, 0.07), transparent 70%),
      #fbf8f5;
  }

  .top {
    grid-template-columns: 1fr auto;
    row-gap: 12px;
    padding: 10px 14px 38px;
    padding-top: max(12px, calc(env(safe-area-inset-top) + 6px));
    border: 0;
    border-radius: 0 0 22px 22px;
    background: linear-gradient(140deg, #f97316 0%, #ea580c 40%, #c2410c 75%, #9a3412 100%);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: 0 12px 30px -14px rgba(154, 52, 18, 0.6);
    color: #fff;
  }
  .logo { width: 28px; height: 28px; border-radius: 8px; background: #fff; box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.25); }
  .logo::after { background: #ea580c; inset: 7px 7px 8px 8px; }
  .brand-name { display: inline; font-size: 17px; background: none; color: #fff; -webkit-text-fill-color: #fff; }

  .tabs {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    padding: 3px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: none;
  }
  .tab { font-size: 13px; padding: 8px 6px; color: rgba(255, 255, 255, 0.85); }
  .tab:hover { color: #fff; }
  .tab[aria-selected="true"] { color: #c2410c; }
  .tab-indicator { top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border-radius: 8px; background: #fff; box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.25); }

  .top .install-btn { width: 32px; height: 32px; border-radius: 9px; background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.3); color: #fff; }
  .top .install-btn .i { width: 16px; height: 16px; }
  .me { padding: 2px 12px 2px 2px; max-width: 52vw; background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.3); color: #fff; }
  .me:hover { background: rgba(255, 255, 255, 0.24); box-shadow: none; }
  .me-name { font-size: 13px; }
  .avatar.sm { width: 28px; height: 28px; font-size: 11px; }

  /* the room card floats over the bottom of the header */
  .body { position: relative; z-index: 21; margin-top: -26px; }
  .chat { background: transparent; border: 0; box-shadow: none; border-radius: 0; animation: none; }
  .roombar {
    margin: 0 12px;
    padding: 9px 10px 9px 14px;
    border: 1px solid var(--glass-edge);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.78);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    box-shadow: 0 10px 28px -12px rgba(60, 30, 10, 0.3);
    animation: rise 0.5s var(--ease) both;
  }
  .room-title { font-size: 15px; }
  .room-sub { font-size: 11.5px; }
  .roombar { gap: 8px; }
  .room-info { min-width: 72px; }
  .room-actions { gap: 4px; }
  .room-actions .icon-btn { width: 31px; height: 31px; border-radius: 8px; }
  .room-actions .icon-btn .i { width: 16px; height: 16px; }
  .badge { font-size: 10px; min-width: 16px; height: 16px; line-height: 16px; top: -6px; right: -6px; }
  .offline { margin: 8px 12px 0; border-radius: 10px; border: 1px solid #fde68a; font-size: 12px; padding: 6px; }

  .messages { padding: 10px 12px 8px; gap: 2px; }
  .row { gap: 6px; }
  .row:not(.grouped) { margin-top: 9px; }
  .row .avatar { width: 26px; height: 26px; font-size: 10px; }
  .bubble { max-width: 80%; padding: 7px 11px; font-size: 14px; line-height: 1.45; border-radius: 14px; }
  .row:not(.mine):not(.grouped) .bubble { border-bottom-left-radius: 4px; }
  .row.mine .bubble { border-bottom-right-radius: 4px; }
  .author { font-size: 11.5px; }
  .time { font-size: 10px; margin-top: 6px; }
  .emoji-only .text { font-size: 30px; }
  .media, .media.is-gif { max-width: 220px; }
  .media img, .media video, .media .gif { max-height: 260px; }
  .system, .day { font-size: 11px; padding: 3px 10px; margin: 10px 0 3px; }
  .empty b { font-size: 15px; }
  .empty span { font-size: 13px; }
  .typing { padding: 0 12px 4px; font-size: 11.5px; }
  .jump { right: 14px; bottom: 80px; width: 38px; height: 38px; }

  .composer-wrap { padding: 4px 10px max(10px, env(safe-area-inset-bottom)); }
  .composer { padding: 4px; border-radius: 16px; gap: 0; box-shadow: 0 10px 28px -12px rgba(60, 30, 10, 0.3); }
  .composer .icon-btn.flat { width: 34px; height: 36px; }
  /* phones have an emoji keyboard; keep the bar clean */
  #emoji-btn, .emoji-pop { display: none !important; }
  .composer .icon-btn .i { width: 19px; height: 19px; }
  .gif-btn { height: 36px; padding: 0 5px; font-size: 11.5px; }
  /* 16px stops iOS Safari from zooming the page when the box is tapped */
  .composer textarea, .field input, #name-input { font-size: 16px; }
  .composer textarea { padding: 8px 6px; }
  .send { width: 36px; height: 36px; border-radius: 11px; }
  .send .i { width: 17px; height: 17px; }

  .suggest { padding: 5px; gap: 6px; border-radius: 12px; margin-bottom: 6px; }
  .suggest .mood { width: 30px; height: 30px; font-size: 17px; border-radius: 8px; }
  .sg-list .gif-tile { height: 60px; }
  .sg-close { width: 28px; height: 28px; }
  .tray { gap: 8px; margin-bottom: 6px; }
  .thumb { width: 64px; height: 64px; border-radius: 10px; }
  .gif-pop { left: 10px; right: 10px; height: min(380px, 55vh); border-radius: 14px; }

  .join { padding: 34px 14px 20px; align-items: start; }
  .join-card { padding: 28px 18px 20px; border-radius: 18px; }
  .orb { width: 54px; height: 54px; margin-bottom: 14px; }
  .join-card h1 { font-size: 19px; margin-bottom: 18px; }
  .primary { padding: 11px 18px; font-size: 14px; }
  
  .people { top: 8px; right: 8px; bottom: 8px; border-radius: 16px; }
  .people-head { min-height: 54px; font-size: 14px; }
  .people li { font-size: 13.5px; padding: 7px 8px; }
  dialog { padding: 20px; border-radius: 16px; }
  dialog h2 { font-size: 17px; }
  .toast { bottom: 92px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
