/* المحادثات, drawn as WhatsApp Web draws its chats — and on a phone as the
 * WhatsApp app does: one pane at a time and the two-row message card. Every
 * rule is scoped under .wx. The colours come from the site's own tokens in
 * styles.css, which are WhatsApp's; the local names below only say which
 * token plays which part in a chat, and the accent is the person's own. */

.view:has(> .wx) {
  padding: var(--topbar-h) 0 0;
}

/* The page entrance animation would replay on every conversation click. */
.view.entering > .wx {
  animation: none;
}

.wx {
  --wx-panel: var(--card);
  --wx-rail: var(--bg);
  --wx-soft: var(--hover);
  --wx-hover: color-mix(in srgb, var(--hover) 55%, var(--card));
  --wx-active: var(--hover);
  --wx-chip-on: var(--soft);
  --wx-chip-line: var(--input-border);
  --wx-border: var(--input-border);
  --wx-line: var(--border);
  --wx-chat: var(--chat-bg);
  --wx-wall: var(--chat-wall);
  --wx-in: var(--bubble-in);
  --wx-out: var(--bubble-out);
  --wx-day: var(--bubble-in);
  --wx-pop: var(--bubble-in);
  --wx-note: #fff3c2;
  --wx-note-ink: #5c4600;
  --wx-ink: var(--heading);
  --wx-sub: var(--muted);
  --wx-meta-out: var(--bubble-out-meta);
  --wx-icon: var(--heading);
  --wx-primary: var(--btn);
  --wx-on-primary: var(--btn-ink);
  --wx-green: var(--primary);
  --wx-green-ink: var(--primary-ink);
  --wx-toggle-off: var(--toggle-off);
  --wx-read: #53bdeb;
  --wx-danger: var(--danger);
  --wx-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  --wx-pop-shadow: var(--shadow-lg);
  --wx-r: 7px;
  --wx-r-lg: 16px;
  --wx-text: calc(0.9rem + var(--chat-text-step, 0) * 1pt);
  --wx-glyph: calc(1.45rem + var(--chat-icon-step, 0) * 1pt);

  position: relative;
  display: flex;
  block-size: calc(100dvh - var(--topbar-h) - var(--tabbar-h));
  overflow: hidden;
  background: var(--wx-panel);
  color: var(--wx-ink);
}

.dark .wx {
  --wx-note: #3b3212;
  --wx-note-ink: #f3d77c;
  --wx-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.4);
}

/* ------------------------------------------------------------- controls */

.wx button {
  box-shadow: none;
}

.wx .wx-icon {
  inline-size: 40px;
  block-size: 40px;
  padding: 0;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--wx-icon);
}

.wx .wx-icon .bx {
  font-size: var(--wx-glyph);
}

.wx .wx-icon:hover,
.wx .wx-icon[aria-expanded="true"] {
  background: var(--wx-soft);
  color: var(--wx-ink);
}

/* WhatsApp's buttons: a solid ink pill for the main action, a soft grey pill
 * beside it. */
.wx .wx-btn {
  gap: 0.35rem;
  min-block-size: 2.4rem;
  padding: 0.45rem 1.25rem;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--wx-primary);
  color: var(--wx-on-primary);
  font-weight: 700;
  font-size: 0.875rem;
  white-space: nowrap;
}

.wx .wx-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--wx-primary) 85%, var(--wx-panel));
}

.wx .wx-btn.quiet {
  background: var(--wx-chip-on);
  color: var(--wx-ink);
}

.wx .wx-btn.quiet:hover:not(:disabled) {
  background: color-mix(in srgb, var(--wx-chip-on) 85%, var(--wx-ink));
}

.wx-muted {
  margin: 0;
  color: var(--wx-sub);
  font-size: 0.8125rem;
}

.wx .wx-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--wx-green-ink);
  font-size: 0.875rem;
  font-weight: 700;
}

.wx-open {
  color: var(--wx-green);
}

/* ---------------------------------------------------------------- popovers */

.wx-pop-wrap {
  position: relative;
}

.wx-pop {
  position: absolute;
  z-index: 40;
  padding: 0.5rem;
  background: var(--wx-pop);
  border-radius: var(--wx-r-lg);
  box-shadow: var(--wx-pop-shadow);
}

.wx-menu {
  inset-block-start: calc(100% + 6px);
  inset-inline-end: 0;
  min-inline-size: 240px;
}

.wx .wx-menu-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.85rem;
  inline-size: 100%;
  padding: 0.6rem 0.85rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--wx-ink);
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: start;
  text-decoration: none;
}

.wx .wx-menu-item:hover {
  background: var(--wx-soft);
  color: var(--wx-ink);
  text-decoration: none;
}

.wx .wx-menu-item .bx {
  font-size: 1.3rem;
  color: var(--wx-icon);
}

.wx .wx-menu-item.danger,
.wx .wx-menu-item.danger .bx {
  color: var(--wx-danger);
}

.wx-menu-title {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0 0.25rem 0.4rem;
  border-block-end: 1px solid var(--wx-line);
  margin-block-end: 0.35rem;
  color: var(--wx-sub);
  font-size: 0.8125rem;
}

.wx .wx-menu-title .wx-icon {
  inline-size: 32px;
  block-size: 32px;
}

.wx .wx-menu-title .wx-icon .bx {
  font-size: 1.2rem;
}

/* ------------------------------------------------------------------ list */

.wx-side {
  flex: 0 0 clamp(340px, 30%, 440px);
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
  border-inline-end: 1px solid var(--wx-line);
  background: var(--wx-panel);
}

.wx-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-block-size: 64px;
  padding: 0.5rem 1.25rem 0;
}

.wx-side-head h1 {
  color: var(--wx-ink);
  font-size: 1.4rem;
  font-weight: 800;
}

.wx-search {
  position: relative;
  margin: 0.35rem 1rem 0.25rem;
}

.wx-search .bx {
  position: absolute;
  inset-inline-start: 0.95rem;
  inset-block-start: 50%;
  translate: 0 -50%;
  color: var(--wx-sub);
  font-size: 1.2rem;
  pointer-events: none;
}

.wx .wx-search input {
  block-size: 2.6rem;
  padding-inline: 2.8rem 1rem;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--wx-soft);
  color: var(--wx-ink);
  font-size: 0.9rem;
}

.wx .wx-search input::placeholder {
  color: var(--wx-sub);
}

.wx .wx-search input:focus {
  background: var(--wx-panel);
  box-shadow: inset 0 0 0 2px var(--wx-green);
}

/* One row of pills that scrolls sideways, as on the phone, never two. */
.wx-chips {
  display: flex;
  gap: 0.5rem;
  padding: 0.55rem 1rem 0.6rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.wx-chips::-webkit-scrollbar {
  display: none;
}

.wx .wx-chip {
  flex-shrink: 0;
  block-size: 2rem;
  padding: 0 0.85rem;
  border: 1px solid var(--wx-border);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--wx-sub);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}

.wx .wx-chip:hover {
  background: var(--wx-soft);
  color: var(--wx-ink);
}

.wx .wx-chip.on {
  border-color: var(--wx-chip-line);
  background: var(--wx-chip-on);
  color: var(--wx-ink);
  font-weight: 700;
}

.wx-rows {
  flex: 1;
  min-block-size: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.15rem 0.6rem 0.75rem;
}

.wx-rows .sk-row {
  border-color: transparent;
}

/* Rows have no rules between them; the hover and the open chat are a rounded
 * tile, inset from the panel's edges. */
.wx-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-block-size: 72px;
  padding-inline: 0.7rem 0.75rem;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
}

.wx-row:hover {
  background: var(--wx-hover);
  color: inherit;
  text-decoration: none;
}

.wx-row.active {
  background: var(--wx-active);
}

.wx-row > .avatar {
  inline-size: 49px;
  block-size: 49px;
  font-size: 1rem;
}

.wx-row-main {
  flex: 1;
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.15rem;
}

.wx-row-top,
.wx-row-bottom {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.wx-row-name {
  flex: 1;
  min-inline-size: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--wx-ink);
  font-size: 1.0625rem;
  font-weight: 600;
}

.wx-row-time {
  flex-shrink: 0;
  color: var(--wx-sub);
  font-size: 0.75rem;
}

.wx-row.unread .wx-row-name {
  font-weight: 800;
}

.wx-row.unread .wx-row-time {
  color: var(--wx-ink);
  font-weight: 800;
}

.wx-row-preview {
  flex: 1;
  min-inline-size: 0;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  overflow: hidden;
  color: var(--wx-sub);
  font-size: 0.875rem;
}

.wx-row-preview span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wx-row-preview .bx {
  flex-shrink: 0;
  font-size: 1rem;
}

.wx-row-preview .bx.warn {
  color: #d99a00;
}

.wx-row-preview .bx.info {
  color: var(--info);
}

/* The customer asked for a person and the AI has stepped back — blue frame
 * until someone switches the AI on again. */
.wx-row.human-requested {
  box-shadow: inset 0 0 0 2px var(--info);
}

/* An approved maintenance report waits to be sent to this customer — green
 * frame until it goes (ops.send_to_customer). */
.wx-row.report-ready {
  box-shadow: inset 0 0 0 2px var(--success);
}

.wx-row-tag {
  flex-shrink: 0;
  color: var(--wx-sub);
  font-size: 1rem;
}

.wx-unread {
  flex-shrink: 0;
  min-inline-size: 1.3rem;
  block-size: 1.3rem;
  padding-inline: 0.35rem;
  display: inline-grid;
  place-items: center;
  border-radius: var(--r-pill);
  background: var(--wx-green);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
}

.wx .wx-more {
  display: block;
  margin: 0.75rem auto;
  padding: 0.45rem 1.2rem;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--wx-chip-on);
  color: var(--wx-ink);
  font-weight: 700;
}

/* ------------------------------------------------------------------ chat */

.wx-chat {
  flex: 1;
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--wx-chat);
  /* WhatsApp's doodle wallpaper, in the same spirit: faint line drawings
   * that stay put while the messages scroll over them. */
  background-image: var(--wx-wall);
  background-size: 220px 220px;
}

/* No chat open: WhatsApp Web's resting screen, a white card on warm grey. */
.wx-intro {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem 4rem;
  background: var(--wx-rail);
  text-align: center;
}

.wx-intro-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  inline-size: min(440px, 100%);
  padding: 2.25rem 2rem 2rem;
  border-radius: 24px;
  background: var(--wx-panel);
}

.wx-intro img {
  inline-size: min(220px, 65%);
  margin-block-end: 0.75rem;
}

.wx-intro h2 {
  color: var(--wx-ink);
  font-size: 1.375rem;
  font-weight: 700;
}

.wx-intro p {
  margin: 0;
  color: var(--wx-sub);
  font-size: 0.875rem;
}

.wx-intro .wx-intro-foot {
  position: absolute;
  inset-block-end: 1.5rem;
  inset-inline: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
}

.wx-head {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-block-size: 64px;
  padding: 0.4rem 1rem;
  background: var(--wx-panel);
  border-block-end: 1px solid var(--wx-line);
}

.wx .wx-back {
  display: none;
}

.wx .wx-who {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.8rem;
  flex: 1;
  min-inline-size: 0;
  padding: 0.2rem;
  border: 0;
  border-radius: var(--wx-r);
  background: transparent;
  color: inherit;
  text-align: start;
}

.wx-who > .avatar {
  inline-size: 40px;
  block-size: 40px;
}

.wx-who-text {
  display: flex;
  flex-direction: column;
  min-inline-size: 0;
  line-height: 1.35;
}

.wx-who-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--wx-ink);
  font-size: 1rem;
  font-weight: 700;
}

.wx-who-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--wx-sub);
  font-size: 0.8125rem;
}

/* The AI switch, drawn like WhatsApp's outlined header pill ("الإضافة إلى
 * القائمة"): the assistant's mark, its name, then a real checkbox shown as a
 * green toggle. */
.wx .wx-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0.25rem;
  block-size: 2.5rem;
  padding-inline: 0.85rem 0.5rem;
  border: 1px solid var(--wx-border);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--wx-ink);
  font-size: 0.875rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.wx .wx-switch:hover {
  background: var(--wx-hover);
}

/* Arabic glyphs sit high in their line box; nudge the label down so it
 * centers against the icon and the toggle. */
.wx-switch-text {
  line-height: 1;
  padding-block-start: 0.2em;
}

.wx-switch img {
  inline-size: 18px;
  block-size: 18px;
}

.dark .wx-switch img,
.dark .wx-meta-ai {
  filter: invert(1);
}

.wx .wx-switch input {
  position: absolute;
  opacity: 0;
  inline-size: 1px;
  block-size: 1px;
  pointer-events: none;
}

.wx-switch-track {
  position: relative;
  inline-size: 34px;
  block-size: 20px;
  border-radius: var(--r-pill);
  background: var(--wx-toggle-off);
  transition: background-color var(--t-fast) ease;
}

.wx-switch-track::after {
  content: "";
  position: absolute;
  inset-block-start: 2px;
  inset-inline-start: 2px;
  inline-size: 16px;
  block-size: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: inset-inline-start var(--t-fast) ease;
}

.wx-switch input:checked + .wx-switch-track {
  background: var(--wx-green);
}

.wx-switch input:checked + .wx-switch-track::after {
  inset-inline-start: 16px;
}

.wx-switch input:focus-visible + .wx-switch-track {
  outline: 2px solid var(--wx-green);
  outline-offset: 2px;
}

.wx-switch:has(input:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Campaign lead waiting for an outcome — a yellow notice under the header. */
.wx-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.55rem 1rem;
  background: var(--wx-note);
  color: var(--wx-note-ink);
  font-size: 0.8125rem;
  box-shadow: var(--wx-shadow);
}

.wx-banner > .bx {
  font-size: 1.25rem;
}

.wx-banner-text {
  flex: 1 1 14rem;
}

/* -------------------------------------------------------------- messages */

.wx-log {
  flex: 1;
  min-block-size: 0;
  overflow-y: auto;
  overflow-x: hidden; /* the reply button sits outside the bubble and must not widen the page */
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  padding: 0.75rem clamp(2rem, 6%, 4.5rem) 0.5rem; /* 2rem leaves room for the reply button */
}

.wx-dayblock {
  display: flex;
  flex-direction: column;
}

.wx-day {
  position: sticky;
  inset-block-start: 0.5rem;
  z-index: 2;
  align-self: center;
  margin-block: 0.75rem 0.25rem;
}

.wx-day span,
.wx-event {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  border-radius: 8px;
  background: var(--wx-day);
  box-shadow: var(--wx-shadow);
  color: var(--wx-sub);
  font-size: 0.78rem;
}

.wx-event {
  align-self: center;
  max-inline-size: 85%;
  margin-block: 0.6rem 0.2rem;
  text-align: center;
}

.wx-msg {
  display: flex;
  flex-direction: column;
  max-inline-size: min(65%, 640px);
  margin-block-start: 2px;
}

.wx-msg.first {
  margin-block-start: 0.75rem;
}

.wx-msg.wx-in {
  align-self: flex-start;
  align-items: flex-start;
}

.wx-msg:not(.wx-in) {
  align-self: flex-end;
  align-items: flex-end;
}

.wx-bubble {
  position: relative;
  max-inline-size: 100%;
  padding: 0.4rem 0.6rem 0.45rem;
  border-radius: var(--wx-r);
  background: var(--wx-in);
  color: var(--wx-ink);
  box-shadow: var(--wx-shadow);
  font-size: var(--wx-text);
  line-height: 1.55;
}

.wx-out .wx-bubble,
.wx-ai .wx-bubble {
  background: var(--wx-out);
}

.wx-note .wx-bubble {
  background: var(--wx-note);
  color: var(--wx-note-ink);
}

/* The tail on the first bubble of each run, on its outer top corner. The
 * shapes are drawn for right-to-left, which is the only way this page runs. */
.wx-msg.first .wx-bubble::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inline-size: 8px;
  block-size: 13px;
  background: inherit;
}

.wx-msg.first.wx-in .wx-bubble {
  border-start-start-radius: 0;
}

.wx-msg.first.wx-in .wx-bubble::before {
  inset-inline-start: -8px;
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.wx-msg.first:not(.wx-in) .wx-bubble {
  border-start-end-radius: 0;
}

.wx-msg.first:not(.wx-in) .wx-bubble::before {
  inset-inline-end: -8px;
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.wx-sender {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-block-end: 0.1rem;
  color: var(--wx-green-ink);
  font-size: 0.8rem;
  font-weight: 800;
}

.wx-ai .wx-sender {
  color: #6d5dfc;
}

.dark .wx-ai .wx-sender {
  color: #a89dff;
}

.wx-note .wx-sender {
  color: inherit;
}

.wx-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Room at the end of the last line for the time, which sits over it. */
.wx-meta-gap {
  display: inline-block;
  inline-size: 4.6rem;
}

.wx-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: var(--wx-sub);
  font-size: 0.6875rem;
  white-space: nowrap;
}

.wx-out .wx-meta,
.wx-ai .wx-meta {
  color: var(--wx-meta-out);
}

.wx-note .wx-meta {
  color: color-mix(in srgb, var(--wx-note-ink) 70%, transparent);
}

.wx-bubble.has-text .wx-meta {
  position: absolute;
  inset-block-end: 0.3rem;
  inset-inline-end: 0.55rem;
}

.wx-bubble:not(.has-text) .wx-meta {
  display: flex;
  justify-content: flex-end;
  margin-block-start: 0.2rem;
}

.wx-meta-ai {
  inline-size: 12px;
  block-size: 12px;
  opacity: 0.75;
}

.wx-meta .msg-tick {
  margin: 0;
  font-size: 1rem;
  opacity: 1;
  color: inherit;
}

.wx-meta .msg-tick.read {
  color: var(--wx-read);
}

/* Files inside a bubble: the bubble is the frame, so the cards lose theirs. */
.wx-bubble.has-media {
  padding: 0.2rem 0.2rem 0.35rem;
}

.wx-bubble.has-media > .wx-sender,
.wx-bubble.has-media > .wx-text {
  padding-inline: 0.4rem;
}

.wx-bubble.has-media > .wx-text {
  padding-block-start: 0.3rem;
}

.wx-bubble.has-media:not(.has-text) .wx-meta {
  padding-inline: 0.4rem;
}

.wx-bubble .msg-file,
.wx-bubble .msg-doc,
.wx-bubble .voice {
  margin: 0;
  box-shadow: none;
}

.wx-bubble .msg-file {
  border-radius: 5px;
  background: transparent;
}

.wx-bubble .msg-file-foot {
  border-color: color-mix(in srgb, var(--wx-ink) 10%, transparent);
}

.wx-bubble .msg-doc {
  border-radius: 5px;
  background: color-mix(in srgb, var(--wx-ink) 5%, transparent);
}

.wx-bubble .voice {
  background: transparent;
}

.wx-bubble .voice-avatar,
.wx-bubble .voice-play {
  background: color-mix(in srgb, var(--wx-green) 16%, transparent);
  color: var(--wx-green-ink);
}

.wx-bubble .voice-mic {
  color: var(--wx-read);
  background: var(--wx-in);
}

.wx-bubble .voice-wave span.played {
  background: var(--wx-read);
}

.wx-msg.failed .wx-bubble {
  box-shadow: inset 0 0 0 1px var(--wx-danger);
}

.wx-msg .msg-failed {
  margin-block-start: 0.25rem;
}

/* -------------------------------------------------------------- composer */

/* The bar floats on the wallpaper as one rounded pill: attach and emoji at
 * the start, the text, then one round button that is a microphone while the
 * box is empty and a solid "send" once it is not. */
.wx-compose {
  position: relative;
  padding: 0.25rem 1rem 0.9rem;
}

.wx-compose.dropping .wx-bar {
  box-shadow: inset 0 0 0 2px var(--wx-green);
}

.wx-bar,
.wx-recording {
  display: flex;
  align-items: flex-end;
  gap: 0.1rem;
  min-block-size: 52px;
  padding: 0.3rem 0.4rem;
  border-radius: 26px;
  background: var(--wx-in);
  box-shadow: 0 1px 2px rgba(11, 20, 26, 0.08);
}

.wx-recording {
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.wx-input {
  flex: 1;
  min-inline-size: 0;
  display: flex;
  padding: 0.55rem 0.5rem;
}

.wx .wx-input textarea {
  display: block;
  min-block-size: 1.5rem;
  max-block-size: 7.8em;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  resize: none;
  color: var(--wx-ink);
  font-size: var(--wx-text);
  line-height: 1.55;
}

.wx .wx-input textarea:focus {
  box-shadow: none;
}

.wx .wx-input textarea::placeholder {
  color: var(--wx-sub);
}

.wx .wx-action {
  inline-size: 42px;
  block-size: 42px;
  padding: 0;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--wx-icon);
}

.wx .wx-action .bx {
  font-size: 1.5rem;
  /* The press lands on the button, not the glyph: the glyph is swapped while
   * a press is under way (paintAction), and a click whose press began on a
   * removed node is dropped. */
  pointer-events: none;
}

.wx .wx-action:hover {
  background: var(--wx-soft);
}

.wx .wx-action.send,
.wx .wx-recording .wx-action {
  background: var(--wx-primary);
  color: var(--wx-on-primary);
}

.wx .wx-action.send:hover:not(:disabled) {
  background: color-mix(in srgb, var(--wx-primary) 85%, var(--wx-panel));
}

/* WhatsApp's paperclip leans; the icon font's lies flat. */
.wx .wx-plus-btn .bx {
  rotate: -45deg;
}

/* Paper planes point the way the text runs. */
.wx .wx-action .bx-send {
  transform: scaleX(-1);
}

.wx-compose.noting .wx-bar {
  background: var(--wx-note);
}

.wx-compose.noting .wx-input textarea {
  color: var(--wx-note-ink);
}

.wx .wx-compose.noting .wx-action.send {
  background: #d99a00;
  color: #fff;
}

/* Notices above the bar are cards in the same family. */
.wx-note-strip,
.wx-attached {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-block-end: 0.4rem;
  padding: 0.35rem 0.4rem 0.35rem 0.9rem;
  border-radius: var(--wx-r-lg);
  font-size: 0.8125rem;
  box-shadow: var(--wx-shadow);
}

.wx-note-strip {
  background: var(--wx-note);
  color: var(--wx-note-ink);
}

.wx-attached {
  background: var(--wx-in);
  color: var(--wx-ink);
}

.wx-note-strip span,
.wx-attached .truncate {
  flex: 1;
}

.wx .wx-note-strip .wx-icon,
.wx .wx-attached .wx-icon {
  inline-size: 30px;
  block-size: 30px;
  color: inherit;
}

.wx .wx-note-strip .wx-icon .bx,
.wx .wx-attached .wx-icon .bx {
  font-size: 1.1rem;
}

.wx-attached-icon {
  display: inline-grid;
  place-items: center;
  inline-size: 30px;
  block-size: 30px;
  border-radius: 10px;
  background: color-mix(in srgb, #765afc 14%, transparent);
  color: #765afc;
  font-size: 1.1rem;
}

.wx-shut {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  padding: 1rem 1rem 1.1rem;
  border-radius: var(--wx-r-lg);
  background: var(--wx-in);
  box-shadow: var(--wx-shadow);
  text-align: center;
}


.wx-shut p {
  margin: 0;
  color: var(--wx-sub);
  font-size: 0.875rem;
}

.wx-shut-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.wx-templates {
  align-self: stretch;
  padding: 0.75rem;
  border-radius: 12px;
  background: var(--wx-soft);
  text-align: start;
}

.wx-templates .picker-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.wx-rec-dot {
  inline-size: 10px;
  block-size: 10px;
  border-radius: 50%;
  background: #ea0038;
  animation: wx-pulse 1.1s ease-in-out infinite;
}

.wx-rec-time {
  min-inline-size: 3rem;
  color: var(--wx-ink);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

@keyframes wx-pulse {
  50% {
    opacity: 0.3;
  }
}

.wx-emoji {
  inset-block-end: calc(100% + 4px);
  inset-inline-start: 1rem;
  display: grid;
  grid-template-columns: repeat(10, 2.6rem);
  max-block-size: 300px;
  overflow-y: auto;
  padding: 0.6rem;
}

.wx .wx-emoji button {
  inline-size: 2.6rem;
  block-size: 2.6rem;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 1.5rem;
}

.wx .wx-emoji button:hover {
  background: var(--wx-soft);
}

/* WhatsApp Web's attach menu: coloured glyphs, no discs behind them. */
.wx-plus {
  inset-block-end: calc(100% + 4px);
  inset-inline-start: 1rem;
  min-inline-size: 230px;
}

.wx .wx-plus-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.85rem;
  inline-size: 100%;
  padding: 0.6rem 0.85rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--wx-ink);
  font-size: 0.9375rem;
  font-weight: 600;
}

.wx .wx-plus-item:hover {
  background: var(--wx-soft);
}

.wx-plus-icon {
  display: inline-grid;
  place-items: center;
  font-size: 1.4rem;
}

.wx-plus-icon.doc {
  color: #765afc;
}

.wx-plus-icon.saved {
  color: #fcb13c;
}

.wx-plus-icon.note {
  color: #23c891;
}
.wx-plus-icon.translate {
  color: #4f8ef7;
}

.wx-quick {
  inset-block-end: calc(100% + 4px);
  inset-inline: 1rem;
  display: flex;
  flex-direction: column;
  max-block-size: 300px;
  padding: 0.35rem;
  overflow: hidden;
}

.wx-quick-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem 0.6rem;
  border-block-end: 1px solid var(--wx-line);
  margin-block-end: 0.25rem;
  color: var(--wx-ink);
  font-size: 0.875rem;
  font-weight: 800;
}

.wx-quick-head .bx {
  color: #fcb13c;
  font-size: 1.2rem;
}

.wx-quick-tip {
  margin-inline-start: auto;
  color: var(--wx-sub);
  font-weight: 600;
}

.wx-quick-list {
  overflow-y: auto;
}

.wx .wx-quick-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.05rem;
  inline-size: 100%;
  padding: 0.55rem 0.75rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--wx-ink);
  text-align: start;
}

.wx .wx-quick-item:hover,
.wx .wx-quick-item.on {
  background: var(--wx-soft);
}

.wx-quick-item span {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--wx-sub);
  font-size: 0.8125rem;
}

.wx-quick-code {
  margin-inline-start: 0.5rem;
  padding: 0.05rem 0.4rem;
  border-radius: 6px;
  background: var(--wx-soft);
  color: var(--wx-sub);
  font: 700 0.75rem/1.4 inherit;
  font-style: normal;
  direction: ltr;
  unicode-bidi: isolate;
}

.wx-quick .wx-muted {
  padding: 0.75rem;
}

/* ------------------------------------------------------------------ info */

/* WhatsApp's contact panel: one white sheet, sections split by thin inset
 * rules rather than grey gaps. */
.wx-info {
  flex: 0 0 400px;
  min-block-size: 0;
  display: flex;
  flex-direction: column;
  border-inline-start: 1px solid var(--wx-line);
  background: var(--wx-panel);
}

.wx:not(.wx-info-open) .wx-info,
.wx:not(.wx-chat-on) .wx-info {
  display: none;
}

.wx-info-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-block-size: 64px;
  padding: 0.4rem 1rem;
  background: var(--wx-panel);
}

.wx-info-head h2 {
  color: var(--wx-ink);
  font-size: 1rem;
  font-weight: 700;
}

.wx-info-scroll {
  flex: 1;
  min-block-size: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  padding-block-end: 1.25rem;
}

.wx-cards {
  display: flex;
  flex-direction: column;
}

.wx-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-inline: 1.5rem;
  padding: 1.1rem 0 1.2rem;
  border-block-end: 1px solid var(--wx-line);
}

.wx-card h3 {
  color: var(--wx-ink);
  font-size: 0.9375rem;
  font-weight: 700;
}

.wx-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.wx-profile {
  align-items: center;
  gap: 0.25rem;
  padding-block: 0.75rem 1.4rem;
  text-align: center;
}

.wx-profile > .avatar {
  inline-size: 120px;
  block-size: 120px;
  margin-block-end: 0.75rem;
  font-size: 2.4rem;
}

.wx-profile-name {
  color: var(--wx-ink);
  font-size: 1.375rem;
  font-weight: 700;
}

.wx-profile-phone {
  color: var(--wx-sub);
  font-size: 1rem;
}

.wx-profile-phone bdi {
  direction: ltr;
}

.wx-profile .tags {
  justify-content: center;
  margin-block-start: 0.35rem;
}

/* The round shortcuts under the name (WhatsApp: voice, video, search). */
.wx-tiles {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin-block-start: 0.9rem;
}

.wx .wx-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--wx-ink);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
}

.wx-tile-icon {
  display: inline-grid;
  place-items: center;
  inline-size: 52px;
  block-size: 52px;
  border-radius: 50%;
  background: var(--wx-soft);
  font-size: 1.4rem;
}

.wx .wx-tile:hover {
  color: var(--wx-ink);
  text-decoration: none;
}

.wx .wx-tile:hover .wx-tile-icon {
  background: var(--wx-chip-on);
}

.wx-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem 0.75rem;
  align-items: center;
  font-size: 0.875rem;
}

.wx-fact {
  display: contents;
}

.wx-fact-name {
  color: var(--wx-sub);
  font-size: 0.8125rem;
}

.wx-fact-value {
  justify-self: end;
  color: var(--wx-ink);
  text-align: end;
}

.wx-labels {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.wx-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding-block: 0.2rem;
  padding-inline: 0.6rem 0.2rem;
  border-radius: var(--r-pill);
  background: var(--wx-chip-on);
  color: var(--wx-ink);
  font-size: 0.75rem;
  font-weight: 700;
}

.wx-tag > .bx {
  color: var(--wx-green);
}

.wx .wx-tag button {
  inline-size: 18px;
  block-size: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
}

.wx .wx-tag button:hover {
  background: color-mix(in srgb, var(--wx-ink) 12%, transparent);
}

.wx .wx-label-input {
  flex: 1 1 8rem;
  inline-size: auto;
  padding: 0.35rem 0.75rem;
  border: 1px dashed var(--wx-border);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--wx-ink);
  font-size: 0.8125rem;
}

.wx-form label {
  margin-block-end: 0.25rem;
  color: var(--wx-sub);
  font-size: 0.75rem;
}

.wx .wx-form input,
.wx .wx-form textarea {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--wx-border);
  border-radius: 12px;
  background: transparent;
  color: var(--wx-ink);
  font-size: 0.875rem;
}

.wx .wx-form input:focus,
.wx .wx-form textarea:focus {
  border-color: var(--wx-green);
  box-shadow: inset 0 0 0 1px var(--wx-green);
}

.wx-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.wx-form .wx-btn {
  align-self: flex-start;
}

.wx-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.wx-mini {
  display: flex;
  flex-direction: column;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  background: var(--wx-soft);
}

.wx-mini strong {
  color: var(--wx-ink);
  font-size: 1.05rem;
  font-weight: 800;
}

.wx-mini span {
  color: var(--wx-sub);
  font-size: 0.75rem;
}

.wx-repeats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}

.wx-ticket {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px var(--wx-line);
  color: var(--wx-ink);
  font-size: 0.8125rem;
}

.wx-ticket:hover {
  background: var(--wx-hover);
  color: var(--wx-ink);
  text-decoration: none;
}

.wx-ticket-top {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.wx-ticket-top strong {
  margin-inline-end: auto;
}

.wx-ticket-desc {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--wx-sub);
}

.wx-ticket time {
  color: var(--wx-sub);
  font-size: 0.75rem;
}

/* No room for a third column: the panel slides over the chat instead. */
@media (max-width: 1280px) {
  .wx-info {
    position: absolute;
    inset-block: 0;
    inset-inline-end: 0;
    z-index: 30;
    inline-size: min(400px, 100%);
    box-shadow: 0 0 24px rgba(11, 20, 26, 0.2);
  }
}

@media (max-width: 1100px) {
  .wx-side {
    flex-basis: 320px;
  }

  .wx-switch-text {
    display: none;
  }
}

/* The assistant's held reply (0044, styles.css): on a phone the bar is two
 * rows (below), and its count joins the lower one, between the buttons and
 * send, only while it is running. */
@media (max-width: 860px) {
  .wx-bar.rv-counting {
    grid-template-columns: 1fr auto auto auto auto;
    grid-template-areas:
      "input input input input input"
      ". emoji plus timer action";
  }

  .wx-bar > .rv-timer {
    grid-area: timer;
    align-self: center;
    margin: 0;
  }
}

/* A phone: the WhatsApp app. One pane at a time, the list first, and the
 * message card with the text on top and its buttons in a row beneath. */
@media (max-width: 860px) {
  .wx-side {
    flex: 1 1 auto;
    border: 0;
  }

  .wx.wx-chat-on .wx-side,
  .wx:not(.wx-chat-on) .wx-chat {
    display: none;
  }

  .wx-side-head {
    min-block-size: 56px;
    padding-inline: 1rem;
  }

  .wx-side-head h1 {
    font-size: 1.5rem;
  }

  .wx-search {
    margin-inline: 0.85rem;
  }

  .wx-chips {
    padding-inline: 0.85rem;
  }

  .wx-rows {
    padding-inline: 0.25rem;
  }

  .wx-row {
    border-radius: 0;
  }

  .wx-row > .avatar {
    inline-size: 52px;
    block-size: 52px;
  }

  .wx .wx-back {
    display: inline-grid;
  }

  .wx-head {
    gap: 0.15rem;
    min-block-size: 58px;
    padding-inline: 0.25rem;
    border-block-end: 0;
  }

  .wx .wx-switch {
    padding-inline: 0.6rem 0.4rem;
    border-color: transparent;
  }

  .wx-info {
    inline-size: 100%;
  }

  .wx-msg {
    max-inline-size: 85%;
  }

  .wx-log {
    padding-inline: 0.85rem;
  }

  .wx-compose {
    padding: 0.2rem 0.6rem 0.6rem;
  }

  .wx-bar {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    grid-template-areas:
      "input input input input"
      ". emoji plus action";
    align-items: center;
    gap: 0.1rem;
    padding: 0.35rem 0.5rem 0.5rem;
    border-radius: 24px;
  }


  .wx-bar > .wx-input {
    grid-area: input;
    padding: 0.5rem 0.4rem 0.35rem;
  }

  .wx-bar > .wx-emoji-btn {
    grid-area: emoji;
  }

  .wx-bar > .wx-plus-btn {
    grid-area: plus;
  }

  .wx-bar > .wx-action {
    grid-area: action;
    inline-size: 48px;
    block-size: 48px;
    margin-inline-start: 0.35rem;
    background: var(--wx-primary);
    color: var(--wx-on-primary);
  }

  .wx-emoji {
    inset-inline: 0.5rem;
    grid-template-columns: repeat(auto-fill, minmax(2.5rem, 1fr));
  }

  .wx .wx-emoji button {
    inline-size: auto;
  }

  .wx-quick {
    inset-inline: 0.5rem;
  }

  /* The attach sheet: tiles with the glyph in a rounded square, the name
   * underneath. */
  .wx-plus {
    inset-inline: 0.5rem;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem 0.25rem;
    padding: 1.1rem 0.5rem 1rem;
    border-radius: 24px;
  }

  .wx .wx-plus-item {
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.45rem;
    padding: 0.2rem;
    font-size: 0.8125rem;
    text-align: center;
  }

  .wx .wx-plus-item:hover {
    background: transparent;
  }

  .wx-plus-icon {
    inline-size: 64px;
    block-size: 52px;
    border-radius: 20px;
    box-shadow: inset 0 0 0 1px var(--wx-line);
    font-size: 1.6rem;
  }

  .wx-card {
    margin-inline: 1.1rem;
  }
}

/* ------------------------------------------------------------- new chat */
/* The "+" beside المحادثات: a phone keypad on one side, who the number is
 * and the first template on the other. A native <dialog>, so focus stays
 * inside and Escape closes it for free. Lives on <body>, outside .wx. */
.dial {
  inline-size: min(720px, calc(100vw - 2rem));
  max-block-size: calc(100dvh - 2rem);
  padding: 1.25rem;
  border: 0;
  border-radius: 16px;
  background: var(--card);
  color: var(--heading);
}

.dial::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.dial-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block-end: 0.75rem;
}

.dial-head h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.dial .dial-x {
  inline-size: 36px;
  block-size: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--heading);
  box-shadow: none;
  font-size: 1.4rem;
}

.dial-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.dial-pad,
.dial-side {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.dial-side {
  border-inline-start: 1px solid var(--border);
  padding-inline-start: 1.25rem;
}

.dial-pad label,
.dial-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.dial input,
.dial select {
  inline-size: 100%;
  border-radius: 7px;
}

.dial-number {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 7px;
  background: var(--hover);
  direction: ltr;
  color: var(--muted);
  font-size: 1.3rem;
}

.dial .dial-number input {
  flex: 1;
  padding: 0.25rem 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  outline: none;
  color: var(--heading);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: left;
}

.dial-number:focus-within {
  outline: 2px solid var(--primary);
}

/* A phone keypad reads left to right whatever the page direction. */
.dial-keys {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  direction: ltr;
}

.dial .dial-keys button {
  block-size: 3.1rem;
  padding: 0;
  display: grid;
  place-items: center;
  line-height: 1;
  border: 0;
  border-radius: 7px;
  background: var(--hover);
  color: var(--heading);
  box-shadow: none;
  font-size: 1.3rem;
  font-weight: 700;
}

.dial .dial-keys button:hover {
  background: color-mix(in srgb, var(--hover) 80%, var(--primary));
}

.dial .dial-keys button:active {
  background: var(--primary-soft);
}

.dial .dial-keys button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.dial-found {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-ink);
}

.dial .dial-open {
  inline-size: 100%;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 7px;
}

/* One template only, so no picker — just its wording and the send button. */
.dial .picker-form > select {
  display: none;
}

.dial-muted {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.dial-card-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-block: 0.5rem;
}

.dial-ava {
  inline-size: 48px;
  block-size: 48px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-size: 1.5rem;
}

.dial-card-row b {
  display: block;
  font-size: 1.05rem;
  text-align: right;
}

.dial-card-row span {
  font-size: 0.8rem;
  color: var(--muted);
}

/* templateForm() from app.js: its preview as the green bubble the customer
 * will see, its send button full width. */
.dial .picker-preview {
  padding: 0.6rem 0.75rem;
  border-radius: 7px;
  background: var(--bubble-out);
  color: var(--heading);
}

.dial .picker-form > .filters {
  inline-size: 100%;
}

.dial .picker-form > button {
  inline-size: 100%;
  justify-content: center;
  border-radius: 7px;
}

@media (max-width: 640px) {
  .dial {
    padding: 1rem;
  }

  .dial-grid {
    grid-template-columns: 1fr;
  }

  .dial-side {
    border: 0;
    padding: 0;
  }
}

/* Replying to a message: a button on the bubble, a quote inside it, and the
 * same quote in a strip above the bar while the reply is being written. */
.wx-reply-btn {
  position: absolute;
  inset-block-start: 50%;
  translate: 0 -50%;
  /* Beside the bubble, toward the middle of the chat, so it never covers text. */
  inline-size: 26px;
  block-size: 26px;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.12s;
}

.wx-bubble:hover .wx-reply-btn,
.wx-reply-btn:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .wx-reply-btn {
    opacity: 0.6;
  }
}

.wx-quote {
  display: flex;
  flex-direction: column;
  min-inline-size: 0;
  margin-block-end: 0.3rem;
  padding: 0.25rem 0.5rem;
  border-inline-start: 4px solid var(--wx-green);
  border-radius: 6px;
  background: color-mix(in srgb, var(--wx-ink) 7%, transparent);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.wx-quote b {
  color: var(--wx-green-ink);
  font-weight: 600;
}

.wx-quote span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--wx-sub);
}

.wx-quoting .wx-quote {
  flex: 1;
  margin: 0;
}

.wx-in .wx-reply-btn {
  inset-inline-end: 100%;
}

.wx-msg:not(.wx-in) .wx-reply-btn {
  inset-inline-start: 100%;
}

/* Tapping a quote jumps to the original message and pulses it once. */
.wx-quote.jump {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.wx-quote.jump:hover {
  background: color-mix(in srgb, var(--wx-ink) 12%, transparent);
}

.wx-quote.jump:focus-visible {
  outline: 2px solid var(--wx-green);
  outline-offset: 2px;
}

.wx-msg.wx-flash .wx-bubble {
  animation: wx-flash 1.8s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes wx-flash {
  0%,
  100% {
    box-shadow: 0 0 0 0 transparent;
    filter: none;
  }
  18% {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--wx-green) 45%, transparent);
    filter: brightness(0.94);
  }
  60% {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--wx-green) 25%, transparent);
    filter: brightness(0.97);
  }
}

@media (prefers-reduced-motion: reduce) {
  .wx-msg.wx-flash .wx-bubble {
    animation-duration: 0.01s;
  }
}

/* The arrow in a bubble's corner and its menu, as WhatsApp Web draws them.
 * The arrow sits on a small patch of the bubble's own colour so it never
 * fights the text under it. */
.wx-drop {
  position: absolute;
  inset-block-start: 1px;
  inset-inline-end: 2px;
  display: grid;
  place-items: center;
  inline-size: 18px;
  block-size: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 60% 40%, var(--wx-in) 55%, transparent 100%);
  color: var(--wx-sub);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s;
}

.wx-out .wx-drop,
.wx-ai .wx-drop {
  background: radial-gradient(circle at 60% 40%, var(--wx-out) 55%, transparent 100%);
  color: var(--wx-meta-out);
}

.wx-note .wx-drop {
  background: radial-gradient(circle at 60% 40%, var(--wx-note) 55%, transparent 100%);
  color: var(--wx-note-ink);
}

.wx-drop .bx {
  font-size: 1.4rem;
}

.wx-bubble:hover .wx-drop,
.wx-drop:focus-visible,
.wx-drop[aria-expanded="true"] {
  opacity: 1;
}

@media (hover: none) {
  .wx-drop {
    opacity: 0.7;
  }
}

.wx-cm {
  inset-block-start: calc(100% + 4px);
  inset-inline-end: 0;
  min-inline-size: 190px;
  padding: 0.4rem;
}

.wx-cm.up {
  inset-block-start: auto;
  inset-block-end: calc(100% + 4px);
}

.wx-cm .wx-menu-item {
  padding: 0.5rem 0.75rem;
}

/* A translation sits under the original, set apart by a thin rule. */
.wx-translation {
  display: flex;
  gap: 0.4rem;
  margin-block-start: 0.35rem;
  padding-block: 0.3rem 1rem; /* the last row is left free for the timestamp */
  border-block-start: 1px solid color-mix(in srgb, var(--wx-ink) 14%, transparent);
}

.wx-translation span {
  min-inline-size: 0;
  overflow-wrap: anywhere;
}

.wx-translation .bx {
  flex: none;
  margin-block-start: 0.25rem;
  font-size: 0.95rem;
  color: var(--wx-sub);
}

/* A small phone with the ticket line and maybe a report to send in the
 * header too: a smaller picture and tighter buttons keep the name readable.
 * After the phone rules above, which it narrows. */
@media (max-width: 420px) {
  .wx .wx-who {
    gap: 0.5rem;
  }

  .wx-who > .avatar {
    inline-size: 34px;
    block-size: 34px;
  }

  .wx .wx-switch {
    margin: 0;
    padding-inline: 0.4rem 0.3rem;
  }

  .wx .wx-switch.wx-ops-btn {
    padding-inline: 0.35rem;
  }
}

/* Under 16px an iPhone zooms the page in when a field is tapped and never
 * zooms back out. The global 16px rule loses to the selectors above, so the
 * chat's own fields say it again, last. The message box keeps a larger
 * chat-text size if the person chose one. */
@media (max-width: 640px) {
  .wx .wx-search input,
  .wx .wx-label-input,
  .wx .wx-form input,
  .wx .wx-form textarea {
    font-size: 1rem;
  }

  .wx .wx-input textarea {
    font-size: max(1rem, var(--wx-text));
  }
}
