/* d5 project Messages tab + header Text sheet (design
 * artisan-project-messages-20261107, style.css). The project desk's compact
 * chat restyled: page scroll, a composer docked above the phone tab bar,
 * bubbles by direction, cards for calls/email/notes, and the header Text
 * sheet. Every selector starts at .pm.pm (doubled) so the workspace's element
 * rules (.artisan-workspace :is(button, input[type=submit]) at 0,2,1) never
 * override it. The app's own font (Sora). Motion only when allowed. */
.pm {
  --pm-ink: #1c1917; --pm-muted: #57534e; --pm-canvas: #f5f5f4; --pm-line: #e7e5e4;
  --pm-clay: #a9562b; --pm-clay-deep: #8a4420; --pm-moss: #3f5a3b; --pm-call: #174d38; --pm-danger: #9f1d1d;
  font-family: inherit;
}

/* ---------- the tab: page scroll, no fixed box ---------- */
.pm.pm.chat-compact { height: auto; border: 0; border-radius: 0; overflow: visible; background: transparent; }
.pm.pm .m-scroll { flex: none; overflow: visible; padding: 0; overscroll-behavior: auto; }
.pm.pm .m-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 4px 0 8px; border: 0; background: transparent; grid-template-columns: none; grid-template-areas: none; }
.pm.pm .m-filters { display: flex; gap: 6px; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.pm.pm .m-filters::-webkit-scrollbar { display: none; }
.pm.pm .m-f { flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; font-size: 15px; font-weight: 600; color: #44403c; background: #fff; box-shadow: inset 0 0 0 1px #a8a29e; white-space: nowrap; text-decoration: none; }
.pm.pm .m-f[aria-current="true"] { background: var(--pm-ink); color: #fff; box-shadow: none; }
.pm.pm .m-searchbox { flex: none; }
.pm.pm .m-searchbox[open] { flex-basis: 100%; order: 3; }
.pm.pm .m-search { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: var(--pm-ink); background: #fff; box-shadow: inset 0 0 0 1px #a8a29e; cursor: pointer; list-style: none; }
.pm.pm .m-search::-webkit-details-marker { display: none; }
.pm.pm .m-searchform { display: flex; gap: 8px; margin-top: 8px; }
.pm.pm .m-q { flex: 1; min-width: 0; min-height: 44px; padding: 0 16px; border: 1px solid #a8a29e; border-radius: 22px; font-size: 16px; }
.pm.pm .m-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.pm.pm .m-full { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; font-weight: 700; color: var(--pm-ink); text-decoration: underline; text-underline-offset: 3px; }

.pm.pm .m-er { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 2px 0 4px; }
.pm.pm .m-earlier { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 999px; font-size: 14px; font-weight: 600; color: #44403c; background: var(--pm-canvas); text-decoration: none; }
.pm.pm .m-gap { margin: 4px 0; font-size: 13px; color: var(--pm-muted); text-align: center; }
.pm.pm .m-list { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 6px 0 14px; list-style: none; }
.pm.pm .m-item { display: flex; max-width: none; width: auto; padding: 0; margin: 0; }
.pm.pm .m-in { justify-content: flex-start; }
.pm.pm .m-out { justify-content: flex-end; margin-left: 0; }
.pm.pm .m-wide { justify-content: center; }
.pm.pm .m-day { display: flex; justify-content: center; margin-top: 8px; }
.pm.pm .m-day span { display: inline-flex; align-items: center; padding: 3px 12px; border-radius: 999px; background: var(--pm-canvas); font-size: 13px; font-weight: 600; color: var(--pm-muted); }
.pm.pm .m-newline { display: flex; align-items: center; gap: 10px; margin: 4px 0 -2px; color: var(--pm-clay-deep); font-size: 13px; font-weight: 700; }
.pm.pm .m-newline::before, .pm.pm .m-newline::after { content: ""; flex: 1; height: 1.5px; background: #e9b896; }
.pm.pm .m-empty { padding: 16px 0; font-size: 14px; color: var(--pm-muted); text-align: center; }

/* bubbles */
.pm.pm .m-msg { display: flex; flex-direction: column; max-width: 82%; min-width: 0; }
.pm.pm .m-out .m-msg { align-items: flex-end; }
.pm.pm .m-from { display: inline-flex; align-items: center; gap: 4px; margin: 0 6px 3px; font-size: 13px; font-weight: 700; color: #44403c; }
.pm.pm [data-artie] .m-from { color: var(--pm-moss); }
.pm.pm .m-bub { padding: 9px 14px 10px; border-radius: 18px 18px 18px 6px; background: #efedea; color: var(--pm-ink); font-size: 15px; line-height: 1.4; }
.pm.pm .m-bub-out { border-radius: 18px 18px 6px 18px; background: #292524; color: #fff; }
.pm.pm .m-bub-artie { border-radius: 18px 18px 6px 18px; background: #e4ece1; color: #1d2b1a; box-shadow: inset 0 0 0 1px #b9cbb3; }
.pm.pm .m-bub-fail { background: #fff; color: var(--pm-ink); box-shadow: inset 0 0 0 2px var(--pm-danger); }
.pm.pm .m-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.pm.pm .m-meta { display: flex; align-items: center; gap: 4px; margin: 3px 6px 0; font-size: 12px; color: var(--pm-muted); font-variant-numeric: tabular-nums; }
.pm.pm .m-ok { color: #2f4a2c; font-weight: 600; }
.pm.pm .m-bad { color: var(--pm-danger); font-weight: 700; }
.pm.pm .m-fail { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-top: 8px; padding-top: 8px; border-top: 1px solid #f1c9c9; }
.pm.pm .m-fail p { flex: 1; margin: 0; color: #7f1d1d; }
.pm.pm .m-resend { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--pm-danger); color: #fff; font-size: 14px; font-weight: 700; cursor: pointer; }
.pm.pm .m-thumbs { display: grid; grid-template-columns: repeat(3, 76px); gap: 4px; margin-top: 8px; }
.pm.pm .m-thumb { display: block; min-height: 44px; border-radius: 8px; overflow: hidden; background: #d6d3d1; }
.pm.pm .m-thumb img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; }
.pm.pm .m-saved { display: flex; align-items: center; gap: 4px; margin: 4px 0 0; font-size: 13px; font-weight: 600; color: #2f4a2c; }
.pm.pm .m-bub-out .m-saved { color: #d9f99d; }
.pm.pm .m-nlink { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-size: 14px; font-weight: 700; color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* cards: calls, email, notes, inquiries */
.pm.pm .m-card { width: 100%; max-width: 460px; min-width: 0; border-radius: 12px; background: #fff; box-shadow: inset 0 0 0 1px #d6d3d1; padding: 10px 12px; }
.pm.pm .m-crow, .pm.pm .m-esum { display: flex; align-items: center; gap: 10px; }
.pm.pm .m-esum { min-height: 44px; cursor: pointer; list-style: none; }
.pm.pm .m-esum::-webkit-details-marker { display: none; }
.pm.pm .m-cic { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--pm-canvas); color: var(--pm-ink); }
.pm.pm .m-cic-miss { background: #fbe9e9; color: var(--pm-danger); }
.pm.pm .m-ctext { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.pm.pm .m-ctitle { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.02em; color: var(--pm-ink); }
.pm.pm .m-csub { margin: 0; font-size: 13px; color: var(--pm-muted); }
.pm.pm .m-esubj { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm.pm .m-ctime { flex: none; font-size: 12px; color: var(--pm-muted); font-variant-numeric: tabular-nums; }
.pm.pm .m-cbtns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding-left: 46px; }
.pm.pm .m-tr { display: contents; }
.pm.pm .m-cbtn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 999px; font-size: 14px; font-weight: 700; color: var(--pm-ink); background: var(--pm-canvas); cursor: pointer; list-style: none; }
.pm.pm .m-cbtn::-webkit-details-marker { display: none; }
.pm.pm .m-tr[open] > .m-cbtn { background: var(--pm-ink); color: #fff; }
.pm.pm .m-tr-body { flex-basis: 100%; display: grid; gap: 6px; margin-top: 4px; padding: 10px 12px; border-radius: 10px; background: var(--pm-canvas); font-size: 14px; }
.pm.pm .m-ebody { margin: 8px 0 2px 46px; font-size: 14px; color: #292524; }
.pm.pm .m-notecard, .pm.pm .m-form { background: #fffbeb; box-shadow: inset 0 0 0 1.5px #d6a96a; }
.pm.pm .m-nhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0; font-size: 13px; font-weight: 700; color: #78350f; }
.pm.pm .m-nbody { margin: 4px 0 0; font-size: 15px; color: var(--pm-ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.pm.pm .m-nfoot { margin: 4px 0 0; font-size: 12px; font-weight: 600; color: #78350f; }

/* ---------- the composer (one partial: tab and sheet) ---------- */
/* Above the phone tab bar, whose height is calc(4rem + safe area)
   (dashboard/nav/_mobile); rem, so a larger default font keeps them apart. */
.pm.pm .c-dock { position: sticky; bottom: calc(4rem + env(safe-area-inset-bottom)); z-index: 15; margin: 0 -16px; padding: 0; border-top: 1px solid var(--pm-line); background: #fff; box-shadow: 0 -6px 16px rgba(28, 25, 23, .06); }
.pm.pm .c-dock .chat-float { position: absolute; left: 0; right: 0; bottom: 100%; height: auto; padding-bottom: 8px; pointer-events: none; }
.pm.pm .c-dock .chat-float > button { transform: none; pointer-events: auto; min-height: 44px; }
.pm .composer { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 12px; }
.pm.pm .c-form { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.pm.pm .c-form.c-note { margin: -10px -12px -12px; padding: 10px 12px 12px; background: #fffbeb; }
.pm.pm .c-sug { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "k use" "t use"; align-items: center; column-gap: 10px; padding: 8px 8px 8px 12px; border-radius: 12px; background: #eef3ec; box-shadow: inset 0 0 0 1px #c9d8c4; }
.pm.pm .c-sug[hidden] { display: none; }
.pm.pm .c-sug-k { grid-area: k; display: inline-flex; align-items: center; gap: 4px; margin: 0; font-size: 12px; font-weight: 700; color: #2f4a2c; }
.pm.pm .c-sug-t { grid-area: t; margin: 0; font-size: 14px; color: var(--pm-ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pm.pm .c-use { grid-area: use; min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px; background: #fff; color: #1d2b1a; font-size: 14px; font-weight: 700; box-shadow: inset 0 0 0 1.5px #3f5a3b; cursor: pointer; }
.pm.pm .c-bar { display: flex; align-items: center; gap: 8px; margin-right: -12px; }
.pm.pm .c-chips { display: flex; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; padding-right: 12px; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent); }
.pm.pm .c-chips::-webkit-scrollbar { display: none; }
.pm.pm .c-chips[hidden] { display: none; }
.pm.pm .c-chip { flex: none; min-height: 44px; padding: 0 14px; border: 0; border-radius: 999px; background: #fff; font-size: 14px; font-weight: 600; color: #292524; box-shadow: inset 0 0 0 1px #a8a29e; white-space: nowrap; cursor: pointer; }
.pm.pm .c-mode { display: inline-flex; flex: none; border-radius: 999px; background: #e7e5e4; }
.pm.pm .c-seg { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 999px; font-size: 14px; font-weight: 700; color: #44403c; text-decoration: none; }
.pm.pm .c-seg[aria-current="true"] { background: var(--pm-ink); color: #fff; }
.pm.pm .c-note .c-seg[aria-current="true"] { background: #78350f; }
.pm.pm .c-row { display: flex; align-items: flex-end; gap: 8px; }
.pm.pm .c-row[hidden] { display: none; }
.pm.pm .c-attach { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%; color: var(--pm-ink); box-shadow: inset 0 0 0 1px #a8a29e; cursor: pointer; }
.pm.pm .c-attach[hidden] { display: none; }
.pm.pm .c-attach:focus-within { outline: 3px solid #b45309; outline-offset: 2px; }
.pm.pm .c-input { flex: 1; min-width: 0; min-height: 44px; max-height: 160px; padding: 10px 16px; border: 1px solid #a8a29e; border-radius: 22px; background: #fff; font-size: 16px; line-height: 1.4; resize: none; }
.pm.pm .c-note .c-input { border-style: dashed; border-color: #b45309; background: #fffdf5; }
.pm.pm .c-send { display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none; min-width: 44px; min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--pm-call); color: #fff; font-size: 15px; font-weight: 700; cursor: pointer; opacity: 1; }
.pm.pm .c-note .c-send { background: #78350f; }
.pm.pm .c-send:disabled { background: #d6d3d1; color: #57534e; cursor: not-allowed; }
.pm.pm .c-count { align-self: flex-end; margin: -4px 0 0; font-size: 12px; color: var(--pm-muted); font-variant-numeric: tabular-nums; }
.pm.pm .c-count:empty, .pm.pm .c-files[hidden] { display: none; }
.pm.pm .c-files { margin: 0; font-size: 13px; color: var(--pm-muted); }
.pm.pm .c-nfoot { margin: -2px 0 0; font-size: 13px; font-weight: 600; color: #78350f; }
.pm.pm .c-nfoot[hidden] { display: none; }
.pm.pm .c-block { display: grid; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--pm-canvas); }
.pm.pm .c-block[hidden] { display: none; }
.pm.pm .c-block-why { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 15px; color: var(--pm-ink); }
.pm.pm .c-alts { display: flex; flex-wrap: wrap; gap: 8px; }
.pm.pm .c-alt { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 999px; font-size: 14px; font-weight: 700; color: var(--pm-ink); background: #fff; box-shadow: inset 0 0 0 1px #a8a29e; text-decoration: none; }
.pm.pm .c-feedback { margin: 0; padding: 0 12px 8px; font-size: 13px; color: var(--pm-muted); }
.pm.pm .c-feedback:empty { display: none; }
.pm.pm .c-closed { margin: 0; padding: 12px; font-size: 14px; font-weight: 600; color: #7c2d12; }
.pm.pm :focus-visible { outline: 3px solid #b45309; outline-offset: 2px; }

/* ---------- the header: needs-reply dot, Text reason ---------- */
.nr-dot { display: inline-block; flex: none; width: 9px; height: 9px; margin-left: 6px; border-radius: 50%; background: #a9562b; box-shadow: 0 0 0 2px #fff; vertical-align: middle; }
[role="tab"][aria-selected="true"] .nr-dot { background: #fdba74; box-shadow: none; }
.ph-wrap .ph-text-reason { margin-top: 6px; }
.ph-bar .ph-text-reason { display: none; }

/* ---------- the header Text sheet ---------- */
.pm-sheet.m-sheet { position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: none; max-height: 88dvh; padding: 6px 0 calc(8px + env(safe-area-inset-bottom)); border: 0; border-radius: 18px 18px 0 0; background: #fff; color: #1c1917; overflow: auto; box-shadow: 0 -10px 30px rgba(0, 0, 0, .25); }
.pm-sheet.m-sheet[open] { display: flex; flex-direction: column; }
.pm-sheet.m-sheet::backdrop { background: rgba(12, 10, 9, .45); }
.pm-sheet .ms-grab { flex: none; width: 40px; height: 5px; margin: 2px auto 6px; border-radius: 3px; background: #d6d3d1; }
.pm-sheet .ms-head { display: flex; align-items: center; gap: 10px; padding: 0 8px 0 16px; }
.pm-sheet .ms-name { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.03em; color: #1c1917; }
.pm-sheet .ms-sub { margin: 0; font-size: 13px; color: #57534e; font-variant-numeric: tabular-nums; }
.pm-sheet.pm-sheet .ms-x { display: grid; place-items: center; flex: none; margin-left: auto; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #57534e; cursor: pointer; }
.pm-sheet .ms-loading { margin: 0; padding: 16px; font-size: 14px; color: #57534e; }
.pm-sheet .ms-list { padding: 8px 12px 10px; border-bottom: 1px solid #e7e5e4; }
.pm-sheet .ms-items { padding: 0; }
.pm-sheet.pm-sheet .ms-open { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; margin: 0 12px; font-size: 15px; font-weight: 700; color: #1c1917; text-decoration: underline; text-underline-offset: 3px; }
@media (prefers-reduced-motion: no-preference) {
  .pm-sheet.m-sheet[open] { animation: pm-sheet-up .22s ease-out; }
  @keyframes pm-sheet-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
}

/* ---------- md (48rem) ---------- */
@media (min-width: 48rem) {
  .pm.pm.chat-compact { border: 1px solid var(--pm-line); border-radius: 12px; background: #fff; }
  .pm.pm .m-tools { padding: 12px 16px 6px; }
  .pm.pm .m-scroll { padding: 0 18px; }
  .pm.pm .m-msg { max-width: 68%; }
  .pm.pm .c-dock { margin: 0; border-radius: 0 0 12px 12px; }
  .pm .composer { padding: 12px 16px 14px; }
  .pm.pm .c-bar { margin-right: 0; flex-direction: column-reverse; align-items: flex-start; }
  .pm.pm .c-chips { flex-wrap: wrap; overflow: visible; padding: 0; -webkit-mask-image: none; mask-image: none; }
  .pm-sheet.m-sheet { inset: auto 16px 80px auto; width: 440px; max-height: calc(100dvh - 160px); padding-top: 14px; border-radius: 18px; box-shadow: 0 18px 50px rgba(0, 0, 0, .35); }
  .pm-sheet .ms-grab { display: none; }
  .pm-sheet .ms-head { padding: 0 12px 6px 20px; }
  .pm-sheet .ms-list { padding: 10px 16px; }
}

/* ---------- lg (64rem): the tab bar is gone (lg:hidden) ---------- */
@media (min-width: 64rem) {
  .pm.pm .c-dock { bottom: 0; }
  .pm.pm .m-msg { max-width: 560px; }
  .pm-sheet.m-sheet { inset: auto 24px 24px auto; width: 460px; }
}
