/* ============================================================================
   Client chat — Pages/Chat.razor and Pages/Admin/ClientChatRooms.razor.

   Rooms · conversation · people/thread, as three cards side by side on a desktop,
   the side panel as a drawer on a tablet, and one column at a time on a phone (the
   list, or the room with a back button). Every colour is a token, so both themes
   come for free.

   The page fills the canvas exactly and the message list scrolls inside it, the
   way a chat app behaves — the page itself never scrolls, so the composer is
   always under the thumb.
   ========================================================================== */

/* ---------------------------------------------------------------- rail badge */
.tms-rail-badge {
  position: absolute; top: 1px; right: 0;
  min-width: 17px; height: 17px; padding: 0 4px; box-sizing: border-box;
  border-radius: 999px; background: var(--tms-danger); color: var(--tms-on-danger);
  border: 2px solid var(--tms-rail);
  font-size: 10px; font-weight: 750; line-height: 13px; text-align: center;
  font-variant-numeric: tabular-nums; pointer-events: none;
}

/* ---------------------------------------------------------------- shell */
.tms-chat {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 14px; padding: 14px 18px;
  height: calc(100dvh - var(--tms-topbar-h));
  box-sizing: border-box;
}
.tms-chat.no-list { grid-template-columns: minmax(0, 1fr); }
.tms-chat.has-side { grid-template-columns: 300px minmax(0, 1fr) 300px; }
.tms-chat.no-list.has-side { grid-template-columns: minmax(0, 1fr) 300px; }

.tms-chat > .tms-card { min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

.tms-chat-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 28px 18px; text-align: center; color: var(--tms-text-3); font-size: 13.5px;
}
.tms-chat-empty .tms-i { font-size: 30px; color: var(--tms-text-3); opacity: .7; }
.tms-chat-empty p { margin: 0; max-width: 44ch; line-height: 1.5; }
.tms-chat-empty.is-big { flex: 1; }

/* ---------------------------------------------------------------- room list */
.tms-chat-rooms-h {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 13px 14px; border-bottom: 1px solid var(--tms-border);
}
.tms-chat-rooms-h h1 { font-size: var(--tms-fs-sub); font-weight: 650; margin: 0; letter-spacing: -.01em; }
.tms-chat-all {
  margin-left: auto; display: inline-flex; align-items: center; gap: 7px;
  font-size: var(--tms-fs-cap); color: var(--tms-text-2); cursor: pointer;
}

.tms-chat-filter {
  display: flex; align-items: center; gap: 7px; margin: 10px 12px 2px; padding: 0 10px;
  height: 32px; border: 1px solid var(--tms-border-strong); border-radius: var(--tms-r);
  color: var(--tms-text-3); background: var(--tms-surface);
}
.tms-chat-filter input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  color: var(--tms-text); font: inherit; font-size: var(--tms-fs-data);
}
.tms-chat-filter:focus-within { border-color: var(--tms-accent); box-shadow: 0 0 0 3px var(--tms-accent-tint); }

.tms-chat-rooms-list { flex: 1; overflow-y: auto; padding: 6px; }

.tms-chat-row {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 9px 10px 9px 12px; border-radius: var(--tms-r);
  color: var(--tms-text); text-decoration: none;
  transition: background-color var(--tms-fast);
}
.tms-chat-row:hover { background: var(--tms-surface-2); text-decoration: none; }
.tms-chat-row.is-skel { pointer-events: none; }

/* The ribbon: the open room carries the accent, a room with unread messages the info blue. */
.tms-chat-row::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px;
  border-radius: 0 3px 3px 0; background: transparent;
}
.tms-chat-row.is-unread::before { background: var(--tms-info); }
.tms-chat-row.is-active { background: var(--tms-accent-tint); }
.tms-chat-row.is-active::before { background: var(--tms-accent); }

.tms-chat-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tms-chat-row-top, .tms-chat-row-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tms-chat-row-top b {
  flex: 1; min-width: 0; font-size: var(--tms-fs-data); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tms-chat-row.is-unread .tms-chat-row-top b { font-weight: 750; }
.tms-chat-row-when { font-size: 11px; color: var(--tms-text-3); font-variant-numeric: tabular-nums; flex: none; }
.tms-chat-row.is-unread .tms-chat-row-when { color: var(--tms-info); font-weight: 650; }
.tms-chat-row-prev {
  flex: 1; min-width: 0; font-size: var(--tms-fs-cap); color: var(--tms-text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tms-chat-row.is-unread .tms-chat-row-prev { color: var(--tms-text-2); }
.tms-chat-row-who { color: var(--tms-text-2); font-weight: 600; margin-right: 3px; }

.tms-chat-count {
  flex: none; min-width: 19px; height: 19px; padding: 0 6px; box-sizing: border-box;
  border-radius: 999px; background: var(--tms-accent); color: var(--tms-on-accent);
  font-size: 11px; font-weight: 750; line-height: 19px; text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- room header */
.tms-chat-room { position: relative; }

.tms-chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--tms-border); flex: none;
}
.tms-chat-back { display: none; }
.tms-chat-head-t { flex: 1; min-width: 0; }
.tms-chat-head-t h2 {
  font-size: 14.5px; font-weight: 650; margin: 0; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tms-chat-head-sub { display: flex; align-items: center; gap: 7px; margin-top: 3px; font-size: var(--tms-fs-cap); color: var(--tms-text-3); }
.tms-chat-head-sub .tms-pill { height: 18px; font-size: 10.5px; }
.tms-chat-head-act { display: flex; gap: 6px; align-items: center; }
.tms-chat-head-act .is-on { background: var(--tms-accent-tint); color: var(--tms-accent-ink-2); }

/* Photos loaded by tms-chat.js sit on the initials avatar as a background. */
[data-chat-photo] { background-size: cover; background-position: center; }

/* ---------------------------------------------------------------- message list */
.tms-chat-list {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 10px 10px 16px;
  background: var(--tms-bg);
}

.tms-chat-older, .tms-chat-start { display: flex; justify-content: center; padding: 6px 0 12px; }
.tms-chat-start { font-size: var(--tms-fs-cap); color: var(--tms-text-3); }

.tms-chat-day { display: flex; justify-content: center; margin: 14px 0 8px; }
.tms-chat-day span {
  font-size: 11px; font-weight: 650; letter-spacing: .02em; color: var(--tms-text-2);
  background: var(--tms-surface); border: 1px solid var(--tms-border);
  border-radius: 999px; padding: 3px 11px; box-shadow: var(--tms-shadow-1);
}

/* "New": where the unread part began when the room was opened (as webmail chat). */
.tms-chat-new {
  display: flex; align-items: center; gap: 10px; margin: 10px 8px 4px;
  font-size: 11px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; color: var(--tms-danger);
}
.tms-chat-new::before, .tms-chat-new::after { content: ""; flex: 1; height: 1px; background: var(--tms-danger-line); }
.tms-chat-new span {
  padding: 1px 8px; border-radius: 999px; border: 1px solid var(--tms-danger-line); background: var(--tms-danger-tint);
}

/* One message. Mine sit on the right, everyone else's on the left with an avatar. */
.tms-cm {
  position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 8px;
  padding: 6px 8px 2px; border-radius: var(--tms-r);
}
.tms-cm.is-cont { padding-top: 1px; }
.tms-cm.is-mine { grid-template-columns: minmax(0, 1fr); }
.tms-cm.is-mine .tms-cm-av { display: none; }
.tms-cm-av { padding-top: 2px; }
.tms-cm-av .tms-av { width: 32px; height: 32px; font-size: 12px; }

.tms-cm-main { min-width: 0; max-width: min(680px, 82%); display: flex; flex-direction: column; align-items: flex-start; }
.tms-cm.is-mine .tms-cm-main { margin-left: auto; align-items: flex-end; }

.tms-cm-h { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin: 0 2px 3px; }
.tms-cm-who { font-size: var(--tms-fs-data); font-weight: 650; color: var(--tms-text); }
.tms-cm-when { font-size: 11px; color: var(--tms-text-3); font-variant-numeric: tabular-nums; }
.tms-cm-h .tms-pill { height: 18px; font-size: 10.5px; }

.tms-chat-tag {
  font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 1px 6px; border-radius: var(--tms-r-sm); border: 1px solid;
}
.tms-chat-tag.is-support { color: var(--tms-accent-ink-2); background: var(--tms-accent-tint); border-color: var(--tms-accent-line); }
.tms-chat-tag.is-client  { color: var(--tms-progress); background: var(--tms-progress-tint); border-color: var(--tms-progress-line); }

.tms-cm-bubble {
  position: relative; max-width: 100%; box-sizing: border-box;
  background: var(--tms-surface); border: 1px solid var(--tms-border);
  border-radius: 4px 14px 14px 14px; padding: 7px 11px 6px;
  box-shadow: var(--tms-shadow-1);
}
.tms-cm.is-cont .tms-cm-bubble { border-radius: 14px; }
.tms-cm.is-mine .tms-cm-bubble {
  background: var(--tms-accent-tint); border-color: var(--tms-accent-line);
  border-radius: 14px 4px 14px 14px;
}
.tms-cm.is-mine.is-cont .tms-cm-bubble { border-radius: 14px; }

/* Internal note: amber, hatched, never mistaken for something the client can read. */
.tms-cm.is-internal .tms-cm-bubble,
.tms-chat-tm.is-internal .tms-chat-tm-main {
  border-color: var(--tms-warn-line);
  background:
    repeating-linear-gradient(135deg,
      transparent 0 9px,
      color-mix(in srgb, var(--tms-warn-line) 38%, transparent) 9px 11px),
    var(--tms-warn-tint);
}

.tms-cm.is-deleted .tms-cm-bubble { background: transparent; box-shadow: none; border-style: dashed; }
.tms-cm-gone { font-size: var(--tms-fs-data); font-style: italic; color: var(--tms-text-3); }

.tms-cm-c {
  font-size: 13.5px; line-height: 1.55; color: var(--tms-text);
  overflow-wrap: anywhere; white-space: normal;
}
.tms-cm-c p { margin: 0 0 6px; }
.tms-cm-c p:last-child { margin: 0; }
.tms-cm-c img, .tms-cm-c video { max-width: 100%; height: auto; border-radius: var(--tms-r); }
.tms-cm-c pre {
  max-width: 100%; overflow-x: auto; margin: 6px 0;
  background: var(--tms-surface-2); border: 1px solid var(--tms-border);
  border-radius: var(--tms-r); padding: 8px 10px;
}
.tms-cm-c code {
  font-family: var(--tms-font-mono); font-size: var(--tms-fs-cap);
  background: var(--tms-surface-2); border: 1px solid var(--tms-border);
  border-radius: var(--tms-r-sm); padding: 0 4px;
}
.tms-cm-c pre code { background: none; border: none; padding: 0; }
.tms-cm-c blockquote { margin: 4px 0; padding: 2px 0 2px 10px; border-left: 3px solid var(--tms-border-strong); color: var(--tms-text-2); }
.tms-cm-c ul, .tms-cm-c ol { margin: 4px 0; padding-left: 20px; }
.tms-cm-c a { color: var(--tms-accent); text-decoration: underline; }

.tms-cm-fwd { font-size: 11.5px; font-style: italic; color: var(--tms-text-3); margin-bottom: 3px; display: flex; align-items: center; gap: 4px; }

/* The quoted message a reply answers. Clicking it jumps to the original. */
.tms-cm-quote {
  display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left;
  margin: 1px 0 6px; padding: 5px 9px; border-radius: var(--tms-r);
  border-left: 3px solid var(--tms-accent);
  background: color-mix(in srgb, var(--tms-text) 6%, transparent);
  font-size: var(--tms-fs-cap); color: var(--tms-text-2);
}
.tms-cm-quote b { color: var(--tms-accent-ink-2); font-weight: 650; }
.tms-cm-quote span { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.tms-cm-meta {
  display: flex; justify-content: flex-end; align-items: center; gap: 6px;
  margin-top: 2px; font-size: 10.5px; color: var(--tms-text-3); font-variant-numeric: tabular-nums;
}
.tms-cm-meta:empty { display: none; }

/* Ticks: one for sent, two for delivered, two in colour for seen. */
.tms-cm-tick { display: inline-flex; align-items: center; color: var(--tms-text-3); font-size: 13px; }
.tms-cm-tick .tms-i + .tms-i { margin-left: -.55em; }
.tms-cm-tick.is-seen { color: var(--tms-info); }

/* files */
.tms-chat-imgs { display: grid; grid-template-columns: repeat(2, minmax(0, 160px)); gap: 4px; margin: 4px 0 2px; }
.tms-chat-imgs.is-one { grid-template-columns: minmax(0, 300px); }
.tms-chat-img-wrap { position: relative; display: block; min-width: 0; }
.tms-chat-img {
  display: block; width: 100%; padding: 0; border-radius: var(--tms-r); overflow: hidden;
  background: var(--tms-surface-2); border: 1px solid var(--tms-border);
  min-height: 80px; cursor: zoom-in;
}
.tms-chat-img img { display: block; width: 100%; max-height: 260px; object-fit: cover; }
.tms-chat-imgs.is-one .tms-chat-img img { object-fit: contain; max-height: 320px; }
.tms-chat-img img.is-broken { visibility: hidden; }

.tms-chat-files { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 2px; }
.tms-chat-file {
  display: flex; align-items: stretch; max-width: 340px;
  border: 1px solid var(--tms-border); border-radius: var(--tms-r);
  background: var(--tms-surface); overflow: hidden;
}
.tms-chat-file-open {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px;
  padding: 6px 9px; text-align: left; color: var(--tms-text); font-size: var(--tms-fs-data);
}
.tms-chat-file-open:hover { background: var(--tms-surface-2); }
.tms-chat-file-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.tms-chat-file-s { font-size: 11px; color: var(--tms-text-3); flex: none; }
.tms-chat-file-dl { padding: 0 9px; color: var(--tms-text-3); border-left: 1px solid var(--tms-border); }
.tms-chat-file-dl:hover { color: var(--tms-text); background: var(--tms-surface-2); }

/* A file's type as a small tinted badge: PDF, DOCX, XLSX… (also in the composer, the viewer
   and the Files panel). Tint fill, saturated text, 1px border — never a solid block. */
.tms-chat-ext {
  flex: none; display: inline-grid; place-items: center; min-width: 30px; height: 20px; padding: 0 4px;
  box-sizing: border-box; border-radius: var(--tms-r-sm); border: 1px solid var(--tms-border-strong);
  background: var(--tms-surface-2); color: var(--tms-text-2);
  font-size: 9.5px; font-weight: 750; letter-spacing: .03em; line-height: 1;
}
.tms-chat-ext .tms-i { font-size: 14px; }
.tms-chat-ext.is-pdf    { background: var(--tms-danger-tint);   color: var(--tms-danger);        border-color: var(--tms-danger-line); }
.tms-chat-ext.is-doc    { background: var(--tms-info-tint);     color: var(--tms-info);          border-color: var(--tms-info-line); }
.tms-chat-ext.is-sheet  { background: var(--tms-ok-tint);       color: var(--tms-ok);            border-color: var(--tms-ok-line); }
.tms-chat-ext.is-slides { background: var(--tms-warn-tint);     color: var(--tms-warn);          border-color: var(--tms-warn-line); }
.tms-chat-ext.is-zip    { background: var(--tms-progress-tint); color: var(--tms-progress);      border-color: var(--tms-progress-line); }
.tms-chat-ext.is-media,
.tms-chat-ext.is-link   { background: var(--tms-accent-tint);   color: var(--tms-accent-ink-2);  border-color: var(--tms-accent-line); }
.tms-chat-ext.is-big { min-width: 56px; height: 56px; border-radius: var(--tms-r-lg); font-size: 13px; }

/* Taking one file out of my sent message: a small x, then "Remove?" to be sure. */
.tms-chat-rmfile {
  flex: none; display: inline-grid; place-items: center; padding: 0 8px;
  color: var(--tms-text-3); border-left: 1px solid var(--tms-border); font-size: 13px;
}
.tms-chat-rmfile:hover { color: var(--tms-danger); background: var(--tms-danger-tint); }
.tms-chat-rmfile.is-sure {
  font-size: 11.5px; font-weight: 700; color: var(--tms-danger);
  background: var(--tms-danger-tint); border-left-color: var(--tms-danger-line);
}
.tms-chat-img-wrap > .tms-chat-rmfile {
  position: absolute; top: 5px; right: 5px; height: 24px; min-width: 24px; padding: 0 6px;
  border: 1px solid var(--tms-border); border-radius: 999px;
  background: var(--tms-surface); box-shadow: var(--tms-shadow-1);
  opacity: 0; transition: opacity var(--tms-fast);
}
.tms-chat-img-wrap > .tms-chat-rmfile.is-sure { opacity: 1; border-color: var(--tms-danger-line); background: var(--tms-danger-tint); }
.tms-chat-img-wrap:hover > .tms-chat-rmfile, .tms-chat-img-wrap > .tms-chat-rmfile:focus-visible { opacity: 1; }
@media (hover: none) { .tms-chat-img-wrap > .tms-chat-rmfile { opacity: 1; } }

/* reactions and thread link under the bubble */
.tms-cm-reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tms-cm-react {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px;
  border-radius: 999px; border: 1px solid var(--tms-border); background: var(--tms-surface);
  font-size: 13px; color: var(--tms-text-2);
}
.tms-cm-react b { font-size: 11px; font-weight: 650; }
.tms-cm-react:hover { border-color: var(--tms-border-strong); }
.tms-cm-react.is-on { background: var(--tms-accent-tint); border-color: var(--tms-accent-line); color: var(--tms-accent-ink-2); }

.tms-cm-thread {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; padding: 2px 6px;
  border-radius: var(--tms-r-sm); font-size: var(--tms-fs-cap); font-weight: 650; color: var(--tms-accent);
}
.tms-cm-thread span { font-weight: 450; color: var(--tms-text-3); }
.tms-cm-thread:hover { background: var(--tms-accent-tint); }

/* Hover toolbar (or tap, on a touch screen). */
.tms-cm-acts {
  position: absolute; top: -12px; right: 14px; z-index: 3;
  display: none; align-items: center; gap: 1px; padding: 2px;
  background: var(--tms-surface); border: 1px solid var(--tms-border);
  border-radius: var(--tms-r); box-shadow: var(--tms-shadow-2);
}
.tms-cm.is-mine .tms-cm-acts { right: auto; left: 14px; }
.tms-cm-acts > button {
  width: 28px; height: 26px; display: grid; place-items: center;
  border-radius: var(--tms-r-sm); color: var(--tms-text-2); font-size: 15px;
}
.tms-cm-acts > button:hover, .tms-cm-acts > button.is-on { background: var(--tms-surface-2); color: var(--tms-text); }
.tms-cm-acts > button.is-danger:hover { color: var(--tms-danger); background: var(--tms-danger-tint); }

@media (hover: hover) {
  .tms-cm:hover { background: color-mix(in srgb, var(--tms-surface-2) 55%, transparent); }
  .tms-cm:hover .tms-cm-acts { display: flex; }
}
.tms-cm.is-picked { background: color-mix(in srgb, var(--tms-surface-2) 70%, transparent); }
.tms-cm.is-picked .tms-cm-acts { display: flex; }
.tms-cm.is-flash { animation: tms-chat-flash 1.4s var(--tms-ease); }
@keyframes tms-chat-flash {
  0%, 30% { background: var(--tms-accent-tint); }
  100% { background: transparent; }
}

.tms-cm-emoji {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 4;
  display: grid; grid-template-columns: repeat(8, 32px); gap: 2px; padding: 4px;
  background: var(--tms-surface); border: 1px solid var(--tms-border);
  border-radius: var(--tms-r-lg); box-shadow: var(--tms-shadow-3);
}
.tms-cm.is-mine .tms-cm-emoji { right: auto; left: 0; }
.tms-cm-emoji button { width: 32px; height: 32px; border-radius: var(--tms-r); font-size: 18px; line-height: 1; }
.tms-cm-emoji button:hover { background: var(--tms-surface-2); transform: scale(1.12); }

/* "N new messages" when the reader has scrolled up. */
.tms-chat-jump {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 132px; z-index: 5;
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 13px;
  border-radius: 999px; background: var(--tms-accent); color: var(--tms-on-accent);
  font-size: var(--tms-fs-cap); font-weight: 650; box-shadow: var(--tms-shadow-2);
}
.tms-chat-jump .tms-i { transform: rotate(90deg); }

/* ---------------------------------------------------------------- reply / edit banner, files waiting */
.tms-chat-banner {
  display: flex; align-items: center; gap: 9px; margin-bottom: 7px; padding: 6px 4px 6px 10px;
  border-left: 3px solid var(--tms-accent); border-radius: var(--tms-r);
  background: var(--tms-surface-2); font-size: var(--tms-fs-cap); color: var(--tms-text-2);
}
.tms-chat-banner b { color: var(--tms-text); font-weight: 650; }
.tms-chat-banner-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tms-chat-banner-t span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tms-chat-banner > span:not(.tms-chat-banner-t) { flex: 1; }
.tms-chat-banner .tms-icon-btn { width: 28px; height: 28px; }

.tms-chat-pending { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 7px; }
.tms-chat-up {
  position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 6px;
  max-width: 260px; height: 30px; padding: 0 4px 0 9px;
  border: 1px solid var(--tms-border-strong); border-radius: 999px; background: var(--tms-surface);
  font-size: var(--tms-fs-cap); color: var(--tms-text-2);
}
.tms-chat-up.is-done { border-color: var(--tms-accent-line); }
.tms-chat-up.is-error { border-color: var(--tms-danger-line); background: var(--tms-danger-tint); color: var(--tms-danger); }
.tms-chat-up-n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.tms-chat-up-pct { flex: none; color: var(--tms-text-3); font-variant-numeric: tabular-nums; }
.tms-chat-up-err { flex: none; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tms-chat-up-x { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; color: var(--tms-text-3); flex: none; }
.tms-chat-up-x:hover { background: var(--tms-surface-2); color: var(--tms-text); }
.tms-chat-up-bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--tms-accent); transition: width .15s linear; }

.tms-chat-up .tms-chat-ext { height: 18px; min-width: 28px; }
.tms-chat-up-n.is-link { text-align: left; color: var(--tms-text); cursor: pointer; }
.tms-chat-up-n.is-link:hover { color: var(--tms-accent); text-decoration: underline; }

/* Pictures waiting to be sent: tiles to check before sending (click for the viewer), as webmail chat. */
.tms-chat-pending { align-items: center; }
.tms-cc-tile {
  position: relative; flex: none; width: 76px; height: 76px; box-sizing: border-box; overflow: hidden;
  border: 1px solid var(--tms-border-strong); border-radius: var(--tms-r-lg); background: var(--tms-surface-2);
}
.tms-cc-tile.is-done { border-color: var(--tms-accent-line); }
.tms-cc-tile-see { display: block; width: 100%; height: 100%; padding: 0; cursor: zoom-in; }
.tms-cc-tile-see img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tms-cc-tile-see img.is-broken { visibility: hidden; }
.tms-cc-tile-wait {
  display: grid; place-items: center; width: 100%; height: 100%;
  font-size: var(--tms-fs-cap); color: var(--tms-text-3); font-variant-numeric: tabular-nums;
}
.tms-cc-tile-x {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--tms-border); background: var(--tms-surface);
  color: var(--tms-text-2); box-shadow: var(--tms-shadow-1); font-size: 12px;
}
.tms-cc-tile-x:hover { color: var(--tms-danger); background: var(--tms-danger-tint); border-color: var(--tms-danger-line); }

/* ---------------------------------------------------------------- composer
   Components/TmsChatComposer.razor — the same box as webmail chat's composer:
   one bordered box, the text on top and a toolbar row below. Popovers (the @ / :
   suggestions, emoji, schedule) open upwards over the messages, anchored to
   .tms-cc so the toolbar can scroll sideways on a phone without clipping them. */
.tms-cc {
  position: relative; flex: none;
  padding: 6px 12px 12px; background: var(--tms-surface);
  border-top: 1px solid var(--tms-border);
}

.tms-cc-box {
  position: relative;
  border: 1px solid var(--tms-border-strong); border-radius: var(--tms-r-lg);
  background: var(--tms-surface);
  transition: border-color var(--tms-fast), box-shadow var(--tms-fast);
}
.tms-cc-box:focus-within { border-color: var(--tms-accent); box-shadow: 0 0 0 3px var(--tms-accent-tint); }

/* Internal note: the whole box turns amber so nobody sends a note to the client by mistake. */
.tms-cc.is-internal .tms-cc-box { border-color: var(--tms-warn); background: var(--tms-warn-tint); }
.tms-cc.is-internal .tms-cc-box:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--tms-warn) 22%, transparent); }
.tms-cc-note-hint {
  display: flex; align-items: center; gap: 6px; margin: 0; padding: 6px 11px;
  font-size: var(--tms-fs-cap); font-weight: 650; color: var(--tms-warn);
  border-bottom: 1px solid var(--tms-warn-line);
  border-radius: var(--tms-r-lg) var(--tms-r-lg) 0 0;
}

.tms-cc-box > .tms-chat-banner { margin: 8px 8px 0; }
.tms-cc-box > .tms-chat-pending { margin: 8px 10px 0; }

.tms-cc-input {
  display: block; width: 100%; box-sizing: border-box; resize: none; overflow-y: hidden;
  min-height: 42px; max-height: 200px; padding: 10px 12px 4px;
  border: none; outline: none; background: transparent; color: var(--tms-text);
  font: inherit; font-size: var(--tms-fs-body); line-height: 1.45;
}
.tms-cc-input::placeholder { color: var(--tms-text-3); }
/* Editing a sent message: a roomy box (about 4 lines, growing to half the screen; tms-chat.js grow). */
.tms-cc.is-editing .tms-cc-input { min-height: 96px; max-height: 50vh; }
/* The box around it shows the focus; a second ring on the text itself is noise. */
.tms .tms-cc-input:focus-visible { outline: none; }

/* the link form: text + address */
.tms-cc-link { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px 0; }
.tms-cc-link .tms-input { flex: 1 1 160px; min-width: 0; height: 32px; font-size: var(--tms-fs-data); }

/* ---- toolbar */
.tms-cc-tools { display: flex; align-items: center; gap: 2px; padding: 4px 6px 6px; min-width: 0; }
.tms-cc-fmt { display: inline-flex; align-items: center; gap: 2px; }

.tms-cc-tb {
  position: relative; flex: none;
  width: 30px; height: 28px; display: inline-grid; place-items: center;
  border-radius: var(--tms-r-sm); color: var(--tms-text-2); font-size: 13px; cursor: pointer;
  transition: background-color var(--tms-fast), color var(--tms-fast);
}
.tms-cc-tb:hover, .tms-cc-tb.is-on { background: var(--tms-surface-2); color: var(--tms-text); }
.tms-cc-tb .tms-i { font-size: 16px; }
.tms-cc-tb.is-busy { opacity: .45; cursor: progress; }
.tms-cc-tb b { font-weight: 800; }
.tms-cc-serif { font-family: Georgia, "Times New Roman", serif; font-size: 15px; }
.tms-cc-mono { font-family: var(--tms-font-mono); font-size: 11px; font-weight: 650; }
.tms-cc-quote { font-size: 17px; line-height: 1; }
.tms-cc-at { font-size: 15px; font-weight: 650; }
.tms-cc-sep { flex: none; width: 1px; height: 16px; margin: 0 4px; background: var(--tms-border); }

/* "Aa" only on a phone, where it opens the formatting row. */
.tms-cc-aa { display: none; width: auto; padding: 0 7px; font-weight: 700; font-size: 13px; }
.tms-cc-aa[aria-pressed="true"] { background: var(--tms-accent-tint); color: var(--tms-accent-ink-2); }

.tms-cc-internal { width: auto; gap: 5px; padding: 0 8px; display: inline-flex; font-size: var(--tms-fs-cap); font-weight: 650; }
.tms-cc-internal .tms-i { font-size: 14px; }
.tms-cc-internal.is-on { color: var(--tms-warn); background: color-mix(in srgb, var(--tms-warn) 16%, transparent); }

.tms-cc-hint { margin-left: auto; padding: 0 10px; font-size: 11px; color: var(--tms-text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* Send + "schedule for later" as one split button. */
.tms-cc-sendgrp { flex: none; margin-left: auto; display: inline-flex; gap: 1px; }
.tms-cc-hint + .tms-cc-sendgrp { margin-left: 0; }
/* Editing: Cancel beside Save, right under the box. */
.tms-cc.is-editing .tms-cc-sendgrp { gap: 6px; }
.tms-cc-cancel { height: 30px; padding: 0 12px; font-size: var(--tms-fs-data); }
.tms-cc-send { height: 30px; padding: 0 12px; gap: 6px; font-size: var(--tms-fs-data); }
.tms-cc-send.has-more { border-radius: var(--tms-r) 0 0 var(--tms-r); }
.tms-cc-more { width: 28px; padding: 0; border-radius: 0 var(--tms-r) var(--tms-r) 0; }
.tms-cc-more .tms-i { font-size: 14px; }
.tms-cc.is-internal .tms-cc-send { background: var(--tms-warn); color: var(--tms-surface); }
.tms-cc-send[disabled] { opacity: .45; }

/* recording bar */
.tms-cc-rec { gap: 10px; padding: 6px 10px 8px; }
.tms-cc-rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tms-danger); animation: tms-cc-rec 1s infinite; flex: none; }
.tms-cc-rec-t { font-size: var(--tms-fs-data); font-weight: 650; font-variant-numeric: tabular-nums; }
.tms-cc-grow { flex: 1; }
@keyframes tms-cc-rec { 50% { opacity: .3; } }

.tms-cc-note, .tms-cc-err { margin: 0 12px 8px; font-size: var(--tms-fs-cap); color: var(--tms-text-3); }
.tms-cc-err { color: var(--tms-danger); }
.tms-cc-linkbtn { color: var(--tms-accent); font-weight: 650; text-decoration: underline; }

/* ---- scheduled messages, above the box */
.tms-cc-sched { margin: 0 0 6px; }
.tms-cc-sched-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 26px; padding: 0 10px;
  border-radius: 999px; border: 1px solid var(--tms-info-line); background: var(--tms-info-tint);
  color: var(--tms-info); font-size: var(--tms-fs-cap);
}
.tms-cc-sched-chip > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tms-cc-sched-chip b { font-weight: 700; }
.tms-cc-sched-chip .tms-i { flex: none; font-size: 13px; transition: transform var(--tms-fast); }
.tms-cc-sched-chip .tms-i.is-up { transform: rotate(180deg); }
.tms-cc-sched-list {
  list-style: none; margin: 6px 0 0; padding: 4px; display: flex; flex-direction: column; gap: 2px;
  max-height: 200px; overflow-y: auto;
  border: 1px solid var(--tms-border); border-radius: var(--tms-r-lg); background: var(--tms-surface-2);
}
.tms-cc-sched-list li { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 8px; border-radius: var(--tms-r); font-size: var(--tms-fs-data); }
.tms-cc-sched-list li:hover { background: var(--tms-surface); }
.tms-cc-sched-at { flex: none; font-weight: 650; white-space: nowrap; }
.tms-cc-sched-body { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--tms-text-2); }
.tms-cc-sched-list .tms-btn-sm { height: 26px; padding: 0 8px; flex: none; }

/* ---- popovers */
.tms-cc-scrim { position: fixed; inset: 0; z-index: 6; }
.tms-cc-pop {
  position: absolute; bottom: calc(100% - 4px); z-index: 7;
  background: var(--tms-surface); color: var(--tms-text);
  border: 1px solid var(--tms-border); border-radius: var(--tms-r-lg); box-shadow: var(--tms-shadow-3);
}

.tms-cc-pick { left: 14px; width: min(340px, calc(100% - 28px)); padding: 4px; display: flex; flex-direction: column; }
.tms-cc-pick > button {
  display: flex; align-items: center; gap: 9px; width: 100%; min-width: 0; padding: 6px 8px;
  border-radius: var(--tms-r); text-align: left; font-size: var(--tms-fs-data);
}
.tms-cc-pick > button.is-on { background: var(--tms-accent-tint); }
.tms-cc-pick > button:hover { background: var(--tms-surface-2); }
.tms-cc-pick .tms-av { width: 24px; height: 24px; font-size: 10px; flex: none; }
.tms-cc-pick b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tms-cc-pick-sub { margin-left: auto; padding-left: 8px; font-size: 11.5px; color: var(--tms-text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tms-cc-pick-emoji { width: 24px; text-align: center; font-size: 18px; flex: none; }
.tms-cc-pick-keys { padding: 4px 8px 2px; font-size: 10.5px; color: var(--tms-text-3); border-top: 1px solid var(--tms-border); margin-top: 2px; }

.tms-cc-emoji {
  right: 14px; width: min(320px, calc(100% - 28px)); padding: 8px;
  display: flex; flex-direction: column; gap: 6px;
}
.tms-cc-emoji-find { height: 32px; font-size: var(--tms-fs-data); }
.tms-cc-emoji-cats { display: flex; gap: 2px; padding-bottom: 4px; border-bottom: 1px solid var(--tms-border); }
.tms-cc-emoji-cats button { flex: 1; height: 30px; border-radius: var(--tms-r-sm); font-size: 16px; opacity: .55; }
.tms-cc-emoji-cats button:hover { opacity: .85; background: var(--tms-surface-2); }
.tms-cc-emoji-cats button.is-on { opacity: 1; background: var(--tms-accent-tint); }
.tms-cc-emoji-grid {
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px;
  max-height: min(230px, 40dvh); overflow-y: auto; overscroll-behavior: contain;
}
.tms-cc-emoji-grid button { height: 34px; border-radius: var(--tms-r-sm); font-size: 20px; line-height: 1; }
.tms-cc-emoji-grid button:hover { background: var(--tms-surface-2); }
.tms-cc-emoji-none { grid-column: 1 / -1; padding: 14px 4px; text-align: center; font-size: var(--tms-fs-cap); color: var(--tms-text-3); }

.tms-cc-sched-menu { right: 14px; width: 260px; padding: 8px; display: flex; flex-direction: column; gap: 2px; font-size: var(--tms-fs-data); }
.tms-cc-sched-menu > b { padding: 2px 8px 6px; font-weight: 650; }
.tms-cc-sched-menu > button[role=menuitem] {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 6px 8px;
  border-radius: var(--tms-r); text-align: left;
}
.tms-cc-sched-menu > button[role=menuitem]:hover { background: var(--tms-surface-2); }
.tms-cc-sched-menu small { font-size: 11.5px; color: var(--tms-text-3); }
.tms-cc-sched-custom { display: flex; flex-direction: column; gap: 4px; padding: 8px 8px 4px; margin-top: 4px; border-top: 1px solid var(--tms-border); font-size: var(--tms-fs-cap); color: var(--tms-text-2); }
.tms-cc-sched-custom .tms-input { height: 32px; font-size: var(--tms-fs-data); }
.tms-cc-sched-menu > .tms-btn { margin: 4px 8px 2px; }

/* Files dragged over the conversation. */
.tms-chat-room.is-dropping::after {
  content: "Drop files to attach them"; position: absolute; inset: 8px; z-index: 30;
  display: grid; place-items: center; pointer-events: none;
  border: 2px dashed var(--tms-accent); border-radius: var(--tms-r-lg);
  background: color-mix(in srgb, var(--tms-accent-tint) 85%, transparent);
  color: var(--tms-accent-ink-2); font-weight: 650; font-size: 14px;
}

/* ---------------------------------------------------------------- voice player */
.tms-chat-voice {
  display: flex; align-items: center; gap: 8px; width: 340px; max-width: 100%; box-sizing: border-box;
  margin: 4px 0 2px; padding: 6px;
  border: 1px solid var(--tms-border); border-radius: 999px; background: var(--tms-surface);
}
.tms-chat-voice-play {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--tms-accent); color: var(--tms-on-accent); font-size: 15px;
}
.tms-chat-voice-play:hover { background: var(--tms-accent-dark); }
.tms-chat-voice-play > * { grid-area: 1 / 1; }
.tms-chat-voice-play .is-pause, .tms-chat-voice-play .is-load { display: none; }
.tms-chat-voice[data-state="playing"] .is-play { display: none; }
.tms-chat-voice[data-state="playing"] .is-pause { display: block; }
.tms-chat-voice[data-state="loading"] .is-play { display: none; }
.tms-chat-voice[data-state="loading"] .is-load { display: block; border-color: color-mix(in srgb, var(--tms-on-accent) 35%, transparent); border-top-color: var(--tms-on-accent); }
.tms-chat-voice[data-state="error"] .tms-chat-voice-play { background: var(--tms-danger); color: var(--tms-on-danger); }

.tms-chat-voice-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tms-chat-voice-n { font-size: var(--tms-fs-cap); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tms-chat-voice-track {
  position: relative; display: block; height: 6px; border-radius: 999px; cursor: pointer;
  background: color-mix(in srgb, var(--tms-text) 14%, transparent);
}
.tms-chat-voice-track::before { content: ""; position: absolute; inset: -8px 0; }   /* a bigger target */
.tms-chat-voice-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: inherit; background: var(--tms-accent); transition: width .2s linear; }
/* The waveform: the track drawn as bars (an SVG mask from Chat.razor), the fill showing through them. */
.tms-chat-voice-track.is-wave {
  height: 24px; border-radius: 0; background: color-mix(in srgb, var(--tms-text) 22%, transparent);
  -webkit-mask: var(--wave) center / 100% 100% no-repeat;
  mask: var(--wave) center / 100% 100% no-repeat;
}
.tms-chat-voice-track.is-wave::before { display: none; }
.tms-chat-voice-track.is-wave .tms-chat-voice-fill { border-radius: 0; }

/* Playback speed: 1× → 1.5× → 2×; tms-chat.js keeps the choice in this browser. */
.tms-chat-voice-rate {
  flex: none; min-width: 34px; height: 22px; padding: 0 5px; box-sizing: border-box;
  border-radius: 999px; border: 1px solid var(--tms-border-strong); background: var(--tms-surface-2);
  font-size: 10.5px; font-weight: 750; color: var(--tms-text-2); font-variant-numeric: tabular-nums;
}
.tms-chat-voice-rate::after { content: attr(data-rate) "×"; }
.tms-chat-voice-rate:not([data-rate])::after { content: "1×"; }
.tms-chat-voice-rate[data-rate="1.5"], .tms-chat-voice-rate[data-rate="2"] {
  background: var(--tms-accent-tint); border-color: var(--tms-accent-line); color: var(--tms-accent-ink-2);
}
.tms-chat-voice-rate:hover { border-color: var(--tms-accent-line); }

.tms-chat-voice-t { flex: none; min-width: 34px; font-size: 11px; color: var(--tms-text-3); font-variant-numeric: tabular-nums; text-align: right; }
.tms-chat-voice-t::after { content: attr(data-total); }
.tms-chat-voice-t[data-now]::after { content: attr(data-now); }
.tms-chat-voice-dl { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--tms-text-3); }
.tms-chat-voice-dl:hover { background: var(--tms-surface-2); color: var(--tms-text); }

/* ---------------------------------------------------------------- side panel */
.tms-chat-side-h {
  display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 14px;
  border-bottom: 1px solid var(--tms-border); flex: none;
}
.tms-chat-side-h h3 { flex: 1; margin: 0; font-size: 13.5px; font-weight: 650; }
.tms-chat-side-b { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 10px 14px; }
.tms-chat-side-sec { margin: 12px 4px 6px; }
.tms-chat-side-sec:first-child { margin-top: 4px; }
.tms-chat-side-none { font-size: var(--tms-fs-cap); margin: 0 4px 8px; }

.tms-chat-person { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: var(--tms-r); }
.tms-chat-person-t { min-width: 0; display: flex; flex-direction: column; }
.tms-chat-person-t b { font-size: var(--tms-fs-data); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tms-chat-person-t b .tms-muted { font-weight: 450; margin-left: 4px; }
.tms-chat-person-t > span { font-size: var(--tms-fs-cap); color: var(--tms-text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tms-chat-tm { display: flex; gap: 8px; padding: 6px 2px; }
.tms-chat-tm .tms-av { width: 28px; height: 28px; font-size: 11px; flex: none; }
.tms-chat-tm-main { flex: 1; min-width: 0; padding: 6px 9px; border-radius: var(--tms-r-lg); border: 1px solid transparent; }
.tms-chat-tm.is-root .tms-chat-tm-main { background: var(--tms-surface-2); border-color: var(--tms-border); }

.tms-chat-side { position: relative; }

/* Files panel: Media · Files · Links (webmail chat's three tabs). */
.tms-chat-ftabs {
  position: sticky; top: 0; z-index: 1; display: flex; gap: 2px; margin: -8px -10px 10px; padding: 0 8px;
  background: var(--tms-surface); border-bottom: 1px solid var(--tms-border);
}
.tms-chat-ftabs button {
  padding: 9px 8px 8px; border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-size: var(--tms-fs-data); font-weight: 650; color: var(--tms-text-3);
}
.tms-chat-ftabs button small { font-weight: 500; margin-left: 2px; font-variant-numeric: tabular-nums; }
.tms-chat-ftabs button:hover { color: var(--tms-text); }
.tms-chat-ftabs button.is-on { color: var(--tms-text); border-bottom-color: var(--tms-accent); }

.tms-chat-mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.tms-chat-mtile {
  position: relative; aspect-ratio: 1; padding: 0; overflow: hidden; cursor: zoom-in;
  border: 1px solid var(--tms-border); border-radius: var(--tms-r); background: var(--tms-surface-2);
}
.tms-chat-mtile:hover { border-color: var(--tms-accent-line); }
.tms-chat-mtile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tms-chat-mtile img.is-broken { visibility: hidden; }
.tms-chat-mtile-vid {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; height: 100%;
  color: var(--tms-accent-ink-2); background: var(--tms-accent-tint); font-size: 22px;
}
.tms-chat-mtile-vid small { font-size: 10px; font-weight: 750; letter-spacing: .03em; }

.tms-chat-frow { display: flex; align-items: center; gap: 8px; padding: 6px 2px; border-bottom: 1px solid var(--tms-border); }
.tms-chat-frow:last-child { border-bottom: none; }
.tms-chat-frow .tms-chat-ext { min-width: 36px; height: 36px; border-radius: var(--tms-r); }
.tms-chat-frow-t {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; text-align: left;
  color: var(--tms-text); text-decoration: none; font-size: var(--tms-fs-data);
}
.tms-chat-frow-t b, .tms-chat-frow-t small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tms-chat-frow-t b { font-weight: 600; }
.tms-chat-frow-t small { font-size: 11.5px; color: var(--tms-text-3); }
.tms-chat-frow-t:hover { text-decoration: none; }
.tms-chat-frow-t:hover b { text-decoration: underline; color: var(--tms-accent); }
.tms-chat-frow .tms-icon-btn { width: 28px; height: 28px; flex: none; }

/* The thread's reply box is the full composer, folded as on a phone to fit the panel. */
.tms-chat-side .tms-cc { padding: 6px 8px 8px; }
.tms-cc.is-compact .tms-cc-hint, .tms-cc.is-compact .tms-cc-send-t, .tms-cc.is-compact .tms-cc-sep-main { display: none; }
.tms-cc.is-compact .tms-cc-tools { flex-wrap: wrap; row-gap: 4px; }
.tms-cc.is-compact .tms-cc-aa { display: inline-grid; }
.tms-cc.is-compact .tms-cc-fmt { display: none; }
.tms-cc.is-compact.is-fmt .tms-cc-fmt {
  display: flex; order: -1; flex: 1 0 100%; overflow-x: auto; scrollbar-width: none;
  padding-bottom: 4px; border-bottom: 1px solid var(--tms-border);
}
.tms-cc.is-compact .tms-cc-internal span { display: none; }
.tms-cc.is-compact .tms-cc-sendgrp, .tms-cc.is-compact .tms-cc-hint + .tms-cc-sendgrp { margin-left: auto; }
.tms-cc.is-compact .tms-cc-send { width: 36px; padding: 0; justify-content: center; }
.tms-cc.is-compact .tms-cc-more { width: 24px; }
.tms-cc.is-compact .tms-cc-pick, .tms-cc.is-compact .tms-cc-emoji { left: 8px; right: 8px; width: auto; }
.tms-cc.is-compact .tms-cc-sched-menu { right: 8px; width: min(260px, calc(100% - 16px)); }
.tms-cc.is-compact .tms-cc-tile { width: 60px; height: 60px; }

.tms-chat-side.is-dropping::after {
  content: "Drop files to attach them to the reply"; position: absolute; inset: 8px; z-index: 30;
  display: grid; place-items: center; pointer-events: none; text-align: center; padding: 12px;
  border: 2px dashed var(--tms-accent); border-radius: var(--tms-r-lg);
  background: color-mix(in srgb, var(--tms-accent-tint) 85%, transparent);
  color: var(--tms-accent-ink-2); font-weight: 650; font-size: 14px;
}

/* ---------------------------------------------------------------- file viewer
   Components/TmsChatViewer.razor, after webmail chat's: full window, dark, the file in the
   middle, a bar on top, previous / next at the sides. */
.tms-chat-viewer {
  position: fixed; inset: 0; z-index: var(--tms-z-modal);
  display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--tms-rail) 94%, transparent);
  outline: none; animation: tms-chat-viewer-in .15s var(--tms-ease) both;
}
@keyframes tms-chat-viewer-in { from { opacity: 0; } to { opacity: 1; } }

.tms-chat-viewer-bar {
  flex: none; display: flex; align-items: center; gap: 8px; margin: 10px 12px;
  padding: 6px 6px 6px 8px; border-radius: var(--tms-r-lg);
  background: var(--tms-surface); color: var(--tms-text); box-shadow: var(--tms-shadow-2);
  font-size: var(--tms-fs-data);
}
.tms-chat-viewer-bar .tms-chat-ext { min-width: 34px; height: 28px; }
.tms-chat-viewer-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tms-chat-viewer-t b { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tms-chat-viewer-t small { font-size: 11.5px; color: var(--tms-text-3); font-variant-numeric: tabular-nums; }
.tms-chat-viewer-bar .tms-btn { flex: none; }
.tms-chat-viewer-bar .tms-btn[aria-pressed="true"] { background: var(--tms-accent-tint); color: var(--tms-accent-ink-2); }

.tms-chat-viewer-stage {
  position: relative; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 0 64px 20px; box-sizing: border-box;
}
.tms-chat-viewer-stage img {
  max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in;
  border-radius: var(--tms-r); box-shadow: var(--tms-shadow-3);
}
.tms-chat-viewer-stage.is-zoom { overflow: auto; align-items: flex-start; justify-content: flex-start; }
.tms-chat-viewer-stage.is-zoom img { max-width: none; max-height: none; margin: auto; cursor: zoom-out; }
.tms-chat-viewer-stage video { max-width: 100%; max-height: 100%; border-radius: var(--tms-r); background: var(--tms-rail); box-shadow: var(--tms-shadow-3); }
/* PDFs and previews are paper: white whatever the theme, as the documents themselves expect. */
.tms-chat-viewer-stage iframe {
  width: min(1100px, 100%); height: 100%; border: 0; border-radius: var(--tms-r);
  background: white; box-shadow: var(--tms-shadow-3);
}
.tms-chat-viewer-stage iframe.is-loading { visibility: hidden; }

.tms-chat-viewer-audio {
  display: flex; align-items: center; gap: 12px; width: min(520px, 100%); box-sizing: border-box;
  padding: 16px 18px; border-radius: var(--tms-r-lg);
  background: var(--tms-surface); color: var(--tms-accent); box-shadow: var(--tms-shadow-3); font-size: 20px;
}
.tms-chat-viewer-audio audio { flex: 1; min-width: 0; }

.tms-chat-viewer-none {
  display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: min(420px, 100%);
  padding: 28px 36px; box-sizing: border-box; border-radius: var(--tms-r-lg); text-align: center;
  background: var(--tms-surface); color: var(--tms-text); box-shadow: var(--tms-shadow-3);
}
.tms-chat-viewer-none b { overflow-wrap: anywhere; }
.tms-chat-viewer-none > span:not(.tms-chat-ext) { font-size: var(--tms-fs-data); color: var(--tms-text-3); }
.tms-chat-viewer-none .tms-btn { margin-top: 4px; }

.tms-chat-viewer-wait { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }

.tms-chat-viewer-nav {
  position: absolute; top: 50%; translate: 0 -50%; z-index: 1;
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--tms-surface); color: var(--tms-text); box-shadow: var(--tms-shadow-2);
  font-size: 18px; opacity: .88;
}
.tms-chat-viewer-nav:hover { opacity: 1; }
.tms-chat-viewer-nav.is-prev { left: 12px; }
.tms-chat-viewer-nav.is-prev .tms-i { transform: rotate(180deg); }
.tms-chat-viewer-nav.is-next { right: 12px; }

/* ---------------------------------------------------------------- admin page */
.tms-ccr-list { display: flex; flex-direction: column; gap: 10px; }
.tms-ccr {
  position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px 14px 18px;
}
.tms-ccr::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  border-radius: var(--tms-r-lg) 0 0 var(--tms-r-lg); background: var(--tms-accent);
}
.tms-ccr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.tms-ccr-t { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.tms-ccr-t b { font-size: 14px; font-weight: 650; }
.tms-ccr-staff { display: flex; flex-wrap: wrap; gap: 5px; }
.tms-ccr-staff .tms-chip { height: 25px; font-size: var(--tms-fs-cap); cursor: default; }
.tms-ccr-none { display: inline-flex; align-items: center; gap: 6px; font-size: var(--tms-fs-cap); font-weight: 600; color: var(--tms-warn); }
.tms-ccr-when { font-size: var(--tms-fs-cap); color: var(--tms-text-3); }
.tms-ccr-act { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------------------------------------------------------------- tablet */
@media (max-width: 1080px) {
  /* The side panel becomes a drawer over the conversation instead of a third column. */
  .tms-chat.has-side { grid-template-columns: 280px minmax(0, 1fr); }
  .tms-chat.no-list.has-side { grid-template-columns: minmax(0, 1fr); }
  .tms-chat { position: relative; }
  .tms-chat-side {
    position: absolute; top: 14px; bottom: 14px; right: 18px; z-index: 20;
    width: min(320px, calc(100% - 36px));
    box-shadow: var(--tms-shadow-3);
  }
}

/* ---------------------------------------------------------------- phone */
@media (max-width: 720px) {
  .tms-chat,
  .tms-chat.has-side,
  .tms-chat.no-list.has-side {
    grid-template-columns: minmax(0, 1fr);
    gap: 0; padding: 0;
    height: calc(100dvh - var(--tms-topbar-h) - var(--tms-railbar-h) - env(safe-area-inset-bottom, 0px));
  }
  .tms-chat > .tms-card { border-radius: 0; border-left: none; border-right: none; box-shadow: none; }

  /* One column at a time: the list until a room is open, then the room. */
  .tms-chat.has-room .tms-chat-rooms { display: none; }
  .tms-chat:not(.has-room):not(.no-list) .tms-chat-room { display: none; }
  .tms-chat-back { display: grid; }

  .tms-chat-side { top: 0; bottom: 0; right: 0; width: 100%; border-radius: 0; }

  .tms-chat-list { padding: 8px 4px 12px; }
  .tms-cm { padding-left: 4px; padding-right: 4px; grid-template-columns: 30px minmax(0, 1fr); gap: 6px; }
  .tms-cm-av .tms-av { width: 28px; height: 28px; font-size: 11px; }
  .tms-cm-main { max-width: 88%; }
  .tms-cm-acts { right: 6px; }
  .tms-cm.is-mine .tms-cm-acts { left: 6px; }
  .tms-cm-emoji { grid-template-columns: repeat(4, 38px); }
  .tms-cm-emoji button { width: 38px; height: 38px; }

  .tms-cc-input { font-size: 16px; }   /* below 16px iOS zooms the page on focus */
  .tms-chat-head-lbl, .tms-chat-viewer-lbl { display: none; }
  .tms-chat-viewer-bar { margin: 8px; }
  .tms-chat-viewer-stage { padding: 0 8px 12px; }
  .tms-chat-viewer-nav { width: 38px; height: 38px; }
  .tms-chat-voice { width: 100%; }

  /* Composer: formatting folds behind "Aa"; opened, it is its own row that scrolls sideways. */
  .tms-cc { padding: 6px 8px 8px; }
  .tms-cc-hint, .tms-cc-send-t, .tms-cc-sep-main { display: none; }
  .tms-cc-tools { flex-wrap: wrap; row-gap: 4px; }
  .tms-cc-aa { display: inline-grid; }
  .tms-cc-fmt { display: none; }
  .tms-cc.is-fmt .tms-cc-fmt {
    display: flex; order: -1; flex: 1 0 100%; overflow-x: auto; scrollbar-width: none;
    padding-bottom: 4px; border-bottom: 1px solid var(--tms-border);
  }
  .tms-cc-tb { width: 34px; height: 32px; }
  .tms-cc-internal { width: auto; }
  .tms-cc-internal span { display: none; }
  .tms-cc-sendgrp, .tms-cc-hint + .tms-cc-sendgrp { margin-left: auto; }
  .tms-cc-send { width: 38px; height: 32px; padding: 0; justify-content: center; }
  .tms-cc-more { width: 26px; }
  .tms-cc-pick, .tms-cc-emoji { left: 8px; right: 8px; width: auto; }
  .tms-cc-sched-menu { right: 8px; }
  .tms-cc-sched-list li { flex-wrap: wrap; }
  .tms-cc-sched-body { flex-basis: 100%; order: 3; }
  .tms-cc-emoji-grid button { height: 38px; }
  .tms-chat-jump { bottom: 118px; }

  .tms-chat-imgs.is-one { grid-template-columns: minmax(0, 240px); }

  .tms-ccr { flex-wrap: wrap; }
  .tms-ccr-act { width: 100%; justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .tms-cm.is-flash { animation: none; }
  .tms-chat-viewer { animation: none; }
  .tms-cc-rec-dot { animation: none; }
}
