.msg-page { max-width: 1400px; margin: 0 auto; }
.msg-page-narrow { max-width: 680px; }

body:has(.msg-app) { height: 100vh; overflow: hidden; }
body:has(.msg-app) .site-footer { display: none; }
body:has(.msg-app) .page-content { display: flex; flex-direction: column; min-height: 0; overflow: hidden; padding: 1.25rem 0; }
body:has(.msg-app) .page-content > .container { display: flex; flex-direction: column; flex: 1; min-height: 0; width: 100%; }
.msg-app { display: flex; flex-direction: column; flex: 1; min-height: 0; max-width: 1400px; width: 100%; margin: 0 auto; }
.msg-app-head { margin-bottom: 0.875rem; }
.msg-app-head .c-panel-heading { align-items: center; gap: 0.625rem; }
.msg-app-head .c-panel-count { display: inline-grid; place-items: center; min-width: 1.375rem; height: 1.375rem; padding: 0 0.4375rem; line-height: 1; }

.msg-avatar {
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent-color);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.msg-avatar-lg { width: 2.5rem; height: 2.5rem; font-size: 0.875rem; }
.msg-avatar-xl { width: 3.5rem; height: 3.5rem; font-size: 1.125rem; margin-bottom: 0.75rem; }

.msg-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    flex: 1;
    min-height: 420px;
}

.msg-list {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--bg-secondary);
}
.msg-list-search { width: auto; max-width: none; margin: 0.75rem 0.75rem 0.5rem; }
.msg-list-search .c-input, .msg-list-search input.c-input { background: var(--bg-tertiary); }
.msg-list-search .c-input:focus, .msg-list-search input.c-input:focus { background: var(--bg-primary); }
.msg-list-scroll { flex: 1; overflow-y: auto; min-height: 0; padding: 0 0.5rem 0.5rem; }
.msg-list-empty { padding: 2.5rem 1.25rem; }
.msg-list-nomatch { padding: 1.5rem 1rem; text-align: center; font-size: 0.8125rem; color: var(--text-muted); }

.msg-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0.75rem;
    margin-bottom: 0.125rem;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.15s;
}
.msg-row:hover { background: var(--bg-tertiary); text-decoration: none; }
.msg-row.is-active { background: var(--bg-primary); box-shadow: var(--shadow-sm); }
.msg-row.is-loading { opacity: 0.7; }
.msg-row-body { display: flex; flex-direction: column; gap: 0.125rem; min-width: 0; flex: 1; }
.msg-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.msg-row-name { font-size: 0.875rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-row-time { flex-shrink: 0; font-size: 0.6875rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.msg-row.is-unread .msg-row-time { color: var(--accent-color); font-weight: 600; }
.msg-row-preview { font-size: 0.8125rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-row.is-unread .msg-row-preview { color: var(--text-primary); font-weight: 600; }
.msg-unread {
    align-self: center;
    flex-shrink: 0;
    min-width: 1.375rem;
    padding: 0.0625rem 0.4375rem;
    border-radius: 100px;
    background: var(--accent-color);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.msg-thread { position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg-primary); }
.msg-thread-loading {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: none;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--bg-primary) 65%, transparent);
    backdrop-filter: blur(2px);
}
.msg-thread.htmx-request .msg-thread-loading { display: flex; }
.msg-thread.htmx-request > :not(.msg-thread-loading) { opacity: 0.35; transition: opacity 0.15s; }
.msg-thread-loading-card {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1.125rem;
    border-radius: 100px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
    box-shadow: var(--shadow-md);
}
.msg-thread-loading-card .spinner { display: inline-block; width: 1rem; height: 1rem; border: 2px solid var(--bg-tertiary); border-top-color: var(--accent-color); border-radius: 50%; animation: msg-spin 0.8s linear infinite; }
.msg-thread-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    box-shadow: inset 0 -1px 0 var(--bg-tertiary);
}
.msg-thread-head .c-action-icon.msg-back { display: none; }
.msg-thread-who { flex: 1; min-width: 0; }
.msg-thread-title { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.msg-thread-name { font-size: 0.9375rem; font-weight: 650; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-thread-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.625rem; font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.0625rem; }
.msg-context-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    flex-shrink: 0;
    height: 1.375rem;
    padding: 0 0.5625rem;
    border-radius: 100px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.msg-context-pill:hover { background: var(--accent-light); color: var(--accent-color); text-decoration: none; }
.msg-context-pill i { display: block; font-size: 0.6875rem; line-height: 1; }
.msg-context-pill i::before { display: block; vertical-align: 0; }
.msg-thread-head .c-action-icon { display: inline-grid; place-items: center; width: 1.875rem; height: 1.875rem; padding: 0; }
.msg-thread-head .c-action-icon i { display: block; line-height: 1; }
.msg-thread-head .c-action-icon i::before { display: block; vertical-align: 0; }
.msg-thread-actions { position: relative; }
.msg-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.375rem);
    min-width: 170px;
    padding: 0.25rem;
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    box-shadow: var(--shadow-md), 0 0 0 1px var(--bg-tertiary);
    z-index: 20;
}
.msg-menu form { margin: 0; }
.msg-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-primary);
    font: inherit;
    font-size: 0.8125rem;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.msg-menu-item i { display: block; width: 1rem; flex-shrink: 0; font-size: 0.875rem; line-height: 1; text-align: center; }
.msg-menu-item i::before { display: block; vertical-align: 0; }
.msg-menu-item:hover { background: var(--bg-secondary); text-decoration: none; }
.msg-menu-item.is-danger { color: var(--danger); }

.msg-thread-body { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.msg-scroll { flex: 1; overflow-y: auto; padding: 1rem 1.25rem 0.5rem; min-height: 0; scroll-padding-bottom: 1rem; }
.msg-thread-empty, .msg-thread-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    height: 100%;
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}
.msg-thread-empty p, .msg-thread-placeholder p { margin: 0; }
.msg-thread-empty-title { color: var(--text-primary); font-weight: 650; font-size: 1rem; }
.msg-placeholder-icon {
    display: grid;
    place-items: center;
    width: 3.5rem;
    height: 3.5rem;
    margin-bottom: 0.75rem;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 1.5rem;
}
.msg-placeholder-icon i { display: block; line-height: 1; margin: 0; }
.msg-placeholder-icon i::before { display: block; vertical-align: 0; }
.msg-thread-placeholder .c-action { margin-top: 0.875rem; background: var(--bg-secondary); }

.msg-day {
    margin: 1rem auto 0.875rem;
    width: fit-content;
    padding: 0.125rem 0.625rem;
    border-radius: 100px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.msg-bubble-row { display: flex; flex-direction: column; margin-bottom: 0.125rem; border-radius: var(--radius-md); transition: background 0.4s; }
.msg-bubble-row.is-last { margin-bottom: 0.625rem; }
.msg-bubble-row.is-mine { align-items: flex-end; }
.msg-bubble-row.is-theirs { align-items: flex-start; }
.msg-bubble-row.is-highlighted { background: var(--accent-light); }
.msg-bubble-wrap { position: relative; max-width: min(72%, 560px); }
.msg-bubble-wrap.is-wide { max-width: min(80%, 560px); }
.msg-reply-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border: none;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 0.875rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.is-mine .msg-reply-btn { left: -2.125rem; }
.is-theirs .msg-reply-btn { right: -2.125rem; }
.msg-bubble-row:hover .msg-reply-btn, .msg-reply-btn:focus-visible { opacity: 1; }
.msg-reply-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.msg-reply-btn i { display: block; line-height: 1; }
.msg-reply-btn i::before { display: block; vertical-align: 0; }
.msg-quote {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0.625rem 0.5rem 0.875rem;
    border: none;
    border-radius: 0.75rem;
    overflow: hidden;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}
.msg-quote::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.is-mine .msg-quote { background: rgba(0, 0, 0, 0.14); }
.is-mine .msg-quote::before { background: rgba(255, 255, 255, 0.85); }
.is-mine .msg-quote:hover { background: rgba(0, 0, 0, 0.24); }
.is-theirs .msg-quote { background: var(--bg-primary); }
.is-theirs .msg-quote::before { background: var(--accent-color); }
.is-theirs .msg-quote:hover { background: var(--accent-light); }
.msg-quote-body { display: flex; flex-direction: column; gap: 0.125rem; min-width: 0; flex: 1; }
.msg-quote-name { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.01em; }
.is-theirs .msg-quote-name { color: var(--accent-color); }
.msg-quote-text { display: flex; align-items: flex-start; gap: 0.3125rem; font-size: 0.8125rem; line-height: 1.4; opacity: 0.9; }
.msg-quote-text > span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; overflow-wrap: anywhere; }
.msg-quote-text i { display: block; flex-shrink: 0; margin-top: 0.1875rem; font-size: 0.75rem; line-height: 1; }
.msg-quote-thumb { width: 2.75rem; height: 2.75rem; flex-shrink: 0; border-radius: 0.5rem; object-fit: cover; }
.msg-replybar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.25rem 0.5rem 0.5rem 0.5rem;
    padding: 0.5rem 0.5rem 0.5rem 0.625rem;
    border-radius: 1rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.msg-composer.is-focused .msg-replybar { background: var(--bg-secondary); }
.msg-replybar-icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent-color);
    font-size: 0.9375rem;
}
.msg-replybar-icon i { display: block; line-height: 1; }
.msg-replybar-icon i::before { display: block; vertical-align: 0; }
.msg-replybar-body { display: flex; flex-direction: column; gap: 0.0625rem; min-width: 0; flex: 1; cursor: pointer; }
.msg-replybar .msg-quote-name { color: var(--accent-color); font-size: 0.75rem; }
.msg-replybar .msg-quote-text { display: block; font-size: 0.8125rem; color: var(--text-secondary); opacity: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-replybar .msg-quote-thumb { width: 2.25rem; height: 2.25rem; border-radius: var(--radius-md); }
.msg-replybar-cancel { display: grid; place-items: center; flex-shrink: 0; width: 1.75rem; height: 1.75rem; padding: 0; border: none; border-radius: 50%; background: var(--bg-primary); color: var(--text-muted); font-size: 1rem; cursor: pointer; transition: background 0.15s, color 0.15s; }
.msg-replybar-cancel:hover { background: var(--accent-light); color: var(--accent-color); }
.msg-replybar-cancel i { display: block; line-height: 1; }
.msg-replybar-cancel i::before { display: block; vertical-align: 0; }
.msg-bubble {
    max-width: 100%;
    padding: 0.5rem 0.8125rem;
    border-radius: 1.125rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.is-mine .msg-bubble { background: var(--accent-color); color: #fff; }
.is-mine.is-first .msg-bubble { border-top-right-radius: 1.125rem; }
.is-mine:not(.is-first) .msg-bubble { border-top-right-radius: 0.375rem; }
.is-mine:not(.is-last) .msg-bubble { border-bottom-right-radius: 0.375rem; }
.is-theirs:not(.is-first) .msg-bubble { border-top-left-radius: 0.375rem; }
.is-theirs:not(.is-last) .msg-bubble { border-bottom-left-radius: 0.375rem; }
.msg-bubble-text { font-size: 0.875rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-link, .msg-link:hover { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.is-theirs .msg-link, .is-theirs .msg-link:hover { color: var(--accent-color); }
.msg-link:hover { text-decoration-thickness: 2px; }
.msg-more {
    display: block;
    margin-top: 0.375rem;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 700;
    opacity: 0.85;
    cursor: pointer;
}
.msg-more:hover { opacity: 1; text-decoration: underline; }
.is-theirs .msg-more { color: var(--accent-color); opacity: 1; }
.msg-bubble-time { margin: 0.1875rem 0.5rem 0; font-size: 0.625rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.msg-jump {
    position: absolute;
    left: 50%;
    bottom: 6.25rem;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.875rem;
    border: none;
    border-radius: 100px;
    background: var(--accent-color);
    color: #fff;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 650;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    z-index: 5;
}

.msg-composer {
    display: flex;
    flex-direction: column;
    margin: 0.5rem 1rem 0;
    padding: 0.375rem 0.375rem 0.375rem 0.375rem;
    border-radius: 1.375rem;
    background: var(--bg-secondary);
    transition: box-shadow 0.15s, background 0.15s;
}
.msg-composer.is-focused { background: var(--bg-primary); box-shadow: 0 0 0 1px var(--accent-color), 0 0 0 4px var(--focus-ring); }
.msg-composer.is-dragover { background: var(--accent-light); box-shadow: 0 0 0 2px var(--accent-color); }
.msg-composer-row { display: flex; align-items: flex-end; gap: 0; }
.msg-file-input { display: none; }
.msg-attach {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 2rem;
    height: 2.25rem;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.0625rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.msg-attach:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.msg-attach i { display: block; line-height: 1; }
.msg-attach i::before { display: block; vertical-align: 0; }
.msg-pending { display: flex; flex-wrap: wrap; gap: 0.375rem; padding: 0.25rem 0.5rem 0.375rem 2.25rem; }
.msg-pending-file {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    max-width: 260px;
    padding: 0.25rem 0.375rem 0.25rem 0.5rem;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    font-size: 0.75rem;
    color: var(--text-primary);
}
.msg-pending-file img { width: 1.75rem; height: 1.75rem; border-radius: var(--radius-sm); object-fit: cover; }
.msg-pending-file > i { display: block; font-size: 1rem; color: var(--text-secondary); line-height: 1; }
.msg-pending-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.msg-pending-size { flex-shrink: 0; color: var(--text-muted); font-size: 0.6875rem; }
.msg-pending-remove { display: grid; place-items: center; flex-shrink: 0; width: 1.25rem; height: 1.25rem; padding: 0; border: none; border-radius: 50%; background: transparent; color: var(--text-muted); font-size: 1rem; line-height: 1; cursor: pointer; }
.msg-pending-remove i { display: block; line-height: 1; }
.msg-pending-remove i::before { display: block; vertical-align: 0; }
.msg-pending-remove:hover { background: var(--bg-primary); color: var(--danger); }

.msg-attachments { display: flex; flex-direction: column; gap: 0.375rem; }
.msg-attachments + .msg-bubble-text { margin-top: 0.625rem; }
.msg-bubble.has-attachments { padding-top: 0.375rem; }
.msg-bubble.has-quote { padding-top: 0.375rem; }
.msg-quote + .msg-attachments { margin-top: 0; }
.msg-attachment, .msg-attachment:hover, .msg-attachment:focus { display: block; color: inherit; text-decoration: none; }
.is-mine .msg-attachment, .is-mine .msg-attachment:hover { color: #fff; }
.msg-gallery { display: grid; gap: 3px; width: 320px; max-width: 100%; border-radius: 0.75rem; overflow: hidden; }
.msg-gallery.n1 { display: block; width: auto; }
.msg-gallery.n2, .msg-gallery.n3, .msg-gallery.n4 { grid-template-columns: 1fr 1fr; }
.msg-tile { position: relative; display: block; padding: 0; border: none; background: var(--bg-primary); cursor: zoom-in; overflow: hidden; }
.msg-gallery.n1 .msg-tile { border-radius: 0.75rem; }
.msg-gallery.n1 .msg-tile img { display: block; max-width: 320px; max-height: 260px; width: auto; height: auto; }
.msg-gallery.n2 .msg-tile, .msg-gallery.n3 .msg-tile, .msg-gallery.n4 .msg-tile { aspect-ratio: 1; }
.msg-gallery.n3 .msg-tile:first-child { grid-column: 1 / -1; aspect-ratio: 2 / 1; }
.msg-gallery.n2 .msg-tile img, .msg-gallery.n3 .msg-tile img, .msg-gallery.n4 .msg-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.msg-tile:hover img { filter: brightness(1.05); }
.msg-tile-more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.5); color: #fff; font-size: 1.25rem; font-weight: 700; }
.msg-file {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    min-width: 220px;
    padding: 0.5rem 0.625rem;
    border-radius: 0.75rem;
    background: rgba(0, 0, 0, 0.14);
    transition: background 0.15s;
}
.is-theirs .msg-file { background: var(--bg-primary); }
.msg-file-icon { display: grid; place-items: center; flex-shrink: 0; width: 2.25rem; height: 2.25rem; border-radius: var(--radius-md); background: rgba(255, 255, 255, 0.22); font-size: 1.125rem; }
.is-theirs .msg-file-icon { background: var(--accent-light); color: var(--accent-color); }
.msg-file-icon i, .msg-file-dl { display: block; line-height: 1; }
.msg-file-body { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 0.0625rem; }
.msg-file-name { font-size: 0.8125rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-file-size { font-size: 0.6875rem; opacity: 0.75; }
.msg-file-dl { flex-shrink: 0; font-size: 0.9375rem; opacity: 0.8; }
.is-mine .msg-attachment:hover .msg-file { background: rgba(0, 0, 0, 0.24); }
.is-theirs .msg-attachment:hover .msg-file { background: var(--accent-light); }

.msg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4.5rem 4.5rem 5rem;
    background: rgba(0, 0, 0, 0.88);
    cursor: zoom-out;
}
.msg-lightbox-stage { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; overflow: hidden; touch-action: none; }
.msg-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    cursor: zoom-in;
    user-select: none;
    transform-origin: center center;
    transition: transform 0.15s ease-out;
    will-change: transform;
}
.msg-lightbox-img.is-zoomed { cursor: grab; }
.msg-lightbox-img.is-dragging { cursor: grabbing; transition: none; }
.msg-lightbox-count { font-size: 0.75rem; opacity: 0.8; flex-shrink: 0; font-variant-numeric: tabular-nums; padding-left: 0.25rem; }
.msg-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
    z-index: 2;
    transition: background 0.15s;
}
.msg-lightbox-nav:hover { background: rgba(255, 255, 255, 0.28); }
.msg-lightbox-nav.is-prev { left: 1.25rem; }
.msg-lightbox-nav.is-next { right: 1.25rem; }
.msg-lightbox-nav i { display: block; line-height: 1; }
.msg-lightbox-nav i::before { display: block; vertical-align: 0; }
.msg-lightbox-strip { position: absolute; bottom: 0.875rem; left: 0; right: 0; display: flex; justify-content: center; gap: 0.375rem; padding: 0 1rem; pointer-events: none; }
.msg-lightbox-strip-more { align-self: center; padding: 0 0.375rem; color: rgba(255, 255, 255, 0.7); font-size: 0.75rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.msg-lightbox-thumb { width: 3rem; height: 3rem; padding: 0; border: 2px solid transparent; border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.1); overflow: hidden; cursor: pointer; opacity: 0.6; pointer-events: auto; transition: opacity 0.15s, border-color 0.15s; }
.msg-lightbox-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.msg-lightbox-thumb:hover { opacity: 0.9; }
.msg-lightbox-thumb.is-current { opacity: 1; border-color: #fff; }
.msg-lightbox-hint { position: absolute; bottom: 1rem; left: 0; right: 0; margin: 0; text-align: center; font-size: 0.75rem; color: rgba(255, 255, 255, 0.55); pointer-events: none; }
.msg-lightbox-zoom { display: inline-flex; align-items: center; gap: 0.125rem; margin-right: 0.25rem; padding: 0 0.125rem; border-radius: 100px; background: rgba(255, 255, 255, 0.08); }
.msg-lightbox-zoom .msg-lightbox-btn { background: transparent; }
.msg-lightbox-zoom .msg-lightbox-btn:hover { background: rgba(255, 255, 255, 0.18); }
.msg-lightbox-zoom-value { min-width: 3.25rem; border: none; background: none; color: #fff; font: inherit; font-size: 0.75rem; font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer; }
.msg-lightbox-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    color: #fff;
    cursor: default;
}
.msg-lightbox-caption { display: flex; align-items: baseline; gap: 0.625rem; min-width: 0; }
.msg-lightbox-name { font-size: 0.9375rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-lightbox-size { font-size: 0.75rem; opacity: 0.7; flex-shrink: 0; }
.msg-lightbox-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.msg-lightbox-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    height: 2.25rem;
    padding: 0 0.875rem;
    border: none;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
}
.msg-lightbox-btn:hover { background: rgba(255, 255, 255, 0.26); color: #fff; text-decoration: none; }
.msg-lightbox-btn i { display: block; line-height: 1; font-size: 0.9375rem; }
.msg-lightbox-btn i::before { display: block; vertical-align: 0; }
.msg-lightbox-iconbtn { width: 2.25rem; padding: 0; justify-content: center; }
.msg-lightbox-btn:disabled { opacity: 0.35; cursor: default; }
textarea.msg-input {
    flex: 1;
    width: 100%;
    min-height: 0;
    padding: 0.5rem 0.625rem 0.5rem 0.25rem;
    font: inherit;
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--text-primary);
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    resize: none;
    max-height: 180px;
}
textarea.msg-input::placeholder { color: var(--text-muted); }
textarea.msg-input:focus { outline: none; border: none; box-shadow: none; }
.msg-send {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    border-radius: 50%;
    background: var(--accent-color);
    color: #fff;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s, transform 0.1s;
}
.msg-send:hover { background: var(--accent-hover); }
.msg-send:active { transform: scale(0.95); }
.msg-send:disabled { opacity: 0.35; cursor: default; transform: none; }
.msg-composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 1.75rem; padding: 0.25rem 1.5rem 0.625rem; font-size: 0.6875rem; color: var(--text-muted); }
.msg-hint kbd { padding: 0 0.3125rem; border-radius: 4px; background: var(--bg-tertiary); color: var(--text-secondary); font-family: inherit; font-size: 0.625rem; }
.msg-counter { font-variant-numeric: tabular-nums; }
.msg-error { color: var(--danger); font-size: 0.75rem; }
.msg-composer-locked { display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin: 0.5rem 1rem 1rem; padding: 0.75rem 1rem; border-radius: var(--radius-md); background: var(--bg-secondary); color: var(--text-muted); font-size: 0.8125rem; line-height: 1.4; text-align: center; }
.msg-composer-locked i { display: block; flex-shrink: 0; font-size: 0.9375rem; line-height: 1; }
.msg-composer-locked i::before { display: block; vertical-align: 0; }

.msg-people-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 1rem; align-items: start; }
.msg-events { padding: 0.5rem; }
.msg-section-label {
    padding: 0.625rem 0.75rem 0.375rem;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}
.msg-event {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.15s;
}
.msg-event:hover { background: var(--bg-tertiary); text-decoration: none; }
.msg-event.is-active { background: var(--bg-primary); box-shadow: var(--shadow-sm); }
.msg-event-title { font-size: 0.875rem; font-weight: 600; }
.msg-event-date { font-size: 0.75rem; color: var(--text-muted); }

.msg-confirm { max-width: 400px; width: min(400px, 92vw); padding: 1.75rem 1.5rem 1.5rem; text-align: center; }
.msg-confirm-icon {
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    margin: 0 auto 0.875rem;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
    font-size: 1.375rem;
}
.msg-confirm-icon i { display: block; line-height: 1; }
.msg-confirm-icon i::before { display: block; vertical-align: 0; }
.msg-confirm-title { margin: 0 0 0.5rem; font-size: 1.125rem; font-weight: 700; color: var(--text-primary); }
.msg-confirm-text { margin: 0 0 1.5rem; font-size: 0.875rem; line-height: 1.55; color: var(--text-secondary); }
.msg-confirm-actions { display: flex; justify-content: center; gap: 0.625rem; }
.msg-confirm-actions .btn { min-width: 7rem; justify-content: center; }
.msg-modal { max-width: 760px; width: min(760px, 94vw); padding: 0; overflow: hidden; }
.msg-modal.msg-modal-sm { max-width: 520px; width: min(520px, 94vw); }
.msg-new-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    height: 2.375rem;
    padding: 0 1.125rem 0 0.9375rem;
    border: none;
    border-radius: var(--radius-md);
    background: var(--accent-color);
    color: #fff;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.msg-new-btn:hover { background: var(--accent-hover); box-shadow: var(--shadow-md); }
.msg-new-btn:active { transform: translateY(1px); box-shadow: var(--shadow-sm); }
.msg-new-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.msg-new-btn i { display: block; font-size: 1rem; line-height: 1; }
.msg-new-btn i::before { display: block; vertical-align: 0; }
.msg-head-icon { display: inline-grid; place-items: center; width: 2.375rem; height: 2.375rem; padding: 0; border-radius: var(--radius-md); font-size: 1rem; }
.msg-head-icon i { display: block; line-height: 1; }
.msg-head-icon i::before { display: block; vertical-align: 0; }
.msg-modal .modal-header { padding: 1rem 1.25rem 0.75rem; }
.msg-modal-body { display: flex; flex-direction: column; max-height: min(70vh, 640px); overflow: hidden; }
.msg-modal-loading .spinner { display: inline-block; width: 1.125rem; height: 1.125rem; border: 2px solid var(--bg-tertiary); border-top-color: var(--accent-color); border-radius: 50%; animation: msg-spin 0.8s linear infinite; }
@keyframes msg-spin { to { transform: rotate(360deg); } }
.msg-modal-loading { display: flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 3rem 1rem; color: var(--text-muted); font-size: 0.875rem; }
.msg-picker { display: flex; flex-direction: column; min-height: 0; max-height: min(70vh, 640px); }
.msg-picker .msg-people-list { flex: 1; overflow-y: auto; min-height: 0; }
.msg-picker-status { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 1.25rem; }
.msg-picker-count { font-size: 0.75rem; color: var(--text-muted); }
.msg-picker-progress { display: inline-flex; align-items: center; gap: 0.375rem; font-size: 0.75rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.msg-picker-progress .spinner, .msg-people-loading .spinner { display: inline-block; width: 0.875rem; height: 0.875rem; border: 2px solid var(--bg-tertiary); border-top-color: var(--accent-color); border-radius: 50%; animation: msg-spin 0.8s linear infinite; }
.msg-picker-bar { height: 3px; margin: 0.25rem -1rem -0.75rem; background: var(--bg-tertiary); overflow: hidden; }
.msg-picker-bar > span { display: block; height: 100%; background: var(--accent-color); transition: width 0.25s ease-out; }
.msg-people-loading { display: flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 2.5rem 1rem; color: var(--text-muted); font-size: 0.875rem; }
.msg-people-toolbar { display: flex; flex-direction: column; gap: 0.75rem; padding: 1rem 1rem 0.75rem; box-shadow: inset 0 -1px 0 var(--bg-tertiary); }
.msg-people-search { margin: 0; max-width: none; }
.msg-people-search .c-input, .msg-people-search input.c-input { padding: 0.625rem 0.875rem 0.625rem 2.375rem; font-size: 0.9375rem; border-radius: var(--radius-md); }
.msg-people-controls { display: flex; align-items: stretch; gap: 0.5rem; }
.msg-people-controls .msg-people-search { flex: 1; }
.msg-event-picker { position: relative; flex-shrink: 0; }
.msg-event-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    height: 100%;
    max-width: 240px;
    padding: 0 0.875rem;
    border: none;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.msg-event-btn:hover { color: var(--text-primary); }
.msg-event-btn.is-set { background: var(--accent-light); color: var(--accent-color); }
.msg-event-btn i { display: block; line-height: 1; font-size: 0.8125rem; }
.msg-event-btn i::before { display: block; vertical-align: 0; }
.msg-event-btn-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-event-btn-caret { font-size: 0.625rem; opacity: 0.7; }
.msg-event-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.375rem);
    width: 320px;
    max-width: 90vw;
    padding: 0.375rem;
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    box-shadow: var(--shadow-md), 0 0 0 1px var(--bg-tertiary);
    z-index: 30;
}
.msg-event-menu-filter { position: relative; display: flex; align-items: center; margin-bottom: 0.375rem; }
.msg-event-menu-filter i { position: absolute; left: 0.625rem; font-size: 0.75rem; color: var(--text-muted); pointer-events: none; }
.msg-event-menu-filter input {
    width: 100%;
    padding: 0.4375rem 0.75rem 0.4375rem 1.875rem;
    font: inherit;
    font-size: 0.8125rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
}
.msg-event-menu-filter input:focus { outline: none; border-color: var(--accent-color); background: var(--bg-primary); }
.msg-event-menu-list { max-height: 300px; overflow-y: auto; }
.msg-event-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    padding: 0.5rem 0.625rem;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-primary);
    font: inherit;
    font-size: 0.8125rem;
    text-align: left;
    cursor: pointer;
}
.msg-event-option:hover { background: var(--bg-secondary); }
.msg-event-option.is-active { color: var(--accent-color); font-weight: 600; }
.msg-event-option > span { display: flex; flex-direction: column; gap: 0.0625rem; min-width: 0; }
.msg-event-option-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-event-option-date { font-size: 0.6875rem; font-weight: 400; color: var(--text-muted); }
.msg-event-option i { display: block; flex-shrink: 0; line-height: 1; }
.msg-event-option i::before { display: block; vertical-align: 0; }
.msg-person-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 0.125rem 0.625rem; font-size: 0.75rem; color: var(--text-secondary); }
.msg-person-event { display: inline-flex; align-items: center; gap: 0.3125rem; color: var(--text-muted); }
.msg-person-event i { display: block; font-size: 0.6875rem; line-height: 1; }
.msg-person-event i::before { display: block; vertical-align: 0; }
.msg-people-nomatch { padding: 2.5rem 1rem; }

.msg-people-search .c-input, .msg-people-search input.c-input { background: var(--bg-tertiary); }
.msg-people-search .c-input:focus, .msg-people-search input.c-input:focus { background: var(--bg-primary); }
.msg-people-list { padding: 0 0.5rem 0.5rem; }
.msg-person {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-md);
    box-shadow: inset 0 -1px 0 var(--bg-tertiary);
}
.msg-person:last-child { box-shadow: none; }
.msg-person-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.0625rem; }
.msg-person-name { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.msg-person-company { font-size: 0.75rem; color: var(--text-secondary); }

.msg-compose { padding: 1.25rem; }
.msg-compose-to { display: flex; align-items: center; gap: 0.75rem; padding-bottom: 1rem; margin-bottom: 1rem; box-shadow: inset 0 -1px 0 var(--bg-tertiary); }
.msg-compose form { margin: 0; }
textarea.msg-compose-input { background: var(--bg-primary); min-height: 8rem; max-height: none; padding: 0.75rem 0.875rem; border: 1px solid transparent; border-radius: var(--radius-md); transition: border-color 0.15s, box-shadow 0.15s; }
textarea.msg-compose-input:focus { border-color: var(--accent-color); box-shadow: 0 0 0 3px var(--focus-ring); }
.msg-compose-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 0.875rem; }
.msg-compose-hint { font-size: 0.75rem; color: var(--text-muted); }

.msg-prefs { margin: 0; padding: 0 1.25rem 1rem; }
.msg-pref { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; padding: 1rem 0; box-shadow: inset 0 -1px 0 var(--bg-tertiary); cursor: pointer; }
.msg-pref-body { display: flex; flex-direction: column; gap: 0.125rem; }
.msg-pref-title { font-size: 0.9375rem; font-weight: 600; color: var(--text-primary); }
.msg-pref-desc { font-size: 0.8125rem; color: var(--text-secondary); line-height: 1.5; }
.msg-switch { position: relative; display: inline-block; flex-shrink: 0; width: 2.5rem; height: 1.5rem; }
.msg-switch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.msg-switch-track { position: absolute; inset: 0; border-radius: 100px; background: var(--bg-tertiary); transition: background 0.15s; }
.msg-switch-track::after { content: ""; position: absolute; top: 0.1875rem; left: 0.1875rem; width: 1.125rem; height: 1.125rem; border-radius: 50%; background: var(--bg-primary); box-shadow: var(--shadow-sm); transition: transform 0.15s; }
.msg-switch input:checked + .msg-switch-track { background: var(--accent-color); }
.msg-switch input:checked + .msg-switch-track::after { transform: translateX(1rem); }
.msg-switch input:focus-visible + .msg-switch-track { box-shadow: 0 0 0 3px var(--focus-ring); }
.msg-prefs-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 0.875rem; }
.msg-prefs-status { display: inline-flex; align-items: center; gap: 0.375rem; font-size: 0.75rem; color: var(--text-muted); }
.msg-prefs-status.is-saved { color: var(--accent-color); font-weight: 600; }
.msg-prefs-status i { display: block; line-height: 1; }
.msg-prefs-status i::before { display: block; vertical-align: 0; }

.nav-badge[hidden] { display: none; }
.nav-badge {
    display: inline-grid;
    place-items: center;
    min-width: 1.125rem;
    height: 1.125rem;
    padding: 0 0.3125rem;
    border-radius: 100px;
    background: var(--accent-color);
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 860px) {
    .msg-layout { grid-template-columns: 1fr; }
    .msg-app.has-thread .msg-list { display: none; }
    .msg-app:not(.has-thread) .msg-thread { display: none; }
    .msg-thread-head .c-action-icon.msg-back { display: inline-grid; }
    .msg-bubble-wrap, .msg-bubble-wrap.is-wide { max-width: 85%; }
    .msg-reply-btn { opacity: 1; }
    .msg-hint { display: none; }
    .msg-people-layout { grid-template-columns: 1fr; }
    body:has(.msg-app) .page-content { padding: 0.75rem 0; }
}
