/* =========================================================================
   TRACK YOUR APPLICATION — views/mailbox/index.php and thread.php

   The thread half is BDS's customer mailbox stylesheet (bds_frontend
   web/css/mailbox.css), ported with its class names; its storefront theme
   variables are mapped to the ETV palette just below. The ETV-only parts —
   hero, sign-in cards, status card, timeline, dialog — follow at the end.
   ========================================================================= */

.mb-page,
.mb-wrap,
.mb-dialog {
    --surface: #fff;
    --border: var(--g100);
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 10px 30px -14px rgba(10, 45, 107, .22);
    --link: var(--sky);
    --muted: var(--g500);
    --primary: var(--navy);
    --primary-lt: #e8eef9;
    --heading: var(--navy);
    --danger: #c62828;
}

/* Visually hidden but read aloud (Bootstrap's utility; this site has no Bootstrap). */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.mb-page {
    max-width: var(--site-max-width);
    margin: 0 auto;
    padding-left: var(--site-gutter);
    padding-right: var(--site-gutter);
}
/* =========================================================================
   ONE-SCREEN LAYOUT
   The page is exactly the window under the sticky site header: the chat
   card fills its height, the details panel beside it matches, and only the
   thread and the details scroll. The footer follows below, as on every page.
   ========================================================================= */

.mb-page { padding: 14px 0 20px; }

/* 79px is the sticky site header (76px plus its 3px border, in layout.css);
   70px the breadcrumb row above the grid and the padding around it. The
   floor keeps a very short window usable — the page scrolls then. */
.mb-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 22px;
    height: calc(100vh - 79px - 70px);
    height: calc(100dvh - 79px - 70px);
    min-height: 540px;
}

.mb-card {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* ---- chat header: who the customer is talking to, and where it stands ---- */

.mb-chat-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
}

.mb-chat-avatar {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
}
.mb-chat-avatar img { width: 28px; height: 28px; }

.mb-chat-heading {
    flex: 1 1 auto;
    min-width: 0;
}

/* One line; the full subject is the tooltip. */
.mb-chat-title {
    margin: 0;
    overflow: hidden;
    font-size: 1.08rem;
    font-weight: 800;
    line-height: 1.3;
    letter-spacing: -.01em;
    color: var(--heading);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.mb-chat-meta {
    margin: 2px 0 0;
    overflow: hidden;
    font-size: .8rem;
    color: var(--muted);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.mb-chat-header .mb-status { flex: 0 0 auto; }

/* ---- presence: whether an ETV team member has the thread open ----
   Online is a green dot on the mark and a green word at the start of the
   line under the title; offline, a grey dot and a muted word. */
.mb-presence-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin: 0 5px 1px 0;
    border-radius: 50%;
    background: #94a3b8;
    vertical-align: middle;
}
.mb-presence.is-online {
    color: #15803d;
    font-weight: 700;
}
.mb-presence.is-online .mb-presence-dot {
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .2);
}

/* Scoped to the header, past the bubbles' .mb-avatar further down, which
   clips its contents to the circle and would clip the dot too. */
.mb-chat-header .mb-chat-avatar {
    position: relative;
    overflow: visible;
}
.mb-chat-header .mb-chat-avatar.is-online::after {
    content: "";
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 13px;
    height: 13px;
    border: 2px solid var(--surface);
    border-radius: 50%;
    background: #22c55e;
}

/* ---- details panel: its list scrolls, the way out stays put ---- */

.mb-side-header {
    flex: 0 0 auto;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.mb-side-title {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 800;
    color: var(--heading);
}
.mb-side-title .mb-icon { color: var(--link); margin-right: 4px; }

.mb-side-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 4px 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--dk-line-strong, #cbd5e1) transparent;
}
.mb-side-body::-webkit-scrollbar { width: 8px; }
.mb-side-body::-webkit-scrollbar-thumb { background: var(--dk-line-strong, #cbd5e1); border-radius: 999px; }

.mb-side-footer {
    flex: 0 0 auto;
    padding: 14px 20px 16px;
    border-top: 1px solid var(--border);
    background: var(--dk-surface-2, #fcfdff);
}
.mb-side-footer .mb-note { margin: 0 0 12px; line-height: 1.5; }

/* Full width, and without the theme's hover lift inside a pinned footer. */
.mb-leave {
    width: 100%;
    justify-content: center;
    padding-top: 10px;
    padding-bottom: 10px;
}
.mb-leave:hover { transform: none; }

/* status pill */
.mb-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 700;
    white-space: nowrap;
}
.mb-status-open              { background: var(--dk-primary-soft-2, #e0e7ff); color: var(--dk-primary-ink, #3730a3); }
.mb-status-awaiting_customer { background: var(--dk-warning-soft, #fef3c7); color: var(--dk-warning-ink, #92400e); }
.mb-status-awaiting_staff    { background: var(--dk-primary-soft-2, #dbeafe); color: var(--dk-primary-ink, #1e40af); }
.mb-status-closed            { background: var(--dk-surface-4, #e5e7eb); color: var(--dk-text-2, #374151); }

/* =========================================================================
   THREAD — chat bubbles, drawn by _thread.php
   The customer is "us" on this screen: their messages sit on the right in
   the storefront blue; the BDS staff answer on the left in grey beside the
   ITDI mark. Mirrors bds_backend's .conv-msg (web/css/conversation.css).
   ========================================================================= */

.mb-chat {
    --mb-own-bg: var(--primary);
    --mb-own-text: #ffffff;
    --mb-other-bg: var(--dk-surface-3, #eef2f7);
    --mb-other-text: var(--text);
    --mb-bubble-radius: 18px;
    --mb-bubble-join: 5px;
}

.mb-thread {
    display: flex;
    flex-direction: column;
}

/* One message: whatever divider comes before it, the sender's name when it
   starts a group, then the bubble. Messages in a group sit close; a new
   group gets room to breathe. */
.mb-msg {
    display: flex;
    flex-direction: column;
    margin-top: 3px;
}
.mb-msg.is-start { margin-top: 14px; }
.mb-thread > .mb-msg:first-child { margin-top: 0; }

.mb-msg-customer { align-items: flex-end; }
.mb-msg-staff    { align-items: flex-start; }

/* The time between groups, centred as Messenger has it. */
.mb-stamp {
    align-self: stretch;
    margin: 10px 0 8px;
    text-align: center;
    font-size: .76rem;
    font-weight: 700;
    color: var(--muted);
}

/* Where the staff replies the customer had not seen yet begin. */
.mb-divider-new {
    align-self: stretch;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0 4px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--link);
}
.mb-divider-new::before,
.mb-divider-new::after {
    content: '';
    flex: 1 1 auto;
    height: 1px;
    background: rgba(30, 64, 175, .3);
}

/* Clear of the avatar column, so the name sits over the bubble. */
.mb-msg-sender {
    margin: 0 12px 4px 50px;
    font-size: .76rem;
    font-weight: 600;
    color: var(--muted);
}

.mb-msg-line {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 75%;
}

/* Every staff bubble keeps the column, so a group lines up; only the last
   one of the group shows the mark. */
.mb-avatar-slot {
    flex: 0 0 34px;
    width: 34px;
}
.mb-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    overflow: hidden;
}
.mb-avatar img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.mb-bubble {
    min-width: 0;
    padding: 9px 14px;
    border-radius: var(--mb-bubble-radius);
    background: var(--mb-other-bg);
    color: var(--mb-other-text);
    font-size: .97rem;
    line-height: 1.5;
}
.mb-msg-customer .mb-bubble {
    background: var(--mb-own-bg);
    color: var(--mb-own-text);
}

/* A group reads as one block: the corners on the sender's side tighten
   where one bubble meets the next. */
.mb-msg-customer:not(.is-end) .mb-bubble   { border-bottom-right-radius: var(--mb-bubble-join); }
.mb-msg-customer:not(.is-start) .mb-bubble { border-top-right-radius: var(--mb-bubble-join); }
.mb-msg-staff:not(.is-end) .mb-bubble      { border-bottom-left-radius: var(--mb-bubble-join); }
.mb-msg-staff:not(.is-start) .mb-bubble    { border-top-left-radius: var(--mb-bubble-join); }

.mb-msg-body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* The theme's gold selection is unreadable on the blue bubble. */
.mb-msg-customer .mb-bubble ::selection {
    background: rgba(255, 255, 255, .35);
    color: #fff;
}

.mb-attachment {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: .85rem;
    font-weight: 600;
    color: var(--link);
    text-decoration: none;
}
.mb-attachment:hover { border-color: var(--primary); color: var(--link); }

.mb-msg-customer .mb-attachment {
    border-color: rgba(255, 255, 255, .35);
    background: rgba(255, 255, 255, .14);
    color: #fff;
}
.mb-msg-customer .mb-attachment:hover {
    border-color: #fff;
    background: rgba(255, 255, 255, .24);
    color: #fff;
}

.mb-thread-empty {
    margin: auto 0;
    text-align: center;
}

/* A file still sending: the link's look, not yet a link. */
span.mb-attachment { overflow-wrap: anywhere; }

/* Under the text; a file sent on its own has nothing to clear. */
.mb-bubble > .visually-hidden + .mb-attachment { margin-top: 0; }

/* ── photos in the thread ──
   A JPG or PNG shows as the picture itself, under its text, the way
   Messenger shows one: no bubble behind it, rounded, at most 260 x 320.
   The server sizes each box from the picture before it loads
   (views/mailbox/_thread.php), so the thread does not jump. Mirrors
   bds_backend's .conv-photo (web/css/conversation.css). */
.mb-msg-stack {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mb-msg-customer .mb-msg-stack { align-items: flex-end; }
.mb-msg-staff .mb-msg-stack    { align-items: flex-start; }

/* The cap sits on the box, not only on the picture: a percentage on the
   picture inside a box that sizes to its content resolves against nothing,
   and a photo still sending (no width from the server yet) would stretch
   the box to the picture's full size. */
.mb-photo {
    display: block;
    max-width: 260px;
    border-radius: 16px;
    overflow: hidden;
    background-color: var(--dk-surface-3, #e9eef5);
    background-position: center;
    background-size: cover;
    line-height: 0;
    cursor: zoom-in;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .06);
    transition: filter .15s ease;
}
.mb-photo:hover { filter: brightness(.94); }
.mb-photo:focus-visible { outline: 3px solid rgba(30, 64, 175, .45); outline-offset: 2px; }

/* Sized by the server (width + aspect-ratio); without that — a file it
   could not read, or one still sending — the picture's own size, capped. */
.mb-photo img {
    display: block;
    max-width: 100%;
    max-height: 320px;
    height: auto;
    object-fit: cover;
}
.mb-photo img[style] { max-height: none; }

/* A photo just sent, while the stored copy loads over the browser's own. */
.mb-photo.is-bridged img { opacity: 0; }

/* Sent, not yet stored: faded, with "Sending…" under the last of it. */
.mb-msg-pending .mb-msg-stack { opacity: .6; }
.mb-msg-status {
    align-self: flex-end;
    margin: 4px 4px 0;
    font-size: .74rem;
    color: var(--muted);
}

/* ── files about to be sent — #mb-attachment-preview in thread.php ──
   The tray over the input, as Messenger lines up what is attached: a
   square thumbnail per photo, a card per file, each with its own x, and a
   + to add more. Mirrors bds_backend's .conv-tray. */
.mb-tray[hidden] { display: none; } /* beats the UA [hidden] rule */
.mb-tray {
    display: flex;
    gap: 8px;
    margin: 0 0 10px;
    padding: 2px 2px 6px;
    overflow-x: auto;
    scrollbar-width: thin;
}
.mb-tray-item {
    position: relative;
    flex: 0 0 auto;
    height: 64px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--dk-surface-2, #f8fafc);
}
.mb-tray-item.is-photo { width: 64px; overflow: hidden; }
.mb-tray-thumb,
.mb-tray-thumb img { display: block; width: 100%; height: 100%; }
.mb-tray-thumb img { object-fit: cover; cursor: zoom-in; }
.mb-tray-item.is-file {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 220px;
    padding: 0 30px 0 12px;
}
.mb-tray-icon { flex: 0 0 auto; font-size: 22px; color: var(--link); }
.mb-tray-meta { min-width: 0; display: flex; flex-direction: column; }
.mb-tray-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .8rem;
    font-weight: 600;
}
.mb-tray-size { font-size: .74rem; color: var(--muted); }
.mb-tray-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(15, 23, 42, .62);
    color: #fff;
    font-size: 11px;
    cursor: pointer;
}
.mb-tray-remove:hover,
.mb-tray-remove:focus-visible { background: var(--danger); }
.mb-tray-add {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin: 0;
    border: 1px dashed var(--primary);
    border-radius: 12px;
    color: var(--link);
    font-size: 18px;
    cursor: pointer;
}
.mb-tray-add:hover { background: var(--dk-primary-soft, #eff6ff); }

/* Files dragged over the chat: the whole card says it will take them. */
.mb-chat.is-dropping { position: relative; }
.mb-chat.is-dropping::after {
    content: 'Drop to attach';
    position: absolute;
    inset: 8px;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--primary);
    border-radius: 14px;
    background: var(--dk-glass, rgba(239, 246, 255, .92));
    color: var(--link);
    font-size: 1rem;
    font-weight: 700;
    pointer-events: none;
}

/* attachment preview dialog — the #mb-file-preview <dialog> in thread.php
   (its frame is under "dialogs" at the end of this file). */
.mb-preview-slot {
    min-height: 120px;
    text-align: center;
}
.mb-preview-img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 8px;
}
.mb-preview-frame {
    width: 100%;
    height: 70vh;
    border: 0;
    border-radius: 8px;
}
.mb-preview-notice { padding: 22px 8px 6px; }
.mb-preview-notice-title {
    margin: 14px 0 4px;
    font-size: 1rem;
    font-weight: 700;
}
.mb-preview-notice-text {
    margin: 0;
    font-size: .9rem;
    color: var(--muted);
}

/* details — label and value side by side, tight enough that the whole
   record fits the panel on most screens */
.mb-facts { margin: 0; }
.mb-fact {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
    line-height: 1.5;
}
.mb-fact:last-child { border-bottom: 0; }
.mb-fact dt {
    font-weight: 600;
    color: var(--muted);
}
.mb-fact dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.mb-tech-list { margin: 0; padding-left: 18px; }
.mb-tech-list li { margin-bottom: 4px; }

.mb-note {
    font-size: .85rem;
    color: var(--muted);
}

.mb-closed {
    padding: 16px;
    border-radius: var(--radius-sm);
    background: var(--dk-surface-3, #f3f4f6);
    color: var(--dk-text-2, #374151);
    font-size: .95rem;
}

@media (max-width: 1100px) {
    .mb-grid { grid-template-columns: minmax(0, 1fr) 300px; }
}

/* Side by side stops fitting: the chat keeps a full window of its own and
   the details follow it down the page at their natural height. */
@media (max-width: 900px) {
    .mb-grid {
        grid-template-columns: minmax(0, 1fr);
        height: auto;
        min-height: 0;
    }
    .mb-chat {
        height: calc(100vh - 79px - 40px);
        height: calc(100dvh - 79px - 40px);
        min-height: 480px;
    }
    .mb-side-body { overflow: visible; }
    .mb-msg-line { max-width: 88%; }
}

@media (max-width: 600px) {
    .mb-page { padding: 12px 0; }
    .mb-chat { height: calc(100dvh - 79px - 24px); }
    .mb-chat-header { padding: 10px 12px; gap: 10px; }
    .mb-chat-avatar { display: none; }
}

/* =========================================================================
   SCROLLING THREAD
   The thread scrolls in its own panel the way Messenger's does, so a long
   conversation does not push the reply box down the page. Driven by the
   live-thread script in thread.php: it opens on the latest message, follows
   new ones down while the reader is at the bottom, and otherwise leaves
   them where they are and shows the jump button. Mirrors bds_backend's
   .conv-thread-scroll (web/css/conversation.css).
   ========================================================================= */

/* Whatever height the card has left between its header and the composer
   is the thread's: as the composer grows, the thread gives way. */
.mb-thread-viewport {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* A column, so a short thread sits at the bottom next to the composer the
   way a chat does. The auto margin does it rather than justify-content:
   flex-end, which would put the top of a long thread out of scroll reach. */
.mb-thread-scroll {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 18px 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--dk-line-strong, #cbd5e1) transparent;
}

.mb-thread-scroll > .mb-thread { margin-top: auto; }
.mb-thread-scroll > .mb-note { margin: auto 0; }

/* Darker under the pointer, as Messenger's does. */
.mb-thread-scroll:hover { scrollbar-color: var(--dk-text-subtle, #94a3b8) transparent; }

/* Browsers that ignore scrollbar-color. */
.mb-thread-scroll::-webkit-scrollbar { width: 8px; }
.mb-thread-scroll::-webkit-scrollbar-track { background: transparent; }
.mb-thread-scroll::-webkit-scrollbar-thumb { background: var(--dk-line-strong, #cbd5e1); border-radius: 999px; }
.mb-thread-scroll:hover::-webkit-scrollbar-thumb { background: var(--dk-text-subtle, #94a3b8); }

.mb-thread-scroll:focus { outline: none; }
.mb-thread-scroll:focus-visible {
    outline: 2px solid rgba(30, 64, 175, .35);
    outline-offset: -2px;
}

/* A soft shadow on whichever edge has more thread past it. It keeps clear
   of the scrollbar and never takes a click. */
.mb-thread-viewport::before,
.mb-thread-viewport::after {
    content: '';
    position: absolute;
    left: 0;
    right: 10px;
    height: 14px;
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s ease;
}
.mb-thread-viewport::before {
    top: 0;
    background: linear-gradient(rgba(18, 41, 74, .08), rgba(18, 41, 74, 0));
}
.mb-thread-viewport::after {
    bottom: 0;
    background: linear-gradient(rgba(18, 41, 74, 0), rgba(18, 41, 74, .08));
}
.mb-thread-viewport.has-above::before,
.mb-thread-viewport.has-below::after { opacity: 1; }

/* Back to the latest. A round arrow once the reader has scrolled up; it
   widens into a "2 new messages" pill when something lands meanwhile.
   visibility, not just opacity, so a hidden button is out of the tab
   order — and it lags the fade so the fade is seen. */
.mb-jump {
    position: absolute;
    left: 50%;
    bottom: 14px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 38px;
    height: 38px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--link);
    box-shadow: 0 4px 14px rgba(18, 41, 74, .18);
    font-size: .82rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, 10px);
    transition: opacity .18s ease, transform .18s ease, background-color .18s ease,
                color .18s ease, visibility 0s linear .18s;
}
.mb-jump.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
    transition-delay: 0s;
}
.mb-jump:hover { background: var(--dk-primary-soft, #eef2ff); border-color: var(--dk-primary-line, #c7d2fe); }
.mb-jump:focus-visible {
    outline: 2px solid rgba(30, 64, 175, .45);
    outline-offset: 2px;
}
.mb-jump > span[aria-hidden] { font-size: .9rem; }
.mb-jump.has-new {
    padding: 0 16px;
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}
.mb-jump.has-new:hover { background: var(--primary-lt); border-color: var(--primary-lt); }
.mb-jump-label:empty { display: none; }

/* A message that came in over the poll or the reply slides up into place
   rather than appearing. */
.mb-msg-arrived { animation: mb-msg-in .28s ease-out; }

@keyframes mb-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .mb-msg-arrived { animation: none; }
    .mb-jump { transition: none; }
}

@media (max-width: 600px) {
    .mb-thread-scroll { padding: 14px; }
}

/* =========================================================================
   COMPOSER
   The reply box, docked under the thread in the same panel: a paperclip,
   a one-line pill that grows as the reply does and scrolls past a cap, and
   a send button. The live-thread script in thread.php does the growing and
   Ctrl + Enter. Mirrors bds_backend's .conv-composer.
   ========================================================================= */

.mb-composer-area {
    flex: 0 0 auto;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

/* Notices sit over the composer; a long one must not squeeze the thread
   to nothing. */
.mb-composer-area .mb-alert {
    margin-bottom: 10px;
    padding: 10px 14px;
    max-height: 30vh;
    overflow-y: auto;
}
.mb-composer-area .mb-closed { margin: 0; }

.mb-composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

/* The paperclip and the send button stay at the bottom as the pill grows,
   as they do in Messenger. */
.mb-composer-btn,
.mb-composer-send {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color .18s ease, color .18s ease, transform .12s ease;
}

.mb-composer-btn {
    background: transparent;
    color: var(--link);
    font-size: 1.15rem;
}
.mb-composer-btn:hover { background: var(--dk-primary-soft, #eef2ff); }

/* The input itself is visually hidden, so its focus shows on the paperclip. */
.mb-composer-file:focus-visible + .mb-composer-attach {
    outline: 2px solid rgba(30, 64, 175, .45);
    outline-offset: 2px;
}
.mb-composer-file.is-invalid + .mb-composer-attach {
    color: var(--dk-danger-ink, var(--danger));
    background: var(--dk-danger-soft, #fef2f2);
}

.mb-composer-field {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    padding: 4px 8px 4px 0;
    border: 1.5px solid transparent;
    border-radius: 22px;
    background: var(--dk-surface-3, #f1f5f9);
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.mb-composer-field:hover { background: var(--dk-surface-3, #eaeff5); }
.mb-composer-field:focus-within {
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(30, 64, 175, .12);
}
.mb-composer-field:has(.is-invalid) { border-color: var(--danger); }

/* One line tall until there is more to show; eight lines, then it scrolls.
   The script sets the height; overflow stays hidden until the cap so a
   short reply never flashes a scrollbar. */
.mb-composer-input {
    display: block;
    width: 100%;
    min-height: 30px;
    max-height: min(196px, 30vh);
    margin: 0;
    padding: 4px 8px 4px 16px;
    border: 0;
    outline: none;
    background: transparent;
    resize: none;
    overflow-y: hidden;
    font-family: inherit;
    font-size: .97rem;
    line-height: 1.5;
    color: var(--text);
    scrollbar-width: thin;
    scrollbar-color: var(--dk-line-strong, #cbd5e1) transparent;
}
.mb-composer-input::placeholder { color: var(--dk-text-subtle, #9aa7b8); }
.mb-composer-input.is-scrolling { overflow-y: auto; }
.mb-composer-input::-webkit-scrollbar { width: 6px; }
.mb-composer-input::-webkit-scrollbar-track { background: transparent; }
.mb-composer-input::-webkit-scrollbar-thumb { background: var(--dk-line-strong, #cbd5e1); border-radius: 999px; }
.mb-composer-input::-webkit-scrollbar-thumb:hover { background: var(--dk-text-subtle, #94a3b8); }

/* Filled blue once there is something to send — words or a file — and
   grey while there is neither. */
.mb-composer-send {
    background: var(--primary);
    color: #fff;
    font-size: 1rem;
    box-shadow: 0 6px 16px rgba(30, 64, 175, .25);
}
.mb-composer-send:hover { background: var(--primary-lt); }
.mb-composer-send:active { transform: scale(.94); }
.mb-composer-send:focus-visible {
    outline: 2px solid rgba(30, 64, 175, .45);
    outline-offset: 2px;
}
.mb-composer:not(.has-files):has(.mb-composer-input:placeholder-shown) .mb-composer-send {
    background: var(--dk-surface-4, #e2e8f0);
    color: var(--dk-text-subtle, #94a3b8);
    box-shadow: none;
}

/* The plane nudged a touch left, so it looks centred in the circle. */
.mb-send-icon { margin-left: -2px; }
.mb-send-spinner { display: none; }
.mb-composer-send.is-sending { cursor: progress; }
.mb-composer-send.is-sending .mb-send-icon { display: none; }
.mb-composer-send.is-sending .mb-send-spinner { display: inline-block; }

/* The session ran out: the form stays, greyed, with the draft still in it. */
.mb-composer:has(.mb-composer-input:disabled) { opacity: .6; }
.mb-composer:has(.mb-composer-input:disabled) .mb-composer-btn,
.mb-composer:has(.mb-composer-input:disabled) .mb-composer-send { cursor: not-allowed; }

/* Lined up under the pill, clear of the paperclip. */
/* One line: the note gives way with an ellipsis before the keys do. */
.mb-composer-hint {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 6px 50px 0;
    font-size: .78rem;
    color: var(--muted);
    white-space: nowrap;
}
.mb-composer-hint-keys { flex: 0 0 auto; }
.mb-composer-hint-note {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mb-composer-hint kbd {
    padding: 1px 5px;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: var(--light-bg);
    color: var(--text);
    font-family: inherit;
    font-size: .72rem;
    font-weight: 600;
    box-shadow: none;
}

@media (max-width: 600px) {
    .mb-composer-area { padding: 12px; }
    .mb-composer-hint { margin: 6px 4px 0; }
}

@media (prefers-reduced-motion: reduce) {
    .mb-composer-btn,
    .mb-composer-send,
    .mb-composer-field { transition: none; }
}

/* =========================================================================
   ETV PARTS
   ========================================================================= */

/* ---- sign-in page ----
   It opens with the shared page bar (views/layouts/_page_bar.php, .page-bar
   in components.css). */

.mb-wrap {
    max-width: var(--site-max-width);
    margin: 0 auto;
    padding: 28px var(--site-gutter) 56px;
}

.mb-signin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    gap: 22px;
    align-items: start;
}

.mb-info-card,
.mb-form-card {
    padding: 26px 28px;
}

.mb-card-title {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 700;
    color: var(--navy);
}

.mb-info-item {
    display: flex;
    gap: 14px;
    margin-top: 18px;
}

.mb-info-icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--sky-light);
    color: var(--navy);
    font-size: 18px;
    font-weight: 700;
}

.mb-info-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--navy);
}

.mb-info-text {
    margin-top: 2px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--g700);
}

.mb-info-text code {
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--g50);
    font-size: 12px;
}

.mb-field {
    margin-top: 16px;
}

.mb-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--g700);
}

.mb-req {
    color: var(--danger);
}

.mb-input {
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid var(--g200);
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.mb-input:focus {
    border-color: var(--sky);
    box-shadow: 0 0 0 3px rgba(26, 156, 216, .15);
    outline: none;
}

.mb-input.is-invalid {
    border-color: var(--danger);
}

.mb-honeypot {
    position: absolute;
    left: -9999px;
}

/* ---- buttons ---- */

.mb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border: 1.5px solid transparent;
    border-radius: 999px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s ease, transform .1s ease;
}

.mb-btn-primary {
    background: linear-gradient(135deg, #0B5ED7, #0A2A5E);
    color: #fff;
}

.mb-btn-primary:hover {
    background: linear-gradient(135deg, #0a53c2, #08214a);
    color: #fff;
}

.mb-form-card .mb-btn-primary {
    width: 100%;
    margin-top: 20px;
}

.mb-btn-outline {
    border-color: var(--navy);
    background: #fff;
    color: var(--navy);
}

.mb-btn-outline:hover {
    background: var(--primary-lt);
}

/* ---- alerts ---- */

.mb-alert {
    display: flex;
    gap: 8px;
    margin: 12px 0;
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-size: 13px;
    line-height: 1.5;
}

.mb-alert[hidden] {
    display: none;
}

.mb-alert-success {
    border-color: #b7e4c7;
    background: #e9f7ef;
    color: #1e6b3a;
}

.mb-alert-error {
    border-color: #f5c2c7;
    background: #fdecee;
    color: #9b1c2c;
}

.mb-alert a {
    color: inherit;
    font-weight: 600;
}

/* ---- thread page: the side panel's status and timeline ---- */

.mb-status-card {
    padding: 14px 16px;
    border: 1px solid #cfe2fb;
    border-radius: 12px;
    background: #eef5ff;
}

.mb-request-2 { border-color: #f5c050; background: #fef5e0; }
.mb-request-5,
.mb-request-7 { border-color: #b7e4c7; background: #e9f7ef; }
.mb-request-8 { border-color: #f5c2c7; background: #fdecee; }

.mb-status-caption {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--g500);
}

.mb-status-now {
    margin-top: 2px;
    font-size: 16px;
    font-weight: 700;
    color: var(--navy);
}

.mb-status-hint {
    margin: 6px 0 0;
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--g700);
}

.mb-side-subtitle {
    margin: 18px 0 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--g500);
}

.mb-timeline {
    margin: 0;
    padding: 0;
    list-style: none;
}

.mb-timeline li {
    position: relative;
    padding: 0 0 14px 22px;
}

.mb-timeline li::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 14px;
    bottom: 0;
    width: 2px;
    background: var(--g100);
}

.mb-timeline li:last-child::before {
    display: none;
}

.mb-timeline-dot {
    position: absolute;
    left: 0;
    top: 4px;
    width: 12px;
    height: 12px;
    border: 2px solid var(--g300);
    border-radius: 50%;
    background: #fff;
}

.mb-timeline li.is-latest .mb-timeline-dot {
    border-color: var(--sky);
    background: var(--sky);
}

.mb-timeline-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.mb-timeline-when {
    font-size: 11.5px;
    color: var(--g500);
}

.mb-file-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.mb-file-list li {
    margin-bottom: 2px;
    overflow-wrap: anywhere;
}

/* The send button without an icon font: an arrow, and a spinning ring while sending. */
.mb-send-icon {
    font-size: 15px;
    line-height: 1;
}

.mb-send-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: mb-spin .8s linear infinite;
}

@keyframes mb-spin {
    to { transform: rotate(360deg); }
}

.mb-composer-attach > span[aria-hidden] {
    font-size: 17px;
    line-height: 1;
}

/* ---- dialogs (attachment preview; the idle sign-out has its own sheet) ---- */

.mb-dialog {
    width: min(900px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    margin: auto; /* layout.css's "* { margin: 0 }" would pin it to a corner */
    padding: 0;
    border: none;
    border-radius: 14px;
    box-shadow: 0 24px 60px -18px rgba(10, 42, 94, .45);
}

.mb-dialog::backdrop {
    background: rgba(10, 20, 45, .55);
}

.mb-dialog-head,
.mb-dialog-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
}

.mb-dialog-head {
    justify-content: space-between;
    border-bottom: 1px solid var(--g100);
}

.mb-dialog-foot {
    justify-content: flex-end;
    border-top: 1px solid var(--g100);
}

.mb-dialog-body {
    padding: 16px 20px;
}

.mb-preview-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--navy);
    overflow-wrap: anywhere;
}

.mb-dialog-close {
    border: none;
    background: none;
    color: var(--g500);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.mb-preview-notice-icon {
    font-size: 42px;
}

/* ---- narrow screens ---- */

@media (max-width: 860px) {
    .mb-signin-grid {
        grid-template-columns: 1fr;
    }
}

/* ---- thread page: the payment card (status Awaiting payment) ----
   What the payment-instructions email says, beside the conversation. The
   email's "Upload Proof of Payment" link lands here (#payment). */

.mb-pay {
    margin-top: 14px;
    padding: 14px 16px;
    border: 1px solid #cfe2fb;
    border-radius: 12px;
    background: #fff;
    scroll-margin-top: 90px;
}

.mb-pay:target {
    border-color: var(--sky);
    box-shadow: 0 0 0 3px rgba(11, 94, 215, .15);
}

.mb-pay-title {
    margin: 0 0 10px;
    font-size: 15px;
    font-weight: 700;
    color: var(--navy);
}

.mb-pay-facts,
.mb-pay-bank {
    margin: 0;
}

.mb-pay-facts > div,
.mb-pay-bank > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    font-size: 13px;
}

.mb-pay-facts dt,
.mb-pay-bank dt {
    color: var(--g500);
    font-weight: 500;
}

.mb-pay-facts dd,
.mb-pay-bank dd {
    margin: 0;
    text-align: right;
    color: var(--text);
}

.mb-pay-due {
    color: #c62828 !important;
    font-weight: 700;
}

.mb-pay-overdue {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    background: #fdecee;
    color: #b42318;
}

.mb-pay-warn {
    margin: 8px 0 12px;
    font-size: 12px;
    line-height: 1.5;
    color: #c62828;
}

.mb-pay-box {
    padding: 10px 12px;
    border: 1px solid #c9dcf5;
    border-radius: 10px;
    background: #eef5ff;
    font-size: 13px;
    line-height: 1.5;
}

.mb-pay-box-title {
    margin-bottom: 4px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--g500);
}

.mb-pay-bank dt {
    white-space: nowrap;
}

.mb-pay-bank dd {
    font-weight: 700;
}

.mb-pay-tsr {
    width: 100%;
    margin-top: 12px;
    padding: 9px 16px;
    font-size: 13px;
}

.mb-pay-next {
    margin: 10px 0 0;
}

/* After you pay (DRAFT payment process): proof goes through the chat. */
.mb-pay-steps {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--g100);
}

.mb-pay-steps .mb-note {
    margin: 0 0 10px;
}

.mb-pay-send {
    width: 100%;
    padding: 9px 16px;
    font-size: 13px;
}

/* Paid: the ETV team recorded the official receipt. */
.mb-pay-done {
    border-color: #b7e4c7;
    background: #f3fbf6;
}

.mb-pay-done .mb-pay-title {
    color: #157347;
}

/* The meeting the ETV team set (milestone 5): the mini calendar
   (css/meeting-calendar.css) in the site's navy. */
.mb-meeting {
    border-color: #c7d2fe;
    background: #f5f7ff;
}

.mb-meeting .mcal {
    --mcal-accent: var(--navy);
}

.mb-meeting-next {
    margin: 10px 0 0;
}

.mb-meeting.is-cancelled {
    border-color: #f5c2c7;
    background: #fff5f5;
}

.mb-meeting.is-cancelled .mb-pay-title {
    color: #b42318;
}
