/* Screen styles for #/mesaje — owned by the mesaje screen. Prefix: mesaje-.
   Phone: list → detail (push). Tablet: list + thread. Desktop ≥1280: list + thread + details. */

.mesaje { min-width: 0; }
/* a token longer than its box (URL, ?i18n=long padding) breaks instead of overflowing; ordinary words are unaffected */
.mesaje, .mesaje-new, .mesaje-details { overflow-wrap: anywhere; }
.mesaje-newbtn { flex-shrink: 0; }

/* ---------------- list pane ---------------- */
.mesaje-listpane { min-width: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.mesaje-listpane > * { flex-shrink: 0; }
.mesaje-listpane__head { display: grid; gap: var(--sp-3); min-width: 0; }
.mesaje-seg .ui-seg__btn { padding-inline: 8px; gap: 5px; min-width: 0; flex: 1 1 auto; }
/* labels shrink with an ellipsis (full label in title=) so longer English never pushes the bar sideways */
.mesaje-seg__l { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.mesaje-seg__n { flex-shrink: 0; }
.mesaje-seg__n {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill);
  background: var(--primary); color: var(--on-primary); font-size: var(--fs-label-s); font-weight: var(--fw-bold); line-height: 1;
}
.mesaje-search { min-width: 0; }
.mesaje-cats { margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); }
.mesaje-listpane__label { margin: var(--sp-2) 0 calc(-1 * var(--sp-1)); color: var(--muted); }
.mesaje-list { min-width: 0; }

.mesaje-row { align-items: flex-start; min-height: 76px; padding-block: 14px; }
.mesaje-row .ui-row__lead { margin-top: 2px; }
.mesaje-row .ui-row__lead--plain { width: 40px; }
.mesaje-row__top { display: flex; align-items: baseline; gap: var(--sp-2); min-width: 0; }
.mesaje-row__top .ui-row__title {
  flex: 1; min-width: 0; white-space: normal; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mesaje-row__top .ui-row__meta { flex-shrink: 0; white-space: nowrap; }
.mesaje-row .ui-row__sub { -webkit-line-clamp: 2; }
.mesaje-row__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; min-width: 0; }
.mesaje-row__meta .ui-aud { max-width: 100%; }
.mesaje-row__cat { font-size: var(--fs-caption); color: var(--muted); font-weight: var(--fw-medium); }
.mesaje-row.is-unread .ui-row__title::after { display: none; }
.mesaje-row.is-unread .ui-row__meta { color: var(--primary-ink); font-weight: var(--fw-semibold); }
.mesaje-row.is-unread::after {
  content: ""; position: absolute; left: 6px; top: 30px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary-ink);
}
.mesaje-row.is-active { background: var(--primary-soft); }
.mesaje-row.is-active::before { display: none; }
.mesaje-row.is-active + .mesaje-row::before { display: none; }
.mesaje-row.is-active .ui-row__lead { box-shadow: 0 0 0 1.5px var(--primary-ink); }
.mesaje-row[hidden] { display: none; }

.mesaje-lead { background: var(--surface-3); color: var(--ink-2); }
.mesaje-lead--ann { background: var(--aud-class-bg); color: var(--aud-class-fg); }
.mesaje-lead--consent { background: var(--warning-soft); color: var(--warning-ink); }
.mesaje-lead--thread, .mesaje-lead--poll { background: var(--primary-soft); color: var(--primary-ink); }
.mesaje-lead--channel { background: var(--sub-inot-bg); color: var(--sub-inot); }

.mesaje-tag {
  display: inline-flex; align-items: center; gap: 4px; min-height: 22px; padding: 1px 8px; border-radius: var(--r-xs);
  font-size: var(--fs-caption); font-weight: var(--fw-semibold); line-height: 1.2; background: var(--surface-3); color: var(--ink-2); white-space: nowrap;
}
.mesaje-tag .ui-i { width: 13px; height: 13px; }
.mesaje-tag--action { background: var(--warning-soft); color: var(--warning-ink); }
.mesaje-tag--ok { background: var(--success-soft); color: var(--success-ink); }
.mesaje-tag--ai { background: var(--ai-soft); color: var(--ai-ink); }
.mesaje-tag--wait { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-strong); }
.mesaje-tag--p2 { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line-strong); }

/* D2 · "Faza 2 · după ce intră școala": school items kept as examples, collapsed at the end of the list */
.mesaje-p2 { min-width: 0; margin-top: var(--sp-2); border-top: 1px dashed var(--line-strong); padding-top: var(--sp-3); }
.mesaje-p2[hidden] { display: none; }
.mesaje-p2__sum {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 2px; cursor: pointer; list-style: none;
  color: var(--ink-2); font-size: var(--fs-body-s); font-weight: var(--fw-semibold); border-radius: var(--r-sm);
}
.mesaje-p2__sum::-webkit-details-marker { display: none; }
.mesaje-p2__sum::marker { content: ""; }
.mesaje-p2__sum > .ui-i { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.mesaje-p2__sum > .ui-i:last-child { margin-left: auto; transition: transform var(--dur-2) var(--ease-standard); }
.mesaje-p2[open] > .mesaje-p2__sum > .ui-i:last-child { transform: rotate(180deg); }
.mesaje-p2__t { min-width: 0; }
.mesaje-p2__n {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--surface-3); color: var(--ink-2); font-size: var(--fs-label-s); font-weight: var(--fw-bold); line-height: 1;
}
.mesaje-p2__note { margin: 0 0 var(--sp-3); font-size: var(--fs-caption); line-height: 1.45; color: var(--muted); }
.mesaje-list--p2 .mesaje-row:not(.is-active) { background: var(--surface-2); }
.mesaje-list--p2 .mesaje-row:not(.is-active) .ui-row__title { color: var(--ink-2); }
.mesaje-p2note .ui-callout__body p { margin: 0; }

.mesaje-capcard .ui-callout__body p { margin: 0; }
.mesaje-empty { padding-block: var(--sp-5); }
.mesaje-noresults[hidden] { display: none; }

/* ---------------- thread ---------------- */
.mesaje-thread {
  min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1);
  display: flex; flex-direction: column;
}
.mesaje-thread__head { padding: var(--sp-5) var(--sp-5) var(--sp-4); border-bottom: 1px solid var(--line); display: grid; gap: 6px; min-width: 0; }
.mesaje-thread__eyebrow { font-size: var(--fs-eyebrow); letter-spacing: var(--ls-eyebrow); text-transform: uppercase; font-weight: var(--fw-semibold); color: var(--muted); }
.mesaje-thread__title { font-family: var(--font-display); font-weight: var(--fw-regular); font-size: var(--fs-display-s); line-height: var(--lh-display-s); letter-spacing: var(--ls-display); text-wrap: balance; overflow-wrap: anywhere; }
.mesaje-thread__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; min-width: 0; }
.mesaje-thread__spacer { flex: 1; }
.mesaje-thread__body { padding: var(--sp-5); display: grid; gap: var(--sp-4); min-width: 0; align-content: start; }
.mesaje-thread--page .mesaje-thread__head { padding-block: var(--sp-3); }

.mesaje-status { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-caption); font-weight: var(--fw-semibold); color: var(--muted); }
.mesaje-status .ui-i { width: 14px; height: 14px; }
.mesaje-status--open { color: var(--success-ink); }

/* author + announcement */
.mesaje-author { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.mesaje-author > div { min-width: 0; }
.mesaje-author__name { font-weight: var(--fw-semibold); line-height: 1.3; }
.mesaje-author__role { font-size: var(--fs-caption); color: var(--muted); }
.mesaje-ann { display: grid; gap: var(--sp-4); min-width: 0; }
.mesaje-ann__text { font-size: var(--fs-body); line-height: var(--lh-body); max-width: 62ch; display: grid; gap: var(--sp-2); overflow-wrap: anywhere; }
.mesaje-action .ui-callout__body p { margin: 0; }
.mesaje-h3 { font-size: var(--fs-title); font-weight: var(--fw-semibold); }

.mesaje-evt {
  display: flex; align-items: center; gap: var(--sp-3); padding: 10px 14px 10px 10px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line); color: inherit; min-width: 0;
}
a.mesaje-evt:hover { border-color: var(--line-strong); background: var(--surface-3); }
.mesaje-evt > .ui-i { color: var(--subtle); flex-shrink: 0; }
.mesaje-evt__date { display: grid; place-items: center; width: 46px; height: 48px; border-radius: var(--r-sm); background: var(--primary-soft); color: var(--on-primary-soft); line-height: 1; flex-shrink: 0; }
.mesaje-evt__date span { font-size: var(--fs-label-s); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: .06em; }
.mesaje-evt__date b { font-family: var(--font-display); font-size: 1.35rem; font-weight: var(--fw-medium); }
.mesaje-evt__icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: var(--r-sm); background: var(--surface-3); color: var(--ink-2); flex-shrink: 0; }
.mesaje-evt__body { display: grid; gap: 2px; min-width: 0; flex: 1; }
.mesaje-evt__title { font-weight: var(--fw-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mesaje-evt__meta { font-size: var(--fs-caption); color: var(--muted); }
.mesaje-evt--plain .mesaje-evt__title { white-space: normal; }

.mesaje-receipts { display: grid; gap: var(--sp-3); --_pad: var(--sp-4); }
.mesaje-receipts__top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.mesaje-receipts__top b { font-family: var(--font-display); font-size: 1.35rem; font-weight: var(--fw-medium); }
.mesaje-receipts__miss { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mesaje-receipts .ui-btn { justify-self: start; }
.mesaje-nowrap { white-space: nowrap; }
.mesaje-pill { display: inline-flex; align-items: center; min-height: 26px; padding: 2px 10px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--line); font-size: var(--fs-caption); font-weight: var(--fw-medium); }

.mesaje-qs { display: grid; gap: var(--sp-3); padding-top: var(--sp-4); border-top: 1px solid var(--line); }
.mesaje-qs__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.mesaje-qs__list { display: grid; gap: var(--sp-2); }
.mesaje-q { display: grid; gap: 2px; padding: 10px 14px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); color: inherit; }
.mesaje-q:hover { border-color: var(--line-strong); }
.mesaje-q__t { font-weight: var(--fw-semibold); }
.mesaje-q__s { font-size: var(--fs-caption); color: var(--muted); }

/* consent */
.mesaje-consent__text { margin: 0; padding: var(--sp-3) var(--sp-4); border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 var(--r-sm) var(--r-sm) 0; font-family: var(--font-display); font-size: var(--fs-title); line-height: 1.45; }
.mesaje-consent__due { display: flex; align-items: flex-start; gap: 6px; font-size: var(--fs-body-s); line-height: 1.45; color: var(--ink-2); }
.mesaje-consent__due .ui-i { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; margin-top: 2px; }

/* decision (pinned above replies) */
.mesaje-decision {
  display: flex; gap: var(--sp-3); padding: 14px 16px; border-radius: var(--r-md);
  background: var(--success-soft); border: 1px solid color-mix(in srgb, var(--success-ink) 25%, transparent);
}
.mesaje-decision__icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface); color: var(--success-ink); flex-shrink: 0; }
.mesaje-decision__icon .ui-i { width: 16px; height: 16px; }
.mesaje-decision__body { min-width: 0; display: grid; gap: 2px; }
.mesaje-decision__label { font-size: var(--fs-eyebrow); letter-spacing: var(--ls-eyebrow); text-transform: uppercase; font-weight: var(--fw-bold); color: var(--success-ink); }
.mesaje-decision__text { font-size: var(--fs-body); font-weight: var(--fw-semibold); line-height: 1.45; color: var(--ink); }
.mesaje-decision__by { font-size: var(--fs-caption); color: var(--muted); }

.mesaje-tools { display: flex; flex-wrap: wrap; gap: 4px var(--sp-2); margin-inline: -8px; }
.mesaje-ai-btn { color: var(--ai-ink); }
.mesaje-summary .ui-callout__body > p { margin: 0 0 6px; }
.mesaje-summary__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.mesaje-summary__head .ui-callout__title { margin: 0; }

/* poll */
.mesaje-poll { display: grid; gap: var(--sp-3); padding: var(--sp-4); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); min-width: 0; }
.mesaje-poll--solo { background: transparent; border: 0; padding: 0; }
.mesaje-poll__head { display: flex; gap: var(--sp-3); align-items: flex-start; }
.mesaje-poll__head > .ui-i { color: var(--primary-ink); margin-top: 3px; flex-shrink: 0; }
.mesaje-poll__q { font-weight: var(--fw-semibold); font-size: var(--fs-title); line-height: var(--lh-title); }
.mesaje-poll__note { font-size: var(--fs-body-s); color: var(--ink-2); }
.mesaje-poll__opts { display: grid; gap: var(--sp-2); }
.mesaje-poll__cap { display: flex; gap: 6px; align-items: flex-start; }
.mesaje-poll__cap .ui-i { width: 14px; height: 14px; margin-top: 2px; flex-shrink: 0; }
.mesaje-opt {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); min-height: 46px; padding: 8px 14px;
  border-radius: var(--r-sm); border: 1px solid var(--control-border); background: var(--surface); text-align: left; overflow: hidden; width: 100%;
}
.mesaje-opt:not(:disabled):hover { border-color: var(--primary-ink); }
.mesaje-opt:disabled { cursor: default; border-color: var(--line); }
.mesaje-opt__bar { position: absolute; inset: 0 auto 0 0; background: var(--primary-soft); transition: width var(--dur-3) var(--ease-standard); }
.mesaje-opt__label, .mesaje-opt__n { position: relative; display: inline-flex; align-items: center; gap: 6px; }
.mesaje-opt__label { font-weight: var(--fw-medium); min-width: 0; }
.mesaje-opt__n { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: var(--fw-semibold); }
.mesaje-opt.is-mine { border-color: var(--primary-ink); box-shadow: inset 0 0 0 1px var(--primary-ink); }
.mesaje-opt.is-mine .mesaje-opt__bar { background: var(--primary-soft-2); }
.mesaje-opt.is-mine .ui-i { color: var(--primary-ink); width: 16px; height: 16px; }

/* conversation */
.mesaje-convnote { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-caption); color: var(--muted); padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px dashed var(--line-strong); }
.mesaje-convnote .ui-i { width: 14px; height: 14px; margin-top: 1px; flex-shrink: 0; }
.mesaje-nomsg { color: var(--muted); font-size: var(--fs-body-s); }

.mesaje-msgs { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; min-width: 0; }
.mesaje-day { display: flex; justify-content: center; margin: var(--sp-3) 0 var(--sp-2); }
.mesaje-day span { font-size: var(--fs-caption); font-weight: var(--fw-semibold); color: var(--muted); background: var(--surface-2); border-radius: var(--r-pill); padding: 3px 10px; }
.mesaje-msg { display: flex; align-items: flex-end; gap: 8px; min-width: 0; margin-top: 8px; }
.mesaje-msg.is-cont { margin-top: 0; }
.mesaje-msg.is-own { justify-content: flex-end; }
.mesaje-msg__av { width: 30px; flex-shrink: 0; }
.mesaje-msg__bubble {
  position: relative; max-width: min(78%, 560px); min-width: 0; padding: 8px 12px 6px; border-radius: 18px 18px 18px 6px;
  background: var(--surface-2); border: 1px solid var(--line); display: grid; gap: 2px;
}
.mesaje-msg.is-cont .mesaje-msg__bubble { border-radius: 6px 18px 18px 6px; }
.mesaje-msg.is-own .mesaje-msg__bubble { background: var(--primary-soft); border-color: transparent; border-radius: 18px 18px 6px 18px; }
.mesaje-msg.is-own.is-cont .mesaje-msg__bubble { border-radius: 18px 6px 6px 18px; }
.mesaje-msg.is-staff:not(.is-own) .mesaje-msg__bubble { background: var(--surface); border-color: var(--line-strong); }
.mesaje-msg__who { font-size: var(--fs-caption); font-weight: var(--fw-semibold); color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 0 6px; }
.mesaje-msg__who span { font-weight: var(--fw-regular); color: var(--muted); }
.mesaje-msg__text { font-size: var(--fs-body); line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }
.mesaje-msg__time { justify-self: end; font-size: var(--fs-label-s); color: var(--muted); font-variant-numeric: tabular-nums; }
.mesaje-att { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 10px; margin-top: 4px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); font-size: var(--fs-body-s); font-weight: var(--fw-medium); justify-self: start; max-width: 100%; }
.mesaje-att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mesaje-att .ui-i { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }

/* composer (audience locked to the thread) */
.mesaje-composer {
  display: grid; gap: 8px; padding: var(--sp-3) var(--sp-4) var(--sp-4); border-top: 1px solid var(--line);
  background: var(--surface); border-radius: 0 0 var(--r-lg) var(--r-lg); min-width: 0;
}
.mesaje-composer__to { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: var(--fs-caption); color: var(--muted); min-width: 0; }
.mesaje-composer__to > .ui-i { width: 14px; height: 14px; }
.mesaje-composer__reach { color: var(--ink-2); font-weight: var(--fw-medium); }
.mesaje-composer__atts { display: flex; flex-wrap: wrap; gap: 6px; }
.mesaje-attchip { max-width: 100%; min-width: 0; }
.mesaje-attchip__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mesaje-composer__row { display: flex; align-items: flex-end; gap: 8px; min-width: 0; }
.mesaje-composer__input { flex: 1; min-width: 0; min-height: 44px; max-height: 200px; resize: none; padding-block: 10px; border-radius: 22px; line-height: 1.4; }
.mesaje-composer__attach, .mesaje-composer__send { flex-shrink: 0; }
/* attach menu: documents yes; photos only inside family-private items (D3, reason from App.rbac.canAttachPhoto) */
.mesaje-attmenu { display: grid; gap: 8px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); min-width: 0; }
.mesaje-attmenu__btns { display: flex; flex-wrap: wrap; gap: 8px; }
.mesaje-attmenu .ui-btn.is-off { color: var(--muted); border-style: dashed; background: transparent; cursor: not-allowed; }
.mesaje-attmenu__why { display: flex; align-items: flex-start; gap: 8px; margin: 0; font-size: var(--fs-caption); line-height: 1.45; color: var(--ink-2); }
.mesaje-attmenu__why .ui-i { width: 14px; height: 14px; margin-top: 2px; flex-shrink: 0; color: var(--muted); }
.mesaje-composer--off { display: flex; align-items: flex-start; gap: 8px; font-size: var(--fs-body-s); color: var(--muted); background: var(--surface-2); }
.mesaje-composer--off .ui-i { width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; }
.mesaje-composer--off p { min-width: 0; overflow-wrap: anywhere; }

/* "Tradu / Translate": AI translation of CONTENT, under the original, on request (SCREEN_CONTRACT §7.2) */
.mesaje-tr { display: grid; gap: 6px; justify-items: start; min-width: 0; max-width: 62ch; }
.mesaje-tr__btn {
  display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 2px 8px; margin-left: -8px; border-radius: var(--r-sm);
  font-size: var(--fs-caption); font-weight: var(--fw-semibold); color: var(--primary-ink); background: transparent; text-align: left;
}
.mesaje-tr__btn:hover { background: var(--primary-soft); }
.mesaje-tr__btn .ui-i { width: 14px; height: 14px; flex-shrink: 0; }
.mesaje-tr--done { padding: 10px 12px; border-radius: var(--r-sm); background: var(--ai-soft); border: 1px solid color-mix(in srgb, var(--ai-ink) 20%, transparent); justify-self: stretch; }
.mesaje-tr--done .mesaje-tr__btn { margin-left: -8px; }
.mesaje-tr__note { display: flex; align-items: flex-start; gap: 5px; margin: 0; font-size: var(--fs-caption); line-height: 1.4; color: var(--ai-ink); font-weight: var(--fw-medium); }
.mesaje-tr__note .ui-i { width: 13px; height: 13px; margin-top: 2px; flex-shrink: 0; }
.mesaje-tr__text { margin: 0; font-size: var(--fs-body); line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; color: var(--ink); }
.mesaje-tr__live { margin: 0; font-size: var(--fs-body-s); line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; color: var(--muted); }
.mesaje-tr__err { display: flex; align-items: flex-start; gap: 5px; margin: 0; font-size: var(--fs-caption); line-height: 1.4; color: var(--warning-ink); }
.mesaje-tr__err .ui-i { width: 13px; height: 13px; margin-top: 2px; flex-shrink: 0; }
/* inside a message bubble / the pinned decision: smaller, flush with the text */
.mesaje-tr--compact { gap: 4px; }
.mesaje-tr--compact .mesaje-tr__btn { min-height: 28px; padding-inline: 6px; margin-left: -6px; font-size: var(--fs-label-s); }
.mesaje-tr--compact.mesaje-tr--done { padding: 6px 8px; background: color-mix(in srgb, var(--ai-soft) 70%, var(--surface)); }
.mesaje-tr--compact .mesaje-tr__text { font-size: var(--fs-body-s); }
.mesaje-msg__bubble .mesaje-tr { margin-top: 2px; }

/* ---------------- details ---------------- */
.mesaje-details { display: grid; gap: var(--sp-5); min-width: 0; }
.mesaje-details__sec { display: grid; gap: var(--sp-3); min-width: 0; }
.mesaje-details__sec .ui-eyebrow { color: var(--muted); }
.mesaje-details__who { display: grid; gap: 8px; justify-items: start; }
.mesaje-details__reach { font-weight: var(--fw-semibold); }
.mesaje-details .ui-kv dd { overflow-wrap: anywhere; }

.mesaje-notif { display: grid; gap: var(--sp-2); }
.mesaje-notif__phone {
  display: grid; gap: 6px; padding: 10px; border-radius: var(--r-md);
  background: linear-gradient(160deg, var(--inverse-surface), color-mix(in srgb, var(--inverse-surface) 70%, var(--primary)));
}
.mesaje-notif__phone--open { background: var(--surface-3); }
.mesaje-notif__lbl { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-label-s); font-weight: var(--fw-semibold); letter-spacing: .04em; text-transform: uppercase; color: color-mix(in srgb, var(--surface) 80%, transparent); }
.mesaje-notif__phone--open .mesaje-notif__lbl { color: var(--muted); }
.mesaje-notif__lbl .ui-i { width: 12px; height: 12px; }
.mesaje-notif__card { display: grid; gap: 1px; padding: 8px 10px; border-radius: 12px; background: color-mix(in srgb, var(--surface) 92%, transparent); font-size: var(--fs-caption); line-height: 1.35; min-width: 0; }
.mesaje-notif__card b { font-size: var(--fs-body-s); overflow-wrap: anywhere; }
.mesaje-notif__card span:last-child { color: var(--ink-2); overflow-wrap: anywhere; }
.mesaje-notif__app { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: var(--fs-label-s); text-transform: uppercase; letter-spacing: .04em; font-weight: var(--fw-semibold); }
.mesaje-notif__app .ui-i { width: 12px; height: 12px; }

/* ---------------- new message sheet ---------------- */
.mesaje-new { display: grid; gap: var(--sp-4); }
.mesaje-new__to .ui-aud-option__text small { overflow-wrap: anywhere; }
.mesaje-new__confirm[hidden] { display: none; }
.mesaje-new__confirm .ui-callout__body p { margin: 0 0 4px; }
.mesaje-new__p2 { display: flex; gap: 8px; align-items: flex-start; margin: var(--sp-3) 0 0; font-size: var(--fs-caption); line-height: 1.45; color: var(--muted); }
.mesaje-new__p2 .ui-i { width: 14px; height: 14px; margin-top: 2px; flex-shrink: 0; }
.mesaje-new__p2 b { color: var(--ink-2); font-weight: var(--fw-semibold); }
.mesaje-new__lock { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-body-s); color: var(--ink-2); padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); }
.mesaje-new__lock .ui-i { width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; color: var(--muted); }
.mesaje-templates { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-2); }
.mesaje-tpl {
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; row-gap: 1px; align-items: start; text-align: left;
  padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--control-border); background: var(--surface); min-height: 44px;
}
.mesaje-tpl .ui-i { grid-row: span 2; color: var(--primary-ink); width: 20px; height: 20px; margin-top: 1px; }
.mesaje-tpl b { line-height: 1.35; }
.mesaje-tpl small { grid-column: 2; color: var(--muted); font-size: var(--fs-caption); line-height: 1.35; }
.mesaje-tpl[aria-pressed="true"] { border-color: var(--primary-ink); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary-ink); }
.mesaje-tpl.is-locked { background: var(--surface-2); border-style: dashed; }
.mesaje-tpl.is-locked .ui-i { color: var(--muted); }
.mesaje-newopts { display: grid; gap: var(--sp-2); }
.mesaje-newopts .ui-btn { justify-self: start; }

/* Grid columns never grow past their container: long (English / ?i18n=long) strings wrap instead of widening the page */
.mesaje .sh-pagehead, .mesaje-listpane__head, .mesaje-thread__head, .mesaje-thread__body, .mesaje-ann, .mesaje-receipts, .mesaje-qs, .mesaje-qs__list,
.mesaje-q, .mesaje-poll, .mesaje-poll__opts, .mesaje-msgs, .mesaje-msg__bubble, .mesaje-tr, .mesaje-details, .mesaje-details__sec, .mesaje-notif,
.mesaje-notif__phone, .mesaje-notif__card, .mesaje-new, .mesaje-evt__body, .mesaje-decision__body { grid-template-columns: minmax(0, 1fr); }
.mesaje-evt__meta, .mesaje-q__t, .mesaje-q__s, .mesaje-author__role, .mesaje-consent__due, .mesaje-convnote, .mesaje .ui-callout__title, .mesaje-new .ui-callout__title { overflow-wrap: anywhere; }
.mesaje-qs__head > .ui-btn, .mesaje-receipts .ui-btn, .mesaje-tools .ui-btn, .mesaje-thread__meta .ui-btn { max-width: 100%; white-space: normal; text-align: left; }

/* page head: keep "Nou" beside the large title even at 320px */
.mesaje .sh-pagehead__row { flex-wrap: nowrap; align-items: center; }
.mesaje .sh-pagehead__row .ui-pagehead__title { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }

.mesaje-denied { display: grid; gap: var(--sp-4); justify-items: start; max-width: 560px; }

/* ---------------- phone ---------------- */
.mesaje-back {
  display: inline-flex; align-items: center; gap: 2px; min-height: 44px; margin: var(--sp-2) 0 calc(-1 * var(--sp-3)) -8px; padding-right: 8px;
  color: var(--primary-ink); font-weight: var(--fw-semibold); font-size: var(--fs-button);
}
.mesaje-back .ui-i { width: 22px; height: 22px; }
.mesaje--detail .sh-pagehead { padding-top: var(--sp-2); }
.mesaje--detail .ui-pagehead__title { overflow-wrap: anywhere; }
@media (max-width: 767px) {
  .mesaje-list { margin-inline: calc(-1 * var(--gutter)); border-radius: 0; border-inline: 0; }
  .mesaje-row { padding-inline: var(--gutter); }
  .mesaje-row + .mesaje-row::before { left: calc(var(--gutter) + 52px); }
  .mesaje-row.is-unread::after { left: 5px; }
  .mesaje-thread { margin-inline: calc(-1 * var(--gutter)); border-radius: 0; border-inline: 0; box-shadow: none; }
  .mesaje-thread__head { padding-inline: var(--gutter); }
  .mesaje-thread__body { padding: var(--sp-4) var(--gutter); }
  .mesaje-composer { border-radius: 0; padding-inline: var(--gutter); }
  .mesaje-msg__bubble { max-width: 84%; }
  .mesaje-newbtn span { display: none; }
  .mesaje-newbtn { width: var(--touch); padding: 0; justify-content: center; border-radius: 50%; }
  .mesaje-newbtn .ui-i { margin: 0; }
}

/* ---------------- tablet + desktop panes ---------------- */
@media (min-width: 768px) {
  .mesaje-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--sp-5); align-items: start; }
  .mesaje-listpane {
    position: sticky; top: calc(var(--sh-top-h) + var(--sp-3));
    max-height: calc(100dvh - var(--sh-top-h) - var(--sp-6)); overflow-y: auto; overscroll-behavior: contain;
    padding: 2px 4px var(--sp-4); margin: -2px -4px 0; scrollbar-width: thin;
  }
  .mesaje-cats { margin-inline: 0; padding-inline: 0; }
  .mesaje-threadcol { min-width: 0; }
  .mesaje-composer { position: sticky; bottom: 0; z-index: 1; box-shadow: 0 -8px 16px -12px rgba(0, 0, 0, .12); }
  .mesaje-detailcol { display: none; }
  .mesaje-placeholder { padding-block: var(--sp-9); }
}
@media (min-width: 1100px) {
  .mesaje-grid { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }
}
@media (min-width: 1280px) {
  .mesaje-grid { grid-template-columns: 320px minmax(0, 1fr) 280px; gap: var(--sp-5); }
  .mesaje-detailcol {
    display: block; position: sticky; top: calc(var(--sh-top-h) + var(--sp-3));
    max-height: calc(100dvh - var(--sh-top-h) - var(--sp-6)); overflow-y: auto; scrollbar-width: thin;
    padding: var(--sp-5); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg);
  }
  .mesaje--panes .mesaje-detailsbtn { display: none; }
  .mesaje-thread__body { padding: var(--sp-6); }
  .mesaje-thread__head { padding: var(--sp-6) var(--sp-6) var(--sp-4); }
  .mesaje-composer { padding-inline: var(--sp-6); }
}
@media (min-width: 1600px) {
  .mesaje-grid { grid-template-columns: 360px minmax(0, 1fr) 320px; }
}
@media (max-width: 374px) {
  /* four segments must fit 288px: smaller label, counts become dots (count stays in aria-label) */
  .mesaje-seg .ui-seg__btn { padding-inline: 3px; font-size: var(--fs-caption); gap: 3px; }
  .mesaje-seg__n { min-width: 7px; width: 7px; height: 7px; padding: 0; font-size: 0; }
}
@media (min-width: 768px) and (max-width: 1279px) {
  .mesaje-seg .ui-seg__btn { padding-inline: 4px; font-size: var(--fs-caption); gap: 3px; }
  .mesaje-seg__n { min-width: 16px; height: 16px; padding: 0 4px; }
}

/* =====================================================================
   27.09 · "Familie" segment — family chat (ADDED; nothing above changed
   except the 5-segment bar rule). WhatsApp-like thread: bubbles, day
   separators, photos, composer pinned at the bottom (safe-area aware).
   ===================================================================== */
.mesaje-lead--chat { background: var(--aud-family-bg, var(--primary-soft)); color: var(--aud-family-fg, var(--primary-ink)); }
.mesaje-chatnote { display: flex; align-items: flex-start; gap: 8px; margin: 0; font-size: var(--fs-caption); line-height: 1.4; color: var(--muted); min-width: 0; }
.mesaje-chatnote > .ui-i { width: 14px; height: 14px; margin-top: 1px; flex-shrink: 0; }
.mesaje-chatnote > span { min-width: 0; }
.mesaje-chatrow { min-height: 72px; }
.mesaje-chatrow__sub { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mesaje-chatrow__sub .ui-row__sub { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.mesaje-chatrow__sub .ui-row__sub .ui-i { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.mesaje-chatrow__n {
  flex-shrink: 0; display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--primary); color: var(--on-primary); font-size: var(--fs-label-s); font-weight: var(--fw-bold); line-height: 1; font-variant-numeric: tabular-nums;
}
.mesaje-chatrow.is-unread::after { display: none; }

/* thread */
.mesaje-chat { display: flex; flex-direction: column; min-width: 0; }
.mesaje-chat__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line); min-width: 0; }
.mesaje-chat__head > .ui-row__lead { flex-shrink: 0; }
.mesaje-chat__id { flex: 1 1 160px; min-width: 0; display: grid; gap: 2px; }
.mesaje-chat__title { margin: 0; font-size: var(--fs-title-s, 1.125rem); font-weight: var(--fw-bold); line-height: 1.25; overflow-wrap: anywhere; }
.mesaje-chat__members {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; min-width: 0; max-width: 100%; padding: 2px 8px 2px 2px;
  border: 0; border-radius: var(--r-pill); background: transparent; color: var(--ink-2); font: inherit; font-size: var(--fs-caption); cursor: pointer; text-align: left;
}
.mesaje-chat__members:hover { background: var(--surface-2); }
.mesaje-chat__head > .ui-aud { order: 2; margin-left: auto; flex-shrink: 0; }
.mesaje-chat__members { order: 3; flex: 1 1 100%; }
.mesaje-chat__names { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mesaje-chat--page .mesaje-chat__head { padding-block: var(--sp-2); flex-wrap: nowrap; }
.mesaje-chat--page .mesaje-chat__members { order: 1; flex: 1 1 0; }
.mesaje-chat__body { padding: var(--sp-3) var(--sp-5) var(--sp-4); background: var(--surface-2); min-width: 0; flex: 1 1 auto; }
.mesaje-chatmsgs { gap: 3px; }
.mesaje-chat .mesaje-msg__bubble { background: var(--surface); box-shadow: 0 1px 0 rgba(0, 0, 0, .04); max-width: min(78%, 520px); }
.mesaje-chat .mesaje-msg.is-own .mesaje-msg__bubble { background: var(--primary-soft); }
.mesaje-chat .mesaje-day span { background: var(--surface); border: 1px solid var(--line); }
.mesaje-unreadline { display: flex; justify-content: center; margin: var(--sp-3) 0 var(--sp-1); }
.mesaje-unreadline span { font-size: var(--fs-caption); font-weight: var(--fw-semibold); color: var(--primary-ink); background: var(--primary-soft); border-radius: var(--r-pill); padding: 3px 12px; }

/* photos inside a bubble */
.mesaje-chatphs { display: grid; gap: 4px; margin: 2px -6px 4px; min-width: 0; }
.mesaje-chatphs--grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mesaje-chatph {
  display: block; position: relative; width: 100%; min-width: 180px; max-width: 280px; aspect-ratio: 4 / 3; padding: 0; border: 0; border-radius: 12px;
  overflow: hidden; background: var(--surface-3); cursor: zoom-in;
}
.mesaje-chatphs--grid .mesaje-chatph { min-width: 0; aspect-ratio: 1; }
.mesaje-chatph img, .mesaje-chatph .sh-art { width: 100%; height: 100%; object-fit: cover; display: block; }
.mesaje-chatph--off { display: flex; align-items: center; justify-content: center; gap: 6px; cursor: default; font-size: var(--fs-caption); color: var(--muted); }

/* composer: photos picked, waiting to be sent */
.mesaje-chatpick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.mesaje-chatpick__item { position: relative; width: 56px; height: 56px; border-radius: 10px; overflow: hidden; background: var(--surface-3); flex-shrink: 0; }
.mesaje-chatpick__item img, .mesaje-chatpick__item .sh-art { width: 100%; height: 100%; object-fit: cover; display: block; }
.mesaje-chatpick__x {
  position: absolute; top: 2px; right: 2px; width: 24px; height: 24px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .6); color: #fff; cursor: pointer;
}
.mesaje-chatpick__x::before { content: ""; position: absolute; inset: -10px; }   /* 44px touch target */
.mesaje-chatpick__note { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-caption); color: var(--muted); }
.mesaje-chat__composer { border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* sheets */
.mesaje-newchat__row { width: 100%; border: 0; background: transparent; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.mesaje-newchat__row > .ui-i { color: var(--muted); flex-shrink: 0; align-self: center; }
.mesaje-newchat { margin-bottom: var(--sp-3); }
.mesaje-chatsheet { display: grid; gap: var(--sp-3); min-width: 0; }
.mesaje-chatsheet__phone { justify-self: start; cursor: pointer; }
.mesaje-chatsheet__h { margin: var(--sp-1) 0 0; color: var(--muted); }
.mesaje-chatsheet__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.mesaje-chatsheet__ph {
  position: relative; aspect-ratio: 1; padding: 0; border: 0; border-radius: 10px; overflow: hidden; background: var(--surface-3); cursor: pointer;
  outline: 3px solid transparent; outline-offset: -3px;
}
.mesaje-chatsheet__ph img, .mesaje-chatsheet__ph .sh-art { width: 100%; height: 100%; object-fit: cover; display: block; }
.mesaje-chatsheet__ph[aria-pressed="true"] { outline-color: var(--primary); }
.mesaje-chatsheet__ph > .ui-i {
  position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; padding: 3px; border-radius: 50%; background: var(--primary); color: var(--on-primary);
}
.mesaje-chatview { border-radius: var(--r-md); overflow: hidden; background: var(--surface-3); }
.mesaje-chatview img, .mesaje-chatview .sh-art { width: 100%; height: auto; max-height: 70vh; aspect-ratio: 4 / 3; object-fit: contain; display: block; }
.mesaje-chatmembers .ui-row { padding-inline: 0; }

/* five segments (the family chat adds one): tighter on phones */
@media (max-width: 767px) {
  .mesaje-seg--5 .ui-seg__btn { padding-inline: 4px; gap: 3px; font-size: var(--fs-label-s, 12px); }
  .mesaje-seg--5 .mesaje-seg__n { min-width: 16px; height: 16px; padding: 0 4px; }
  .mesaje-chat--page { overflow: visible; margin-bottom: calc(-1 * var(--sp-8)); }   /* the page ends at the composer */
  .mesaje-chat--page .mesaje-chat__head { padding-inline: var(--gutter); }
  .mesaje-chat--page .mesaje-chat__body { padding-inline: calc(var(--gutter) - 4px); min-height: 50vh; }
  .mesaje-chat .mesaje-msg__bubble { max-width: 84%; }
  /* composer pinned above the tab bar (and the home indicator) */
  .mesaje-chat--page .mesaje-chat__composer {
    position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-bottom)); z-index: 2;
    box-shadow: 0 -8px 16px -12px rgba(0, 0, 0, .14);
  }
  /* while a chat is open: the floating persona pill (demo) moves above the composer; the shell footnote steps aside */
  .sh:has(.mesaje-chat--page) .sh-persona-pill--float { bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 76px); }
  .sh:has(.mesaje-chat--page) .sh-footnote { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom)); }
  .sh:has(.mesaje-chat--page) .sh-footnote > span { display: none; }
}
@media (max-width: 374px) {
  .mesaje-seg--5 .ui-seg__btn { padding-inline: 2px; font-size: 11px; }
}
/* tablet / desktop: the chat is a card with its own scroll; the composer stays at its bottom
   (mount() fits its height to the window; the CSS height is the fallback) */
@media (min-width: 768px) {
  .mesaje-seg--5 { flex-wrap: wrap; }
  .mesaje-seg--5 .ui-seg__btn { flex: 1 1 72px; }
  .mesaje-chat { height: calc(100dvh - var(--sh-top-h) - 160px); min-height: 420px; overflow: hidden; }
  .mesaje-chat__body { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
  .mesaje-chat__composer { position: static; box-shadow: none; flex-shrink: 0; }
  .mesaje-chat__head { flex-shrink: 0; }
}
@media (min-width: 1280px) {
  .mesaje-chat__body { padding-inline: var(--sp-6); }
  .mesaje--chatpanes .mesaje-chat__members { display: none; }   /* the details column lists the members */
}
