/*
 * China Kanta messenger — §11 premium mobile, §1..§6 surfaces.
 *
 * Hand-written rather than Tailwind because the production host has no node: public/build is a
 * committed bundle with no new utilities in it. A new filename, not a query string — the edge cache
 * holds a CSS URL for seven days.
 *
 * The page is a column: bar, pinned context card, scrolling messages, composer. On a phone the
 * column fills exactly the space between the status band and the bottom tab bar, so the document
 * never scrolls and opening the keyboard shortens the column instead of pushing the form off screen.
 */

.ck-msg {
    --ck-msg-brand: var(--ck-brand, #e31e24);
    --ck-msg-ink: var(--ck-ink, #171719);
    --ck-msg-muted: var(--ck-muted, #555555);
    --ck-msg-line: var(--ck-line, #eeeeee);
    --ck-msg-bg: #f6f6f7;
    --ck-msg-self: var(--ck-msg-brand);
    --ck-msg-seal: #1a8cff;
    --ck-msg-radius: 18px;
    --ck-msg-x: 14px;

    display: flex;
    flex-direction: column;
    width: 100%;
    background: var(--ck-msg-bg);
    color: var(--ck-msg-ink);
    -webkit-text-size-adjust: 100%;
}

/* The bar owns its own row on both surfaces; it never rides on top of a message. */
.ck-msg-bar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: #fff;
    border-bottom: 1px solid var(--ck-msg-line);
}

/* ---------- §1 header ---------- */

.ck-msg-bar-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 12px var(--ck-msg-x) 8px;
}

.ck-msg-title {
    margin: 0;
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--ck-msg-ink);
}

.ck-msg-title-count {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 9999px;
    background: var(--ck-msg-brand);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.5;
    vertical-align: 2px;
}

.ck-msg-sub {
    margin: 0;
    max-width: 46%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    color: var(--ck-msg-muted);
}

/* ---------- §1 shortcuts: a rail, not a grid of tiles ---------- */

.ck-msg-shortcuts {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 0 var(--ck-msg-x) 10px;
}

.ck-msg-shortcuts::-webkit-scrollbar {
    display: none;
}

.ck-msg-shortcut {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid var(--ck-msg-line);
    border-radius: 9999px;
    background: #fff;
    color: var(--ck-msg-ink);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.ck-msg-shortcut svg {
    width: 16px;
    height: 16px;
    color: var(--ck-msg-brand);
}

.ck-msg-shortcut:active {
    background: var(--ck-msg-bg);
}

/* ---------- §2 search ---------- */

.ck-msg-search {
    position: relative;
    padding: 0 var(--ck-msg-x) 10px;
}

.ck-msg-search svg {
    position: absolute;
    left: calc(var(--ck-msg-x) + 11px);
    top: 10px;
    width: 17px;
    height: 17px;
    margin-top: 11px;
    color: var(--ck-msg-muted);
    pointer-events: none;
}

.ck-msg-search input[type="search"] {
    display: block;
    box-sizing: border-box;
    width: 100%;
    margin: 0;
    padding: 11px 40px 11px 38px;
    border: 1px solid var(--ck-msg-line);
    border-radius: 12px;
    background: var(--ck-msg-bg);
    color: var(--ck-msg-ink);
    font: inherit;
    font-size: 15px;
    -webkit-appearance: none;
    appearance: none;
}

.ck-msg-search input[type="search"]::-webkit-search-cancel-button {
    display: none;
}

.ck-msg-search input[type="search"]:focus {
    border-color: var(--ck-msg-brand);
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 3px rgb(227 30 36 / 12%);
}

.ck-msg-search-clear {
    position: absolute;
    right: calc(var(--ck-msg-x) + 8px);
    top: 10px;
    display: flex;
    width: 30px;
    height: 30px;
    margin-top: 4px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 9999px;
    background: transparent;
    color: var(--ck-msg-muted);
    cursor: pointer;
}

.ck-msg-search-clear svg {
    position: static;
    margin: 0;
    width: 15px;
    height: 15px;
    color: inherit;
}

/* ---------- §3 filters ---------- */

.ck-msg-filters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 0 var(--ck-msg-x) 12px;
}

.ck-msg-filters::-webkit-scrollbar {
    display: none;
}

.ck-msg-chip {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border: 1px solid var(--ck-msg-line);
    border-radius: 9999px;
    background: #fff;
    color: var(--ck-msg-muted);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ck-msg-chip.is-on {
    border-color: var(--ck-msg-brand);
    background: var(--ck-msg-brand);
    color: #fff;
}

.ck-msg-chip-count {
    padding: 0 5px;
    border-radius: 9999px;
    background: rgb(0 0 0 / 8%);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.6;
}

.ck-msg-chip.is-on .ck-msg-chip-count {
    background: rgb(255 255 255 / 24%);
}

.ck-msg-chip-dot {
    width: 9px;
    height: 9px;
    border-radius: 9999px;
    background: var(--ck-label, var(--ck-msg-brand));
}

.ck-msg-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 0 var(--ck-msg-x) 12px;
    border-bottom: 1px solid var(--ck-msg-line);
    background: #fff;
}

.ck-msg-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    border: 1px solid var(--ck-msg-line);
    border-radius: 9999px;
    background: #fff;
    color: var(--ck-msg-muted);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.ck-msg-label::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 9999px;
    background: var(--ck-label, #c7c7cc);
}

.ck-msg-label.is-clear::before {
    background: repeating-linear-gradient(135deg, #d8d8dc 0 3px, #f1f1f3 3px 6px);
}

.ck-msg-label.is-on {
    border-color: var(--ck-label, var(--ck-msg-brand));
    color: var(--ck-msg-ink);
    background: color-mix(in srgb, var(--ck-label, #e31e24) 10%, #fff);
}

/* ---------- the list ---------- */

.ck-msg-list {
    flex: 1 1 auto;
    padding: 6px 0 calc(20px + var(--ck-bottom-inset, 0px));
}

/* a search or a filter chip that costs a round trip says so, without a spinner over the words */
.ck-msg-list.is-fetching {
    opacity: 0.5;
    pointer-events: none;
}

.ck-msg-row {
    position: relative;
    display: flex;
    align-items: stretch;
    background: #fff;
    border-bottom: 1px solid var(--ck-msg-line);
}

.ck-msg-card {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    gap: 11px;
    padding: 12px var(--ck-msg-x);
    color: inherit;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.ck-msg-card:active {
    background: var(--ck-msg-bg);
}

.ck-msg-row.is-unread {
    box-shadow: inset 3px 0 0 var(--ck-msg-brand);
}

/* avatars: a hue the party computes, never a stock illustration */

.ck-msg-avatar {
    display: flex;
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 9999px;
    background: hsl(var(--ck-hue, 12) 74% 92%);
    color: hsl(var(--ck-hue, 12) 62% 34%);
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.ck-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ck-msg-avatar-sm {
    width: 36px;
    height: 36px;
    font-size: 13px;
}

.ck-msg-avatar-xs {
    width: 26px;
    height: 26px;
    font-size: 10px;
}

.ck-msg-verified {
    width: 14px;
    height: 14px;
    margin-left: 3px;
    vertical-align: -2px;
    color: var(--ck-msg-seal);
}

.ck-msg-body {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
    justify-content: center;
}

.ck-msg-line {
    display: flex;
    min-width: 0;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.ck-msg-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15.5px;
    font-weight: 700;
    color: var(--ck-msg-ink);
}

.ck-msg-row.is-unread .ck-msg-name {
    font-weight: 800;
}

.ck-msg-time {
    flex: 0 0 auto;
    font-size: 11.5px;
    color: var(--ck-msg-muted);
}

.ck-msg-store {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: var(--ck-msg-muted);
}

.ck-msg-preview {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13.5px;
    line-height: 1.35;
    color: var(--ck-msg-muted);
}

.ck-msg-row.is-unread .ck-msg-preview {
    color: var(--ck-msg-ink);
    font-weight: 600;
}

.ck-msg-badge {
    flex: 0 0 auto;
    min-width: 19px;
    padding: 1px 6px;
    border-radius: 9999px;
    background: var(--ck-msg-brand);
    color: #fff;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.5;
    text-align: center;
}

.ck-msg-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.ck-msg-tag {
    padding: 1px 8px;
    border: 1px solid color-mix(in srgb, var(--ck-label, #c7c7cc) 40%, #fff);
    border-radius: 9999px;
    background: color-mix(in srgb, var(--ck-label, #c7c7cc) 10%, #fff);
    color: color-mix(in srgb, var(--ck-label, #555) 78%, #171719);
    font-size: 11px;
    font-weight: 600;
}

.ck-msg-thumb {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    align-self: center;
    overflow: hidden;
    width: 44px;
    height: 44px;
    border-radius: 9px;
    background: var(--ck-msg-bg);
    color: var(--ck-msg-muted);
}

.ck-msg-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ck-msg-thumb svg {
    width: 19px;
    height: 19px;
}

/* §4 row actions. Base = the strip under the row that a thumb can sit beside on a phone;
   at lg the strip lifts onto the row and appears on hover, where there is room for it. */

.ck-msg-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 2px;
    padding: 0 6px 7px var(--ck-msg-x);
}

.ck-msg-action {
    display: flex;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 9999px;
    background: transparent;
    color: #9a9aa1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ck-msg-action svg {
    width: 17px;
    height: 17px;
}

.ck-msg-action.is-on {
    color: var(--ck-msg-brand);
}

summary.ck-msg-action {
    list-style: none;
    cursor: pointer;
}

summary.ck-msg-action::-webkit-details-marker {
    display: none;
}

.ck-msg-labelsheet {
    position: relative;
}

.ck-msg-labelsheet-list {
    position: absolute;
    z-index: 40;
    right: 0;
    bottom: calc(100% + 6px);
    display: flex;
    flex-direction: column;
    gap: 1px;
    width: 186px;
    max-height: 240px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--ck-msg-line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 12px 30px rgb(23 23 25 / 16%);
}

.ck-msg-labelrow {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 9px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ck-msg-ink);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.ck-msg-labelrow svg {
    width: 15px;
    height: 15px;
    margin-left: auto;
    color: var(--ck-msg-brand);
}

.ck-msg-labelrow-dot {
    width: 9px;
    height: 9px;
    flex: 0 0 auto;
    border-radius: 9999px;
    background: var(--ck-label, #c7c7cc);
}

.ck-msg-labelrow.is-on {
    background: var(--ck-msg-bg);
}

/* the empty state and the pagination row */

.ck-msg-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 46px 26px;
    text-align: center;
}

.ck-msg-empty svg {
    width: 42px;
    height: 42px;
    color: #d5d5da;
}

.ck-msg-empty p {
    margin: 0;
    max-width: 34ch;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ck-msg-muted);
}

.ck-msg-more {
    display: flex;
    justify-content: center;
    padding: 16px var(--ck-msg-x);
}

.ck-msg-more nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
}

.ck-msg-more a,
.ck-msg-more span[aria-current],
.ck-msg-more span[aria-disabled="true"] {
    display: inline-flex;
    min-width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    padding: 0 9px;
    border: 1px solid var(--ck-msg-line);
    border-radius: 9px;
    background: #fff;
    color: var(--ck-msg-ink);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.ck-msg-more span[aria-current="page"] {
    border-color: var(--ck-msg-brand);
    background: var(--ck-msg-brand);
    color: #fff;
}

.ck-msg-more svg {
    display: none;
}

/* ---------- §5 the thread ---------- */

.ck-msg-bar-thread {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px var(--ck-msg-x);
}

.ck-msg-back {
    display: flex;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    margin-left: -6px;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    color: var(--ck-msg-ink);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.ck-msg-back svg {
    width: 21px;
    height: 21px;
}

.ck-msg-head {
    flex: 1 1 auto;
    min-width: 0;
}

.ck-msg-head .ck-msg-name {
    font-size: 15px;
    line-height: 1.25;
}

.ck-msg-status {
    overflow: hidden;
    margin: 2px 0 0;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    line-height: 1.3;
    color: var(--ck-msg-muted);
}

.ck-msg-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--ck-msg-brand);
    font-weight: 600;
}

.ck-msg-typing i {
    width: 5px;
    height: 5px;
    border-radius: 9999px;
    background: currentColor;
    animation: ck-msg-blink 1s infinite ease-in-out;
}

.ck-msg-typing i:nth-child(2) {
    animation-delay: 140ms;
}

.ck-msg-typing i:nth-child(3) {
    animation-delay: 280ms;
}

@keyframes ck-msg-blink {
    0%,
    100% {
        opacity: 0.25;
        transform: translateY(0);
    }

    50% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

.ck-msg-ctx {
    flex: 0 0 auto;
    padding: 5px 10px;
    border: 1px solid var(--ck-msg-line);
    border-radius: 9999px;
    background: var(--ck-msg-bg);
    color: var(--ck-msg-muted);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-decoration: none;
}

/* the listing the thread was opened from, kept one tap away */

.ck-msg-pinned {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px var(--ck-msg-x) 0;
    padding: 8px 10px;
    border: 1px solid var(--ck-msg-line);
    border-radius: 12px;
    background: #fff;
    color: inherit;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.ck-msg-pinned img {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: 8px;
    object-fit: cover;
    background: var(--ck-msg-bg);
}

.ck-msg-pinned span {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 2px;
}

.ck-msg-pinned strong {
    overflow: hidden;
    font-size: 13.5px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ck-msg-pinned em {
    font-size: 12px;
    font-style: normal;
    color: var(--ck-msg-muted);
}

/* the column that actually scrolls */

.ck-msg-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 6px var(--ck-msg-x) 10px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.ck-msg-older {
    display: block;
    width: 100%;
    margin: 2px auto 10px;
    padding: 8px 12px;
    border: 1px solid var(--ck-msg-line);
    border-radius: 9999px;
    background: #fff;
    color: var(--ck-msg-muted);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.ck-msg-day {
    margin: 12px 0 8px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #9a9aa1;
}

.ck-msg-bubble-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 10px;
}

.ck-msg-bubble-row.is-mine {
    justify-content: flex-end;
}

.ck-msg-bubble-row.is-theirs {
    justify-content: flex-start;
}

.ck-msg-bubble-wrap {
    display: flex;
    min-width: 0;
    max-width: min(80%, 460px);
    flex-direction: column;
    gap: 4px;
}

.ck-msg-bubble-row.is-mine .ck-msg-bubble-wrap {
    align-items: flex-end;
}

.ck-msg-quote {
    display: block;
    max-width: 100%;
    overflow: hidden;
    padding: 5px 9px;
    border-left: 3px solid var(--ck-msg-brand);
    border-radius: 6px;
    background: #fff;
    color: var(--ck-msg-muted);
    font-size: 12px;
    line-height: 1.35;
    text-decoration: none;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ck-msg-bubble {
    position: relative;
    padding: 9px 12px 6px;
    border-radius: var(--ck-msg-radius);
    background: #fff;
    border: 1px solid var(--ck-msg-line);
    color: var(--ck-msg-ink);
    font-size: 15.5px;
    line-height: 1.4;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ck-msg-bubble-row.is-mine .ck-msg-bubble {
    border-color: transparent;
    background: var(--ck-msg-self);
    color: #fff;
}

/* a shared product or order is a card, not a paragraph */

.ck-msg-bubble.is-card {
    padding: 0;
    overflow: hidden;
    background: #fff;
    border-color: var(--ck-msg-line);
    width: 100%;
    max-width: 320px;
}

.ck-msg-card-inner {
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
    color: var(--ck-msg-ink);
}

.ck-msg-card-inner img {
    grid-row: span 3;
    width: 68px;
    height: 68px;
    border-radius: 9px;
    object-fit: cover;
    background: var(--ck-msg-bg);
}

.ck-msg-card-inner p {
    margin: 0;
    overflow: hidden;
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.3;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.ck-msg-card-inner strong {
    font-size: 14px;
    color: var(--ck-msg-brand);
}

.ck-msg-card-inner em {
    font-size: 12px;
    font-style: normal;
    color: var(--ck-msg-muted);
}

.ck-msg-card-status {
    display: inline-block;
    margin-top: 2px;
    padding: 1px 7px;
    border-radius: 9999px;
    background: var(--ck-msg-bg);
    color: var(--ck-msg-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.ck-msg-card-link {
    grid-column: 2;
    justify-self: start;
    margin-top: 4px;
    padding: 4px 12px;
    border: 1px solid var(--ck-msg-brand);
    border-radius: 9999px;
    color: var(--ck-msg-brand);
    font-size: 12.5px;
    font-weight: 700;
    text-decoration: none;
}

/*
 * v4: the card is the door. A shopper taps a listing card anywhere else in the app and the listing
 * opens, so the picture and the name in a bubble now do exactly that. The Open pill stays where it
 * always was and goes to the same url; the nested grid is the card's own 68px-plus-text columns, so
 * the photo, the price and the store do not move a pixel.
 */
.ck-msg-card-hit {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 10px;
    color: inherit;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.ck-msg-card-hit:active {
    opacity: 0.7;
}

/* media: never wider than the bubble it lives in */

.ck-msg-bubble.is-media {
    padding: 0;
    overflow: hidden;
    border-color: transparent;
    background: #ddd;
}

.ck-msg-media {
    display: block;
    max-width: min(280px, 74vw);
    border-radius: var(--ck-msg-radius);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.ck-msg-media img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 360px;
    object-fit: cover;
}

video.ck-msg-media,
.ck-msg-bubble > video {
    display: block;
    width: min(280px, 74vw);
    max-height: 360px;
    border-radius: var(--ck-msg-radius);
    background: #000;
}

audio.ck-msg-voice {
    display: block;
    width: min(260px, 70vw);
    height: 40px;
}

.ck-msg-file {
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(300px, 78vw);
    padding: 10px;
    border-radius: 12px;
    background: var(--ck-msg-bg);
    color: var(--ck-msg-ink);
    text-decoration: none;
}

.ck-msg-bubble-row.is-mine .ck-msg-file {
    background: rgb(255 255 255 / 16%);
    color: #fff;
}

.ck-msg-file svg {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    opacity: 0.7;
}

.ck-msg-file span {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 1px;
}

.ck-msg-file strong {
    overflow: hidden;
    font-size: 13.5px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ck-msg-file em {
    font-size: 11.5px;
    font-style: normal;
    opacity: 0.7;
}

.ck-msg-text {
    margin: 0;
    white-space: pre-wrap;
}

.ck-msg-text + .ck-msg-file,
.ck-msg-media + .ck-msg-text,
.ck-msg-bubble > video + .ck-msg-text,
.ck-msg-voice + .ck-msg-text {
    margin-top: 6px;
}

.ck-msg-file + .ck-msg-text {
    margin-top: 6px;
}

.ck-msg-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    font-size: 10.5px;
    line-height: 1.4;
    color: #9a9aa1;
}

.ck-msg-bubble-row.is-mine .ck-msg-meta {
    color: rgb(255 255 255 / 78%);
}

.ck-msg-meta em {
    font-style: normal;
}

.ck-msg-seen.is-seen {
    color: #d6f5e4;
    font-weight: 700;
}

/* §5 reactions sit under the bubble, so a thumb never covers the words */

.ck-msg-reacts {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.ck-msg-bubble-row.is-mine .ck-msg-reacts {
    justify-content: flex-end;
}

.ck-msg-react {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border: 1px solid var(--ck-msg-line);
    border-radius: 9999px;
    background: #fff;
    color: var(--ck-msg-muted);
    font: inherit;
    font-size: 12px;
    line-height: 1.5;
    cursor: pointer;
}

.ck-msg-react.is-mine {
    border-color: var(--ck-msg-brand);
    background: color-mix(in srgb, var(--ck-msg-brand) 8%, #fff);
    color: var(--ck-msg-ink);
}

/* the tap row: reply, react, and on your own message edit and delete */

.ck-msg-tools {
    display: flex;
    align-items: center;
    gap: 2px;
    opacity: 0;
}

.ck-msg-bubble-row:hover > .ck-msg-bubble-wrap > .ck-msg-tools,
.ck-msg-bubble-row:focus-within > .ck-msg-bubble-wrap > .ck-msg-tools {
    opacity: 1;
}

.ck-msg-tools > button {
    display: flex;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 9999px;
    background: transparent;
    color: #9a9aa1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ck-msg-tools svg {
    width: 15px;
    height: 15px;
}

.ck-msg-reactpicker {
    position: relative;
}

.ck-msg-reactpicker summary {
    display: flex;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    color: #9a9aa1;
    list-style: none;
    cursor: pointer;
}

.ck-msg-reactpicker summary::-webkit-details-marker {
    display: none;
}

.ck-msg-reactpicker summary svg {
    width: 15px;
    height: 15px;
}

.ck-msg-reactrow {
    position: absolute;
    z-index: 45;
    bottom: calc(100% + 6px);
    left: 0;
    display: flex;
    gap: 2px;
    padding: 5px 7px;
    border: 1px solid var(--ck-msg-line);
    border-radius: 9999px;
    background: #fff;
    box-shadow: 0 10px 26px rgb(23 23 25 / 18%);
    white-space: nowrap;
}

.ck-msg-reactrow button {
    padding: 2px 4px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    font-size: 17px;
    line-height: 1.2;
    cursor: pointer;
}

.ck-msg-reactrow button:active {
    background: var(--ck-msg-bg);
}

/* ---------- §6 quick actions ---------- */

.ck-msg-quick {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 4px var(--ck-msg-x) 8px;
}

.ck-msg-quick::-webkit-scrollbar {
    display: none;
}

.ck-msg-quick button {
    flex: 0 0 auto;
    padding: 6px 12px;
    border: 1px solid var(--ck-msg-line);
    border-radius: 9999px;
    background: #fff;
    color: var(--ck-msg-muted);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ck-msg-quick-send {
    border-color: color-mix(in srgb, var(--ck-msg-brand) 45%, #fff) !important;
    color: var(--ck-msg-brand) !important;
}

/* ---------- the composer ---------- */

.ck-msg-composer {
    position: sticky;
    bottom: 0;
    z-index: 28;
    flex: 0 0 auto;
    padding: 8px var(--ck-msg-x);
    border-top: 1px solid var(--ck-msg-line);
    background: #fff;
}

.ck-msg-replybar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 7px;
    padding: 6px 9px;
    border-left: 3px solid var(--ck-msg-brand);
    border-radius: 8px;
    background: var(--ck-msg-bg);
    font-size: 12.5px;
    color: var(--ck-msg-muted);
}

.ck-msg-replybar.is-edit {
    border-left-color: var(--ck-msg-seal);
}

.ck-msg-replybar span {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ck-msg-replybar button {
    flex: 0 0 auto;
    padding: 0 4px;
    border: 0;
    background: transparent;
    color: var(--ck-msg-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.ck-msg-error {
    margin: 0 0 7px;
    padding: 7px 9px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--ck-msg-brand) 8%, #fff);
    color: var(--ck-msg-brand);
    font-size: 12.5px;
    font-weight: 600;
}

.ck-msg-staged {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 8px;
}

.ck-msg-staged::-webkit-scrollbar {
    display: none;
}

.ck-msg-staged-item {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    width: 66px;
    height: 66px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--ck-msg-line);
    border-radius: 10px;
    background: var(--ck-msg-bg);
    color: var(--ck-msg-muted);
    font-size: 10.5px;
    line-height: 1.2;
    text-align: center;
}

.ck-msg-staged-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ck-msg-staged-item span {
    padding: 0 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.ck-msg-staged-item button {
    position: absolute;
    top: 2px;
    right: 2px;
    display: flex;
    width: 19px;
    height: 19px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 9999px;
    background: rgb(23 23 25 / 62%);
    color: #fff;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.ck-msg-composer-row {
    display: flex;
    align-items: flex-end;
    gap: 7px;
}

.ck-msg-attach {
    display: flex;
    flex: 0 0 auto;
    gap: 1px;
}

.ck-msg-attach-btn {
    position: relative;
    display: flex;
    width: 30px;
    height: 38px;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    color: var(--ck-msg-muted);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ck-msg-attach-btn input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.ck-msg-attach-btn svg {
    width: 19px;
    height: 19px;
    pointer-events: none;
}

.ck-msg-attach-btn:active {
    background: var(--ck-msg-bg);
}

.ck-msg-input {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    max-height: 132px;
    margin: 0;
    padding: 9px 12px;
    border: 1px solid var(--ck-msg-line);
    border-radius: 16px;
    background: var(--ck-msg-bg);
    color: var(--ck-msg-ink);
    font: inherit;
    font-size: 15.5px;
    line-height: 1.35;
    overflow-y: auto;
    resize: none;
    -webkit-appearance: none;
    appearance: none;
}

.ck-msg-input:focus {
    border-color: var(--ck-msg-brand);
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 3px rgb(227 30 36 / 10%);
}

.ck-msg-input:disabled {
    opacity: 0.6;
}

.ck-msg-send {
    display: flex;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 9999px;
    background: var(--ck-msg-brand);
    color: #fff;
    cursor: pointer;
    transition: transform 140ms ease, opacity 140ms ease;
    -webkit-tap-highlight-color: transparent;
}

.ck-msg-send svg {
    width: 19px;
    height: 19px;
}

.ck-msg-send:active {
    transform: scale(0.93);
}

.ck-msg-send:disabled {
    background: #d9d9de;
    color: #fff;
    cursor: default;
}

.ck-msg-note {
    margin: 7px 0 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--ck-msg-muted);
}

/* loading: earlier rows are on their way, so the column holds the shape they will fill */

.ck-msg-skeleton {
    padding: 4px 6px 10px;
}

.ck-msg-skeleton span {
    display: block;
    height: 11px;
    margin: 0 auto 7px;
    border-radius: 6px;
    background: linear-gradient(90deg, #f0f0f2 25%, #e6e6ea 37%, #f0f0f2 63%);
    background-size: 400% 100%;
    animation: ck-msg-shimmer 1.3s infinite ease;
}

.ck-msg-skeleton span:nth-child(1) {
    width: 46%;
    height: 13px;
    margin-right: 0;
}

.ck-msg-skeleton span:nth-child(2) {
    width: 72%;
    margin-left: auto;
    margin-right: 4%;
}

.ck-msg-skeleton span:nth-child(3) {
    width: 58%;
    margin-left: 8%;
    margin-right: auto;
}

@keyframes ck-msg-shimmer {
    from {
        background-position: 100% 0;
    }

    to {
        background-position: 0 0;
    }
}

/* ---------- phone: the surface that replaces the storefront header ---------- */

@media (max-width: 1023.98px) {
    /*
     * Both messenger screens carry their own bar, so the storefront header steps out and the
     * status band is reserved by the bar itself. The bottom tab bar stays exactly where §12 wants
     * it, and the column ends above it.
     */
    .ck-appbar.ck-appbar--messenger {
        display: none;
    }

    /* a chat screen is not a landing page: the footer belongs under the shop, not under the composer */
    main.ck-msg-page + footer {
        display: none;
    }

    .ck-msg-inbox {
        min-height: calc(100vh - var(--ck-bottom-inset));
        min-height: calc(100dvh - var(--ck-bottom-inset));
    }

    .ck-msg-bar {
        padding-top: var(--ck-top-inset, 0px);
    }

    /*
     * The inbox header is four rows tall. Only the title earns a place at the top, so the bar
     * itself scrolls away and the title row carries the status band inside its own padding —
     * pinned to 0 with the inset added again on top would reserve the clock twice.
     */
    .ck-msg-inbox .ck-msg-bar {
        position: static;
        padding-top: 0;
    }

    .ck-msg-inbox .ck-msg-bar-row {
        position: sticky;
        top: 0;
        z-index: 30;
        padding-top: calc(12px + var(--ck-top-inset, 0px));
        padding-bottom: 10px;
        background: #fff;
        box-shadow: 0 1px 0 var(--ck-msg-line);
    }

    .ck-msg-thread {
        height: calc(100vh - var(--ck-bottom-inset));
        height: calc(100dvh - var(--ck-bottom-inset) - var(--ck-msg-kb, 0px));
        min-height: 0;
    }

    /* the composer stays put: the column shortens instead of the page moving */
    .ck-msg-composer {
        bottom: 0;
    }

    /*
     * Writing a message is the one moment the dock is in the way. The phone puts the keyboard into
     * the strip the tab bar owns, so while the caret is in the composer the bar steps out and the
     * composer takes that strip and sits tight against the keys — the shape every chat app has,
     * and the only arrangement that keeps what you are typing visible in a WebView that resizes
     * its whole window instead of only its viewport. It comes back the moment the keyboard does.
     */
    html[data-ck-kb="up"] .ck-tabbar {
        display: none;
    }

    html[data-ck-kb="up"] .ck-msg-thread {
        height: calc(100vh - var(--ck-msg-kb, 0px));
        height: calc(100dvh - var(--ck-msg-kb, 0px));
    }

    /* actions live in a strip under the row — full width for the words, all five still tappable */
    .ck-msg-row {
        flex-wrap: wrap;
    }

    .ck-msg-card {
        flex-basis: 100%;
        order: 1;
    }

    .ck-msg-actions {
        order: 2;
        flex-basis: 100%;
        justify-content: flex-end;
        padding: 0 var(--ck-msg-x) 8px;
        border-top: 1px solid var(--ck-msg-bg);
    }

    .ck-msg-thumb {
        display: none;
    }

    /* a tap has to reach these, so on a phone they are not hidden behind a hover */
    .ck-msg-tools {
        opacity: 0.55;
    }

    .ck-msg-bubble-row.is-theirs .ck-msg-tools {
        justify-content: flex-start;
    }

    .ck-msg-bubble-wrap {
        max-width: min(84%, 420px);
    }

    .ck-msg-labelsheet-list {
        bottom: auto;
        top: calc(100% + 2px);
        right: 0;
    }
}

/* ---------- desktop: two panes of the same page, no dvh maths ---------- */

@media (min-width: 1024px) {
    .ck-msg {
        max-width: 760px;
        margin: 22px auto 40px;
        border: 1px solid var(--ck-msg-line);
        border-radius: 16px;
        background: #fff;
        overflow: hidden;
        box-shadow: 0 10px 30px rgb(23 23 25 / 6%);
    }

    .ck-msg-list {
        padding-bottom: 8px;
    }

    .ck-msg-row {
        align-items: center;
    }

    .ck-msg-card {
        padding: 13px 16px;
    }

    .ck-msg-actions {
        position: absolute;
        right: 10px;
        bottom: auto;
        padding: 0;
        background: #fff;
        opacity: 0;
        transition: opacity 140ms ease;
    }

    .ck-msg-row:hover .ck-msg-actions,
    .ck-msg-row:focus-within .ck-msg-actions {
        opacity: 1;
    }

    .ck-msg-scroll {
        max-height: 62vh;
        padding: 10px 18px 14px;
        background: var(--ck-msg-bg);
    }

    .ck-msg-bubble-wrap {
        max-width: min(70%, 520px);
    }

    .ck-msg-tools {
        margin-top: 2px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ck-msg-typing i,
    .ck-msg-skeleton span,
    .ck-msg-send {
        animation: none;
        transition: none;
    }
}


/* ---------------------------------------------------------------------------
   The small support door that replaced the screen-blocking chat panel (§14).
   One pill in the corner of every storefront page. On a messenger page support
   is already open, so the markup hands it .is-away and it stops taking taps.
--------------------------------------------------------------------------- */

.ck-support-door {
    position: fixed;
    right: 14px;
    bottom: calc(var(--ck-bottom-inset, 0px) + 14px);
    z-index: 9985;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 14px;
    border: 1px solid var(--ck-msg-line);
    border-radius: 9999px;
    background: #fff;
    color: var(--ck-msg-ink);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.ck-support-door svg {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    color: var(--ck-msg-brand);
}

.ck-support-door:active {
    transform: scale(0.96);
}

.ck-support-door.is-away {
    opacity: 0;
    pointer-events: none;
}

@media (min-width: 1024px) {
    .ck-support-door {
        right: 24px;
        bottom: 24px;
    }
}

/* ---------------------------------------------------------------------------
   §5 the voice note. The mic button and the recording bar are drawn by the
   blade but kept shut until the page script has proved it can record: a
   browser with no microphone gets the phone's own voice door instead, which
   is the same row a reader with no script at all gets.
--------------------------------------------------------------------------- */

.ck-msg-mic,
.ck-msg-recording {
    display: none;
}

/* Only one of the two voice controls shows, and the swap is the script's doing. */
html[data-ck-voice="ready"] .ck-msg-mic {
    display: flex;
}

html[data-ck-voice="ready"] .ck-msg-voice-door {
    display: none;
}

.ck-msg-mic {
    padding: 0;
    border: 0;
    background: transparent;
    font: inherit;
    color: var(--ck-msg-muted);
    /* a long press is the gesture, so the OS must not steal it for a callout or a scroll */
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html[data-ck-rec="live"] .ck-msg-recording,
html[data-ck-rec="cancel"] .ck-msg-recording {
    display: flex;
}

.ck-msg-recording {
    align-items: center;
    gap: 8px;
    margin-bottom: 7px;
    padding: 7px 10px;
    border-radius: 10px;
    background: var(--ck-msg-bg);
    color: var(--ck-msg-ink);
    font-size: 12.5px;
}

.ck-msg-rec-dot {
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
    border-radius: 9999px;
    background: var(--ck-msg-brand);
    animation: ck-msg-rec-pulse 1s ease-in-out infinite;
}

.ck-msg-rec-time {
    flex: 0 0 auto;
    min-width: 32px;
    font-size: 13px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.ck-msg-rec-hint {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    color: var(--ck-msg-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* the bar is the cancel target, so it says so while the finger is over it */
html[data-ck-rec="cancel"] .ck-msg-recording {
    background: color-mix(in srgb, var(--ck-msg-brand) 14%, #fff);
}

html[data-ck-rec="cancel"] .ck-msg-rec-dot {
    animation: none;
}

@keyframes ck-msg-rec-pulse {
    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.25;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ck-msg-rec-dot {
        animation: none;
    }
}
