/* Pack 12: team chat and notifications. Tokens only. Rules at 1279, 1023 and 767 px. */

/* ---------- Two-pane chat layout (12-01, 12-02) ---------- */
.chat-fill { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h) - 64px); height: calc(100dvh - var(--topbar-h) - 64px); min-height: 560px; }
.chat-fill > .page-head { margin-bottom: var(--s3); }
.chat-page { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: var(--s4); }
.chat-list, .chat-thread { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-card); min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.chat-list .cl-head { padding: 12px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.chat-list .search-in { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; color: var(--muted); font-size: 13px; }
.chat-list .search-in.typed { color: var(--text); border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }
.chat-list .seg { width: 100%; } .chat-list .seg a { flex: 1; text-align: center; }
.cl-items { overflow-y: auto; flex: 1; min-height: 0; }
.cl-group { padding: 12px 14px 4px; }
.conv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 11px; align-items: center; padding: 11px 14px; border-bottom: 1px solid var(--line); position: relative; }
.conv:hover { background: var(--surface-2); }
.conv.on { background: var(--primary-tint); box-shadow: inset 3px 0 0 var(--primary); }
.conv .cb { min-width: 0; display: grid; gap: 2px; }
.conv .l1, .conv .l2 { display: flex; gap: 8px; align-items: center; min-width: 0; }
.conv .nm { font-weight: 600; font-size: 13.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.conv .tm { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.conv .pv { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.conv.unread .nm, .conv.unread .pv { color: var(--text); font-weight: 700; }
.conv .ub { min-width: 20px; height: 20px; border-radius: 10px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 6px; }
.conv .mut { color: var(--muted-2); }
.conv mark, .sres mark { background: var(--warn-tint); color: var(--text); border-radius: 3px; padding: 0 2px; }
.gicon { width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--primary-tint); color: var(--primary-ink); flex-shrink: 0; }
.gicon.lg { width: 52px; height: 52px; border-radius: 14px; }
.gicon.sm { width: 28px; height: 28px; border-radius: 8px; }

/* thread */
.th-head { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); min-height: 64px; }
.th-head .t { min-width: 0; flex: 1; }
.th-head .t strong { display: block; font-size: 15px; }
.th-head .t small { display: block; font-size: 12px; color: var(--muted); }
.th-head .back { display: none; }
.th-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 16px 12px; display: flex; flex-direction: column; }
.th-body > .msgs { margin-top: auto; display: grid; gap: 2px; }
.th-banner { margin: 10px 16px 0; }
.day-sep, .new-sep { display: flex; align-items: center; gap: 10px; margin: 14px 0 8px; font-size: 11.5px; font-weight: 700; color: var(--muted); }
.day-sep::before, .day-sep::after, .new-sep::before, .new-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.day-sep span { background: var(--surface-sunk); border-radius: var(--r-pill); padding: 2px 10px; }
.new-sep { color: var(--bad-ink); }
.new-sep::before, .new-sep::after { background: var(--bad-line); }
.load-earlier { align-self: center; margin: 4px 0 6px; }

/* messages (left aligned for everyone, grouped by sender) */
.msg { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; padding: 6px 8px; margin: 0 -8px; border-radius: 10px; position: relative; }
.msg:hover { background: var(--surface-2); }
.msg.cont { padding-top: 2px; }
.msg.cont > .avc { visibility: hidden; height: 0; }
.msg .avc { padding-top: 2px; }
.msg .avc a { display: inline-flex; border-radius: 50%; }
.msg .mb { min-width: 0; display: grid; gap: 6px; }
.msg .mh { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.msg .mh .nm { font-weight: 700; font-size: 13.5px; color: var(--text); }
.msg .mh .nm:hover { text-decoration: underline; color: var(--primary-ink); }
.msg .mh .tm, .msg .mh .ed { font-size: 11.5px; color: var(--muted); }
.msg .mt { font-size: 14px; color: var(--text); overflow-wrap: anywhere; max-width: 72ch; }
.msg .mt .at { color: var(--primary-ink); font-weight: 600; background: var(--primary-tint); border-radius: 4px; padding: 0 3px; }
.msg.deleted .mt { color: var(--muted); font-style: italic; }
.msg .acts { position: absolute; top: -12px; right: 8px; display: flex; gap: 2px; background: #fff; border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-card); padding: 2px; visibility: hidden; }
.msg:hover .acts, .msg:focus-within .acts { visibility: visible; }
.msg .acts .iconbtn { width: 30px; height: 30px; }
.quote { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); border-left: 3px solid var(--primary-tint-2); padding: 2px 0 2px 9px; min-width: 0; }
.quote strong { color: var(--text-2); white-space: nowrap; }
.quote span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.seen { display: flex; gap: 6px; align-items: center; font-size: 11.5px; color: var(--muted); }
.seen .avstack .av { width: 18px; height: 18px; font-size: 8px; border-width: 1.5px; margin-left: -5px; }
.seen .avstack .av:first-child { margin-left: 0; }
.notsent { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--bad-ink); font-weight: 600; }
.msg.pending .mt { color: var(--muted); }

/* attachments */
.att-file { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; max-width: 420px; }
.att-file:hover { border-color: var(--primary-tint-2); box-shadow: 0 0 0 3px var(--primary-tint); }
.att-file .ft { width: 38px; height: 44px; border-radius: 6px; background: var(--bad-tint); color: var(--bad-ink); display: grid; place-items: center; font-size: 10.5px; font-weight: 800; letter-spacing: .5px; flex-shrink: 0; }
.att-file .fb { min-width: 0; flex: 1; display: grid; gap: 1px; }
.att-file .fb strong { font-size: 13.5px; overflow-wrap: anywhere; }
.att-file .fb small { font-size: 12px; color: var(--muted); }
.att-photo { display: grid; gap: 4px; max-width: 300px; border-radius: 10px; }
.att-photo .img { display: block; width: 100%; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.att-photo .img svg { width: 100%; height: 100%; }
.att-photo small { font-size: 12px; color: var(--muted); }
.att-photo:hover .img { box-shadow: 0 0 0 3px var(--primary-tint); }

/* record link cards */
.rec-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-left: 4px solid var(--c, var(--primary)); border-radius: 10px; background: #fff; max-width: 460px; }
a.rec-card:hover { box-shadow: 0 0 0 3px var(--primary-tint); }
.rec-card .ri { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: color-mix(in srgb, var(--c, var(--primary)) 12%, #fff); color: var(--c, var(--primary)); }
.rec-card .rb { min-width: 0; display: grid; gap: 2px; }
.rec-card .rk { font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--muted-2); }
.rec-card .rt { font-size: 13.5px; font-weight: 700; color: var(--text); overflow-wrap: anywhere; }
.rec-card .rm { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.rec-card .go { color: var(--muted-2); }
.rec-card.locked { border-left-color: var(--grey-ink); background: var(--surface-2); }
.rec-card.locked .ri { background: var(--grey-tint); color: var(--grey-ink); }
.rec-list { display: grid; gap: 8px; }

/* typing and presence */
.typing { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); padding: 6px 0 0; min-height: 24px; }
.typing .dots { display: inline-flex; gap: 3px; }
.typing .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted-2); animation: chatdot 1.2s infinite ease-in-out; }
.typing .dots i:nth-child(2) { animation-delay: .15s; } .typing .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes chatdot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .typing .dots i { animation: none; } }
.presence { display: inline-flex; align-items: center; gap: 5px; }
.presence i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.presence.away i { background: var(--border-strong); }

/* composer */
.composer { border-top: 1px solid var(--line); padding: 10px 16px 12px; display: grid; gap: 8px; background: var(--surface); }
.comp-box { border: 1px solid var(--border-strong); border-radius: 12px; background: #fff; }
.comp-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }
.comp-box .ta { min-height: 44px; padding: 11px 14px 6px; font-size: 14px; color: var(--muted-2); }
.comp-box .ta.typed { color: var(--text); }
.comp-box .bar2 { display: flex; align-items: center; gap: 4px; padding: 4px 6px 6px; }
.comp-box .bar2 .grow { flex: 1; }
.comp-box .bar2 .hint { padding: 0 8px; }
.comp-note { display: flex; gap: 6px; align-items: center; font-size: 11.5px; color: var(--muted); }
.comp-off { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface-2); font-size: 13px; color: var(--muted); }
.pend { display: grid; gap: 6px; }
.pend-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.pend-item.bad { border-color: var(--bad-line); background: var(--bad-tint); }
.pend-item .pt { min-width: 0; display: grid; gap: 4px; }
.pend-item .pt strong { font-size: 13px; overflow-wrap: anywhere; }
.pend-item .pt small { font-size: 12px; color: var(--muted); }
.pend-item.bad .pt small { color: var(--bad-ink); font-weight: 600; }
.pend-item .bar { height: 6px; }
.pend-item .pa { display: flex; gap: 4px; }

/* photo preview (lightbox) */
.lightbox { display: grid; gap: 12px; }
.lightbox .img { border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-sunk); aspect-ratio: 16 / 10; }
.lightbox .img svg { width: 100%; height: 100%; }

/* picker of people (12-03, 12-04 add members) */
.picked { display: flex; flex-wrap: wrap; gap: 6px; }
.picked .pk { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 3px; border-radius: var(--r-pill); background: var(--primary-tint); color: var(--primary-ink); font-size: 12.5px; font-weight: 600; }
.picked .pk .iconbtn { width: 26px; height: 26px; color: var(--primary-ink); }
.people { display: grid; }
.person-row { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); min-height: var(--tap); }
.person-row:last-child { border-bottom: 0; }
.person-row .box { width: 20px; height: 20px; border: 1.5px solid var(--border-strong); border-radius: 5px; display: grid; place-items: center; background: #fff; }
.person-row .box.radio { border-radius: 50%; }
.person-row.on .box { background: var(--primary); border-color: var(--primary); color: #fff; }
.person-row.on .box.radio { background: #fff; box-shadow: inset 0 0 0 5px var(--primary); }
.person-row .t strong { display: block; font-size: 13.5px; }
.person-row .t small { display: block; font-size: 12px; color: var(--muted); }
.person-row.off { opacity: .6; }

/* member list (12-04) */
.member { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.member:last-child { border-bottom: 0; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.photo-grid a { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.photo-grid .img { aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.photo-grid .img svg { width: 100%; height: 100%; }
.opt-list { display: grid; gap: 10px; }

/* notifications (12-05) */
.notif { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: flex-start; padding: 13px 18px; border-bottom: 1px solid var(--line); position: relative; }
.notif:hover { background: var(--surface-2); }
.notif:last-child { border-bottom: 0; }
.notif .ni { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--c, var(--primary)) 12%, #fff); color: var(--c, var(--primary)); }
.notif .nt { min-width: 0; display: grid; gap: 3px; }
.notif .nt strong { font-size: 13.5px; font-weight: 500; color: var(--text-2); }
.notif.unread .nt strong { font-weight: 700; color: var(--text); }
.notif .nt small { font-size: 12px; color: var(--muted); }
.notif .nr { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); white-space: nowrap; }
.notif .ud { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); }
.notif-group { padding: 12px 18px 6px; background: var(--surface-2); border-bottom: 1px solid var(--line); }

/* settings rows (12-06) */
.set-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row .t strong { display: block; font-size: 13.5px; }
.set-row .t small { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.role-checks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 16px; }
.save-bar { display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }

/* page help button and dialog */
.help-steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.help-steps li { padding-left: 2px; }

@media (max-width: 1279px) {
  .chat-page { grid-template-columns: 300px minmax(0, 1fr); }
  .role-checks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1023px) {
  .chat-fill { height: calc(100vh - var(--topbar-h) - 60px); height: calc(100dvh - var(--topbar-h) - 60px); }
  .chat-page { grid-template-columns: 270px minmax(0, 1fr); gap: var(--s3); }
  .msg .acts { display: none; }
  .comp-box .bar2 .iconbtn { width: var(--tap); height: var(--tap); }
  .conv { min-height: 64px; }
  .notif .nr .btn { display: none; }
}
@media (max-width: 767px) {
  .chat-fill { height: auto; min-height: 0; display: block; }
  .chat-page { display: block; }
  .chat-page.list-mode .chat-thread { display: none; }
  .chat-page.thread-mode .chat-list { display: none; }
  .chat-page.thread-mode + .chat-aside, .chat-fill.thread-mode > .page-head { display: none; }
  .chat-list, .chat-thread { overflow: visible; border-radius: var(--r-card); }
  .chat-thread { border: 0; box-shadow: none; background: transparent; margin: 0 calc(-1 * var(--s4)); }
  .th-head { position: sticky; top: calc(52px + env(safe-area-inset-top)); z-index: 5; background: var(--surface); padding: 8px 12px; border: 0; border-bottom: 1px solid var(--border); }
  .th-head .back { display: inline-flex; }
  .th-head .hide-phone { display: none; }
  .th-body { overflow: visible; padding: 4px 16px 8px; background: var(--surface); }
  .th-banner { margin: 10px 16px 0; }
  .msg { grid-template-columns: 30px minmax(0, 1fr); gap: 9px; }
  .msg .avc .av { width: 30px; height: 30px; }
  .att-file, .rec-card, .att-photo { max-width: 100%; }
  .composer { position: sticky; bottom: calc(var(--bottombar-h) + env(safe-area-inset-bottom)); z-index: 6; padding: 8px 12px 10px; box-shadow: 0 -6px 16px rgba(17, 34, 68, .06); }
  .comp-box .bar2 .hint { display: none; }
  .comp-off { position: sticky; bottom: calc(var(--bottombar-h) + env(safe-area-inset-bottom)); }
  .member { grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; padding: 10px 14px; }
  .member .mrole .muted { display: none; }
  .role-checks { grid-template-columns: minmax(0, 1fr); }
  .notif { padding: 12px 14px; grid-template-columns: auto minmax(0, 1fr); }
  .notif .nr { grid-column: 2; }
  .person-row { grid-template-columns: auto auto minmax(0, 1fr); }
  .person-row .pr-extra { grid-column: 3; }
  .set-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .save-bar { position: sticky; bottom: calc(var(--bottombar-h) + env(safe-area-inset-bottom)); background: var(--bg); padding: 10px 0; }
  .save-bar .btn { flex: 1; }
}

/* fixes: message column never grows past its pane; segmented controls are tappable */
.msg .mb { grid-template-columns: minmax(0, 1fr); }
.msg .mb > * { min-width: 0; }
.msg .mb > a { display: block; }
.msg .mb > a.nm { display: inline; }
@media (max-width: 1023px) {
  body[data-page^="12-"] .seg a { min-height: var(--tap); display: inline-flex; align-items: center; justify-content: center; }
}
@media (max-width: 1023px) {
  .msg .avc a { width: 44px; height: 44px; margin: -5px; align-items: center; justify-content: center; }
}
@media (max-width: 1023px) {
  .picked .pk { padding: 2px 2px 2px 4px; }
  .picked .pk .iconbtn { width: var(--tap); height: var(--tap); }
}
/* the thread opens at the newest messages (the product scrolls to the New line) */
.th-body { flex-direction: column-reverse; }
.th-body > .msgs { margin: 0; }
@media (max-width: 767px) { .th-body > .msgs { margin-top: auto; } }
@media (max-width: 767px) { .th-body { flex-direction: column; } }
/* columns of cards keep their natural height */
body[data-page^="12-"] .grid { align-items: start; }
body[data-page^="12-"] .grid > .stack { align-content: start; }
.photo-grid { align-items: start; }
body[data-page^="12-"] .form-grid { align-items: start; }
@media (max-width: 1023px) { .comp-box .bar2 .hint { display: none; } }
.rec-search { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border: 1px solid var(--primary); border-radius: var(--r); box-shadow: 0 0 0 3px var(--primary-tint); font-size: 14px; }
.dialog .rec-card { max-width: none; }
.dialog .seg { flex-wrap: wrap; }

/* the chat list search keeps its placeholder on one line in the narrow list column */
.chat-list .cl-head { grid-template-columns: minmax(0, 1fr); }
.chat-list .cl-head .search-in { min-width: 0; }
.chat-list .cl-head .search-in span { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* search boxes inside pack 12 dialogs (Add people, Link a record) */
.dialog-b > .search-in { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; margin-bottom: 8px; border: 1px solid var(--border-strong); border-radius: var(--r); background: #fff; color: var(--muted); font-size: 13.5px; }
.dialog-b > .search-in span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
