/* Messages: one thread, bubbles, a box at the bottom.

   The defaults are the owner's dark shell; body.listener overrides give her
   the pink one. */

.msg-panel { display: flex; flex-direction: column; }

/* The thread sits in the room: the same scene the chat test uses. The room
   is on a wrapper and the list scrolls inside it, so the picture holds still
   while the bubbles move, and the sign's glow can sit over the picture
   rather than scroll away with the thread. A shade keeps the bubbles
   readable; darker in the dark shell and at night. Split into two properties
   so a preview can point --msg-bg elsewhere. */
.msg-room {
  --msg-bg: url(/messages-bg.jpg);
  --msg-shade: linear-gradient(rgba(23, 7, 15, .55), rgba(23, 7, 15, .55));
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background-image: var(--msg-shade), var(--msg-bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
/* Full height from the first message: the room is always the whole room,
   and a short thread sits at the bottom of it rather than the picture
   growing a line at a time. The margin trick on the first child pushes a
   short thread down without breaking scrolling when it is long. */
.msg-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 62vh;
  min-height: 360px;
  overflow-y: auto;
  padding: 12px 10px;
}
.msg-list > :first-child { margin-top: auto; }

/* The thread gets a wider column than the rest of her pages, so the room
   shows on a big screen. Set on main by the router for this view only. */
body.listener main.wide { max-width: 1180px; }

/* The neon sign in the picture, lit. Positioned by script over "BE A GOOD
   GIRL" wherever the crop has put it, and flared when she sends: two quick
   pulses, the way a tube catches, then gone. Screen blending lights the
   picture under it rather than painting over it. */
.msg-flash {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  border-radius: 50%;
  filter: blur(4px);
  mix-blend-mode: screen;
  /* Held near full strength to halfway out, so the last letter of a word is
     lit as well as the first, then off by the rim. */
  background: radial-gradient(ellipse at center,
    rgba(255, 150, 215, .9) 0%, rgba(255, 110, 200, .75) 50%, rgba(255, 60, 170, 0) 80%);
}
.msg-flash.on { animation: msg-flash .9s ease-out forwards; }
@keyframes msg-flash {
  0%   { opacity: 0; }
  12%  { opacity: .8; }
  28%  { opacity: .25; }
  42%  { opacity: .8; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .msg-flash.on { animation: none; }
}
.msg-day {
  align-self: center;
  margin: 8px 0 2px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .3);
  color: #fff;
  font-size: 11.5px;
  letter-spacing: .6px;
  text-transform: uppercase;
}
.msg {
  max-width: min(78%, 620px);     /* a long message wraps rather than spanning the room */
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.45;
}
/* Her line breaks are kept; the markup's own are not. */
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.theirs { align-self: flex-start; background: var(--panel-2); border-bottom-left-radius: 5px; }
.msg.mine { align-self: flex-end; background: var(--pink-deep); color: #fff; border-bottom-right-radius: 5px; }
.msg-meta { margin-top: 3px; font-size: 11px; opacity: .7; text-align: right; }
.msg-empty { padding: 40px 0; text-align: center; color: var(--muted); }

.msg-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; }
.msg-form textarea { flex: 1; min-height: 40px; max-height: 160px; resize: none; }
.msg-send {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: var(--bc-header);
  font-size: 18px;
  cursor: pointer;
}

/* His sidebar count lights up when something is waiting. */
.nav-item .n.live { color: var(--pink); font-weight: 700; }

/* ------------------------------------------------------------- her shell */

body.listener .msg-list { height: 58vh; }
/* Lighter by day, so the room shows through pink; the bubbles carry the
   contrast. Night pulls it down. */
body.listener .msg-room {
  --msg-shade: linear-gradient(rgba(60, 10, 35, .22), rgba(60, 10, 35, .22));
}
body.listener.night .msg-room {
  --msg-shade: linear-gradient(rgba(23, 7, 15, .6), rgba(23, 7, 15, .6));
}
/* Light against dark, which tells two sides apart better than two colours of
   the same depth. His bubbles are dark plum with white text and a faint pink
   edge, the voice from the room; hers are light with dark text, white by day
   and a soft pink at night. */
body.listener .msg.theirs {
  background: rgba(40, 14, 30, .88);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 140, 200, .35);
}
body.listener .msg.mine { background: rgba(255, 255, 255, .94); color: var(--bc-ink); }
body.listener .msg.mine .msg-meta { color: var(--bc-ink-soft); opacity: 1; }
body.listener.night .msg.theirs { background: rgba(40, 14, 30, .94); }
body.listener.night .msg.mine { background: #f6c6d4; color: #2c2729; }
body.listener.night .msg.mine .msg-meta { color: #6a4a56; }
body.listener .msg-empty { color: #fff; text-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
body.listener .msg-form textarea {
  background: var(--bc-panel);
  border: none;
  border-radius: 14px;
  padding: 10px 14px;
  color: var(--bc-ink);
  font: inherit;
  font-size: 15px;
}
body.listener .msg-form textarea::placeholder { color: var(--bc-ink-soft); }
body.listener .msg-form textarea:focus { box-shadow: 0 0 0 3px rgba(255, 255, 255, .55); }

/* The unread count on her Messages pill. */
#bc-nav a .n {
  display: inline-block;
  min-width: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: #fff;
  color: var(--bc-header);
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}
#bc-nav a .n:empty { display: none; }
#bc-nav a.on .n { background: var(--bc-header); color: #fff; }

/* ------------------------------------------------------------ his pencil */

/* The owner can rewrite any bubble in place. The pencil sits in the meta
   line, faint until the bubble is under the pointer; on a touch screen it
   stays faint and tappable. None of this is in her markup at all. */
.msg-edit {
  background: none;
  border: 0;
  padding: 0 0 0 6px;
  margin: 0;
  color: inherit;
  opacity: .35;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  vertical-align: baseline;
}
.msg:hover .msg-edit, .msg-edit:focus-visible { opacity: 1; }
.msg.editing { width: min(78%, 620px); }
.msg.editing .msg-body { white-space: normal; }
.msg-edit-box {
  width: 100%;
  min-height: 40px;
  max-height: 240px;
  resize: none;
  background: rgba(0, 0, 0, .3);
  color: inherit;
  border-color: rgba(255, 255, 255, .35);
}
.msg-edit-row { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }
.msg-edit-row button { padding: 4px 12px; font-size: 13px; }
.msg.mine .msg-edit-row .ghost { color: rgba(255, 255, 255, .8); }
