/* S1 Messages (s1-messages.js). The page is the approved mockup's t-messages, drawn by redesign-v3.css (.msg .ml .mlh .mr .mt .mth .hda .mb .dsep .bub .comp .inp .go .av .pl .sch .btn).
 * Only the glue the mockup does not draw is here: state hooks, loading / empty / error, the pin, the search, attachments, the new-messages line, and the phone's one pane at a time. */
.s1msg-host { display: block; }
.s1msg { padding: 0; max-width: none; }
.s1msg .av { position: relative; } /* a profile photo fills the circle (the kit lays it over the initials) */
.s1msg .sch:empty { display: none; } /* the school slot fills in once the directory is known */
.s1msg .msg { overflow: hidden; grid-template-rows: minmax(0, 1fr); }
.s1msg .msg.is-empty { grid-template-columns: minmax(0, 1fr); }
.s1msg .msg.is-empty .ml { display: none; }
.s1msg-pad { padding: calc(14px * var(--s1-scale, 1)) var(--gut); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* The no-patient-information reminders: a quiet strip above the page, and a line under the thread header. */
.s1msg-phi, .s1msg-phinote { display: flex; align-items: center; gap: calc(8px * var(--s1-scale, 1)); margin: 0; padding: calc(8px * var(--s1-scale, 1)) var(--gut); background: var(--well); border-bottom: 1px solid var(--line-soft); color: var(--ink-2); font-size: var(--s1-fs-1); flex: none; }
.s1msg-phi p { margin: 0; }
.s1msg-phi b { color: var(--ink); font-weight: 700; }
.s1msg-phi .ic, .s1msg-phinote .ic { color: var(--soon); flex: none; }
.s1msg-phinote { padding-block: calc(6px * var(--s1-scale, 1)); padding-left: calc(22px * var(--s1-scale, 1)); }
.s1msg.has-thread > .s1msg-phi { display: none; } /* the thread carries its own line */

/* ---- list ---- */
.s1msg-tools { display: flex; align-items: center; gap: calc(8px * var(--s1-scale, 1)); padding: 0 calc(18px * var(--s1-scale, 1)) calc(12px * var(--s1-scale, 1)) var(--gut); }
.s1msg-tools .srch { margin: 0; flex: 1 1 auto; }
.s1msg-tools .srch input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; color: var(--ink); }
.s1msg-unread[aria-pressed="true"] { background: var(--well); border-color: var(--mute); }
.s1msg-li { position: relative; }
.mr { text-decoration: none; color: inherit; }
.mr p i { font-style: normal; color: var(--ink-2); }
.s1msg-pin { position: absolute; right: 12px; bottom: 8px; display: inline-grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 7px; background: none; color: var(--mute); cursor: pointer; opacity: 0; }
.s1msg-li:hover .s1msg-pin, .s1msg-pin:focus-visible, .s1msg-pin.is-on { opacity: 1; }
.s1msg-pin.is-on { color: var(--ink); }
.s1msg-pin:hover { background: var(--well); }
.s1msg-pin[disabled] { display: none; }
@media (hover: none) { .s1msg-pin { opacity: .6; } .s1msg-pin.is-on { opacity: 1; } }
.s1msg-notes { list-style: none; margin: 0; padding: 0; }
.s1msg-note { display: flex; gap: calc(12px * var(--s1-scale, 1)); padding: calc(12px * var(--s1-scale, 1)) calc(18px * var(--s1-scale, 1)) calc(12px * var(--s1-scale, 1)) var(--gut); align-items: flex-start; border-top: 1px solid var(--line-soft); }
.s1msg-note-i { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--avatar); color: var(--ink-2); }
.s1msg-note > div { display: grid; gap: 2px; min-width: 0; }
.s1msg-note-t { font-size: var(--s1-fs-2); font-weight: 600; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
a.s1msg-note-t:hover { text-decoration: underline; text-underline-offset: 3px; }
.s1msg-note-m { font-size: var(--s1-fs-1); color: var(--mute); text-transform: capitalize; }
.s1msg-note.is-unread .s1msg-note-t { font-weight: 750; }

/* ---- thread ---- */
.mt { position: relative; min-width: 0; }
.mth .stack { flex: none; }
.s1msg-who { min-width: 0; }
.s1msg-who b, .s1msg-who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s1msg-who b { display: block; }
.s1msg-who b a.pl { font-weight: inherit; }
.s1msg-back { display: none; }
.s1msg-blank { margin: auto; display: grid; justify-items: center; gap: calc(8px * var(--s1-scale, 1)); text-align: center; padding: calc(24px * var(--s1-scale, 1)); max-width: 340px; color: var(--mute); }
.s1msg-blank .ic { width: 24px; height: 24px; color: var(--ink-2); }
.s1msg-blank h2 { margin: 4px 0 0; font: 800 var(--s1-fs-5)/1.2 var(--display); color: var(--ink); letter-spacing: -.01em; }
.s1msg-blank p { margin: 0 0 8px; font-size: var(--s1-fs-3); }
.s1msg-logwrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.s1msg-msgs:focus-visible { box-shadow: inset 0 0 0 2px var(--line); }
.s1msg-none { margin: auto 0; }
.bub { position: relative; overflow-wrap: anywhere; }
.bub.is-run { margin-top: -3px; }
.bub .s1msg-t { white-space: pre-wrap; }
.bub .s1msg-t a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.bub .s1msg-atts + .s1msg-t, .bub .s1msg-t + .s1msg-atts { margin-top: 6px; }
.s1msg-from { font-size: var(--s1-fs-1); margin-bottom: 2px; }
.bub.is-pending { opacity: .7; }
.bub.is-failed { opacity: 1; background: var(--panel); color: var(--ink); border-color: var(--late); }
.s1msg-pstate { align-self: flex-end; display: flex; align-items: center; gap: calc(6px * var(--s1-scale, 1)); font-size: var(--s1-fs-1); color: var(--mute); }
.s1msg-pstate.is-failed { color: var(--late); }
.s1msg-del { position: absolute; top: 4px; left: 100%; margin-left: 4px; display: inline-grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 7px; background: none; color: var(--mute); cursor: pointer; opacity: 0; }
.bub.me .s1msg-del { left: auto; right: 100%; margin: 0 4px 0 0; }
.bub:hover .s1msg-del, .s1msg-del:focus-visible { opacity: 1; }
.s1msg-del:hover { background: var(--well); color: var(--late); }
.s1msg-del[disabled] { display: none; }
@media (hover: none) { .s1msg-del { opacity: .55; } }
.s1msg-seen { align-self: flex-end; display: flex; align-items: center; gap: 4px; font-size: var(--s1-fs-1); color: var(--mute); }
.s1msg-seen.is-seen { color: var(--ink-2); }
.dsep.s1msg-newdiv { align-self: stretch; display: flex; align-items: center; gap: calc(10px * var(--s1-scale, 1)); color: var(--accent-text); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: var(--s1-fs-1); }
.s1msg-newdiv::before, .s1msg-newdiv::after { content: ""; flex: 1; height: 1px; background: color-mix(in srgb, var(--accent-text) 40%, var(--panel)); }
.s1msg-jump { position: absolute; right: 14px; bottom: 12px; box-shadow: 0 2px 8px rgb(17 19 24 / .12); }
.s1msg-jump[hidden] { display: none; }
.s1msg-jump.has-new { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }

/* ---- composer: the mockup's .inp holds a real text box ---- */
.comp { display: grid; gap: calc(6px * var(--s1-scale, 1)); }
/* Every row of the composer fills its column. The mockup centres them with margin-inline:auto (redesign-v3.css), which in a GRID makes a row
   fit its content instead: the text box shrank to its textarea's ~20 columns (about 260px) on Apex and Messages alike. width:100% keeps the centring and the max-width. */
.comp > * { width: 100%; box-sizing: border-box; min-width: 0; }
.comp .inp { align-items: flex-end; color: var(--ink); }
.comp .inp textarea { flex: 1; min-width: 0; align-self: center; resize: none; border: 0; background: none; font: inherit; color: var(--ink); line-height: 1.4; min-height: 22px; max-height: 160px; padding: 4px 0; overflow-y: auto; }
.comp .inp .go[disabled] { opacity: .45; cursor: default; }
.s1msg-chint { display: flex; justify-content: space-between; gap: calc(10px * var(--s1-scale, 1)); font-size: var(--s1-fs-1); color: var(--mute); min-height: 14px; }
.s1msg-count { font-variant-numeric: tabular-nums; }
.s1msg-ro { display: flex; align-items: center; gap: calc(6px * var(--s1-scale, 1)); margin: 0; font-size: var(--s1-fs-1); color: var(--mute); }

/* ---- compose modal ---- */
.s1msg-compose { display: grid; gap: calc(16px * var(--s1-scale, 1)); }
.s1msg-existing { display: flex; align-items: center; gap: calc(8px * var(--s1-scale, 1)); margin-top: 8px; padding: calc(8px * var(--s1-scale, 1)) calc(12px * var(--s1-scale, 1)); border-radius: 9px; background: var(--well); border: 1px solid var(--line-soft); font-size: var(--s1-fs-1); color: var(--ink-2); }
.s1msg-existing[hidden] { display: none; }
.s1msg-teams { margin-top: 8px; } .s1msg-teams[hidden] { display: none; }
.s1msg-existing span { flex: 1; min-width: 0; }
.s1msg-mhint { display: flex; align-items: center; gap: calc(6px * var(--s1-scale, 1)); }
.s1msg-mhint [data-s1msg-phihint] { flex: 1; display: flex; align-items: center; gap: calc(6px * var(--s1-scale, 1)); }

/* ---- attachments ---- */
.s1msg-attach[disabled] { opacity: .45; }
.mt.is-drop { box-shadow: inset 0 0 0 2px var(--ink); }
.mt.is-drop::after { content: "Drop files to attach"; position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--panel) 82%, transparent); font: 700 var(--s1-fs-4) var(--ui); color: var(--ink); pointer-events: none; }
.s1msg-tray { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: calc(8px * var(--s1-scale, 1)); }
.s1msg-tray[hidden] { display: none; }
.s1msg-pv { position: relative; display: flex; align-items: center; gap: calc(8px * var(--s1-scale, 1)); min-width: 0; max-width: 240px; padding: calc(6px * var(--s1-scale, 1)) 28px calc(6px * var(--s1-scale, 1)) calc(8px * var(--s1-scale, 1)); border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.s1msg-pv.is-image { padding: 0; width: 72px; height: 72px; overflow: hidden; }
.s1msg-pv.is-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.s1msg-pv.is-uploading { opacity: .65; }
.s1msg-pv.is-error { border-color: var(--late); }
.s1msg-pv-s { font-size: var(--s1-fs-1); color: var(--mute); }
.s1msg-pv.is-image .s1msg-pv-s { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 4px; background: color-mix(in srgb, var(--panel) 88%, transparent); text-align: center; }
.s1msg-pv-s.is-err { color: var(--late); }
.s1msg-pv-x { position: absolute; top: 3px; right: 3px; display: inline-grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 50%; background: var(--panel); color: var(--ink); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.s1msg-pv-x:hover { background: var(--well); }
.s1msg-file-i { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--avatar); color: var(--ink-2); }
.s1msg-file-t { display: grid; gap: 1px; min-width: 0; }
.s1msg-file-t b { font-size: var(--s1-fs-1); font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s1msg-file-t em { font-style: normal; font-size: var(--s1-fs-1); color: var(--mute); }
.s1msg-atts { display: flex; flex-wrap: wrap; gap: calc(6px * var(--s1-scale, 1)); max-width: 100%; }
.s1msg-thumb { all: unset; box-sizing: border-box; display: block; width: 200px; max-width: 100%; min-height: 80px; border-radius: 12px; overflow: hidden; background: var(--well); border: 1px solid var(--line-soft); cursor: zoom-in; }
.s1msg-thumb img { display: block; width: 100%; max-height: 220px; object-fit: cover; }
.s1msg-thumb img:not([src]) { height: 120px; }
.s1msg-thumb.is-broken { cursor: default; }
.s1msg-file { display: flex; align-items: center; gap: calc(10px * var(--s1-scale, 1)); width: 260px; max-width: 100%; padding: calc(8px * var(--s1-scale, 1)) calc(8px * var(--s1-scale, 1)) calc(8px * var(--s1-scale, 1)) calc(10px * var(--s1-scale, 1)); border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); }
.s1msg-pfiles { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: var(--s1-fs-1); }
.s1msg-pfiles li { display: flex; align-items: center; gap: calc(6px * var(--s1-scale, 1)); }
.s1msg-full { display: grid; place-items: center; }
.s1msg-full img { max-width: 100%; max-height: 70vh; border-radius: 8px; }

/* ---- phones: one pane at a time; the open thread is full screen and follows the visual viewport so the composer stays above the keyboard ---- */
@media (max-width: 760px) {
  .s1msg .msg { grid-template-columns: minmax(0, 1fr); min-height: 460px; }
  .msg .mt { display: none; }
  .msg.has-thread .ml { display: none; }
  .msg.has-thread .mt, .msg.is-empty .mt { display: flex; }
  .msg.has-thread { position: fixed; left: 0; right: 0; top: var(--s1msg-vt, 0px); height: var(--s1msg-vh, 100dvh); z-index: 300; min-height: 0; background: var(--panel); }
  .ml { border-right: 0; }
  .s1msg-back { display: inline-flex; flex: none; }
  .mth { padding: max(10px, env(safe-area-inset-top)) 12px 10px; }
  .mb { padding: 12px; }
  .bub { max-width: 88%; }
  .comp, .mt .comp { padding: 8px 12px max(10px, env(safe-area-inset-bottom)); }
  .mth { gap: 10px; }
  .mth .av.l { width: 36px; height: 36px; flex: none; }
  .s1msg-who { flex: 1 1 auto; min-width: 0; }
  .s1msg .s1msg-who small .sch { white-space: inherit; }
  .s1msg-who b, .s1msg-who small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mth .hda { flex: none; margin-left: 0; gap: 4px; flex-wrap: nowrap; }
  .mth .hda [data-act="s1msg-add"] { font-size: 0; gap: 0; padding: 0; width: 32px; justify-content: center; } /* icon only: the title still names it */
  .s1msg-thumb { width: 168px; } .s1msg-file { width: min(260px, 100%); }
  .s1msg-phi, .s1msg-phinote { padding-inline: 12px; align-items: flex-start; }
}
/* Bigger tap targets on touch. */
@media (pointer: coarse) {
  .mr { min-height: 64px; }
  .s1msg-pin, .s1msg-del { width: 44px; height: 44px; }
  .s1msg-pin { right: 2px; bottom: 2px; }
  .s1msg-back, .s1msg-attach, .s1msg-unread, .s1msg-jump, .mth .btn { min-width: 44px; min-height: 44px; }
  .comp .go { min-width: 44px; min-height: 44px; }
  .s1msg-pv-x { width: 32px; height: 32px; top: 2px; right: 2px; }
  .comp .inp textarea { font-size: var(--s1-fs-4); }
}

/* r18: icons inside a filled button follow the button's text colour (a dark pencil on a dark button was invisible) */
.s1msg-blank .btn .ic, .msg .btn.pri .ic { color: inherit; }
.s1msg .mth a.pl { text-decoration: none; }
.s1msg .mth a.pl:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---- owner pass B14: a normal chat layout. The list of chats stays on the left, the open thread fills the right and scrolls inside itself,
   the composer is fixed under it, and the bubbles are compact. The page itself never scrolls. ---- */
@media (min-width: 601px) {
  body.s1-shell main > .s1msg.s1-fill { flex: 1 1 0; min-height: 0; overflow: hidden; }
  body.s1-shell main > .s1msg.s1-fill > .s1-fill-body { flex: 1 1 0; min-height: 0; }
}
.s1msg .msg { min-height: 0; }
.s1msg .ml { min-height: 0; overflow-y: auto; }
.s1msg .mt { min-height: 0; overflow: hidden; }
.s1msg .mt .comp { flex: none; }
.s1msg .mb { min-height: 0; padding-block: calc(12px * var(--s1-scale, 1)) calc(10px * var(--s1-scale, 1)); gap: 3px; }
.s1msg .bub { max-width: min(72%, 560px); padding: 5px calc(11px * var(--s1-scale, 1)); border-radius: 12px; font-size: var(--s1-fs-2); line-height: 1.35; }
.s1msg .bub + .bub.me, .s1msg .bub.me + .bub:not(.me) { margin-top: 6px; }
.s1msg .mb .dsep { margin: 4px 0 6px; }
.s1msg-older { align-self: center; display: flex; align-items: center; gap: calc(6px * var(--s1-scale, 1)); font-size: var(--s1-fs-1); color: var(--mute); padding: 2px 0 calc(8px * var(--s1-scale, 1)); }
/* The empty state sits near the top under the title, with its one action, not in the middle of a blank page. */
.s1msg .msg.is-empty .s1msg-blank { margin: calc(40px * var(--s1-scale, 1)) auto auto; }
/* No conversations yet (round 3): the title, one line and the action start on the page's left edge, like every other page. */
.s1msg .msg.is-empty .s1msg-first { margin: 0; padding: calc(22px * var(--s1-scale, 1)) var(--gut, 28px); max-width: 640px; justify-items: start; text-align: left; gap: 6px; }
.s1msg-first h1 { margin: 0 0 4px; font: 800 var(--s1-fs-6)/1.12 var(--display); letter-spacing: -.022em; color: var(--ink); }
.s1msg-first p { margin: 0 0 10px; }
.s1msg-blank .btn .ic { width: 16px; height: 16px; }
/* Empty Messages reads like every other page head: title left, its one action right, a line under it. */
.s1msg .msg.is-empty .s1msg-first { max-width: none; justify-items: stretch; }
.s1msg-first-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.s1msg-first-h h1 { margin: 0; }
