/* Chat na webu (stránka /Messages) – mobile first. Vzhled odpovídá chatu v mobilní aplikaci:
   plné bubliny (moje v primární barvě s bílým textem, cizí světle šedé), čas a fajfky vpravo dole
   v bublině, akce v plovoucí liště nad bublinou, vstupní lišta 📎 / emoji / pole / kulaté Odeslat. */

:root {
    --chat-mine-bg: var(--primary-color);
    --chat-mine-text: #fff;
    --chat-theirs-bg: #eceef2;
    --chat-theirs-text: #1f1f1f;
    --chat-canvas: #f6f7fa;
    --chat-radius: 18px;
    /* Výška seznamu zpráv = výška okna minus hlavička webu, hlavička karty a vstupní lišta – jen záloha pro
       stav bez JavaScriptu; za běhu měří chat.js skutečný horní okraj stránky chatu a nastaví
       --chat-card-height (třída chat-fit na <html>), takže karta konverzace vyplní okno až ke spodnímu okraji. */
    --chat-messages-height: max(300px, calc(100dvh - 250px));
}

/* Karta konverzace i seznam konverzací vyplní okno na výšku (chat.js změří horní okraj a nastaví výšku);
   seznam zpráv roste podle zbytku místa a vstupní lišta s přílohami ho jen zkracuje. */
html.chat-fit .chat-conv-card,
html.chat-fit .chat-list-card {
    height: var(--chat-card-height);
}

html.chat-fit .chat-conv-card {
    display: flex;
    flex-direction: column;
}

html.chat-fit .chat-conv-card > .card-header {
    flex-shrink: 0;
}

html.chat-fit .chat-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

html.chat-fit .messages-container {
    height: auto;
    flex: 1 1 auto;
    min-height: 0;
}

html.chat-fit .chat-list-card {
    display: flex;
    flex-direction: column;
}

html.chat-fit .chat-list-card > .list-group {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

/* ---------- Rozvržení stránky ---------- */

.message-page-container {
    display: flex;
    flex-direction: column;
}

/* Telefon: buď seznam konverzací, nebo otevřená konverzace (jako v appce). */
.message-conversation-section {
    display: none;
}

.message-page-container.has-open .message-conversation-section {
    display: block;
}

.message-page-container.has-open .message-friends-section {
    display: none;
}

@media (min-width: 768px) {
    .message-page-container {
        flex-direction: row;
    }

    .message-friends-section,
    .message-page-container.has-open .message-friends-section {
        display: block;
        padding-right: 10px;
    }

    .message-conversation-section {
        display: block;
    }

    :root {
        --chat-messages-height: clamp(360px, calc(100dvh - 300px), 760px);
    }
}

/* ---------- Seznam konverzací ---------- */

.chat-list-card .card-header h5 {
    min-width: 0;
}

.chat-new-btn {
    flex-shrink: 0;
    height: auto;
    min-height: 32px;
    white-space: nowrap;
}

.chat-list-card .list-group-item {
    padding: 0.55rem 0.9rem;
}

.chat-list-name {
    min-width: 0;
}

.selected-friend {
    border-left: 3px solid var(--primary-color) !important;
    background-color: var(--light-primary-color-ultra-light);
}

.chat-avatar-wrap {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

/* Tečka přítomnosti v pravém dolním rohu avatara; offline = nenápadná šedá. */
.chat-avatar-wrap .presence-dot {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background-color: #c4c4c4;
    border: 2px solid #fff;
}

.chat-avatar-wrap .presence-dot.online {
    background-color: #2ecc71;
}

.chat-group-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--secondary-color);
    color: var(--primary-color);
    font-size: 1.05rem;
}

/* ---------- Karta konverzace ---------- */

.chat-conv-card {
    position: relative;
    overflow: hidden;
}

.chat-conv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0.5rem 0.75rem;
    background: #fff;
}

.chat-conv-title {
    min-width: 0;
    flex: 1 1 auto;
}

.chat-conv-title h5 {
    font-size: 1.1rem;
    min-width: 0;
}

.chat-conv-tools {
    flex-shrink: 0;
}

.chat-conv-tools .btn {
    height: auto;
    min-height: 32px;
}

/* ---------- Panel členů skupiny ---------- */

/* Boční panel přes kartu konverzace: na počítači vpravo, na telefonu přes celou šířku (jedno pravidlo
   šířky, žádný breakpoint). Roluje jen seznam členů – hlavička s přidáním člena a patička s odchodem
   zůstávají vidět při libovolném počtu členů i na nízkém okně. Karta má overflow:hidden, panel se ořízne
   do jejích rohů. */
.group-panel-backdrop {
    position: absolute;
    inset: 0;
    z-index: 9;
    background: rgba(0, 0, 0, 0.25);
}

.group-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    width: min(380px, 100%);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.08);
    animation: group-panel-in 0.18s ease-out;
}

@keyframes group-panel-in {
    from {
        transform: translateX(24px);
        opacity: 0;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .group-panel {
        animation: none;
    }
}

.group-panel .btn {
    height: auto;
    min-height: 32px;
    white-space: normal;
}

.group-panel-head,
.group-panel-foot {
    flex-shrink: 0;
    padding: 0.75rem 0.9rem;
}

.group-panel-head {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.group-panel-foot {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.group-panel-title {
    min-width: 0;
}

.group-panel-head .chat-icon-btn {
    width: 36px;
    height: 36px;
    font-size: 1.05rem;
}

.group-panel-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    margin: 0;
    padding: 0.25rem 0.9rem;
    list-style: none;
}

.group-panel-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 44px;
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.group-panel-list li:last-child {
    border-bottom: 0;
}

.group-member-name {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Odebrání člena: nenápadný křížek, červený až při najetí / fokusu (potvrzení zůstává). */
.group-member-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #9aa0a6;
}

.group-member-remove:hover,
.group-member-remove:focus-visible {
    color: #dc3545;
    background: rgba(220, 53, 69, 0.08);
}

.chat-body {
    padding: 0;
    background: var(--chat-canvas);
}

.messages-container {
    height: var(--chat-messages-height);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    /* Nahoře víc místa – plovoucí lišta akcí první zprávy nesmí vyjet mimo kontejner. */
    padding: 1.6rem 0.75rem 0.75rem;
}

@media (min-width: 768px) {
    .messages-container {
        padding: 1.6rem 1.25rem 1rem;
    }
}

/* Systémová zpráva skupiny – šedý štítek uprostřed. */
.chat-system-row {
    text-align: center;
    margin: 0.4rem 0 0.9rem;
    font-size: 0.8rem;
    color: #6c757d;
}

.chat-system-row span {
    display: inline-block;
    max-width: 90%;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    padding: 3px 10px;
    overflow-wrap: anywhere;
}

/* Oddělovač „Nepřečtené zprávy" nad první zprávou nepřečtenou při otevření konverzace (jako v aplikaci). */
.chat-unread-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0.4rem 0 0.9rem;
    font-size: 0.75rem;
    color: #6a6a6a;
}

.chat-unread-divider::before,
.chat-unread-divider::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: #c8c8c8;
}

/* ---------- Zpráva ---------- */

/* Řádek = bublina + lišta akcí + reakce/panely. Zarovnání vlevo (cizí) / vpravo (moje). */
.message-row {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 100%;
    margin-bottom: 0.9rem;
}

.message-row.mine {
    align-items: flex-end;
}

.message {
    position: relative;
    max-width: min(82%, 560px);
    min-width: 0;
    padding: 0.5rem 0.75rem 0.35rem;
    border-radius: var(--chat-radius);
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.4;
    cursor: default;
}

@media (min-width: 992px) {
    .message {
        max-width: min(70%, 560px);
    }
}

.message-received {
    background-color: var(--chat-theirs-bg);
    color: var(--chat-theirs-text);
    border-bottom-left-radius: 6px;
}

.message-sent {
    background-color: var(--chat-mine-bg);
    color: var(--chat-mine-text);
    border-bottom-right-radius: 6px;
}

/* Odkazy v textu bubliny – na primární barvě bílé a podtržené. */
.message-sent .message-content a {
    color: #fff;
    text-decoration: underline;
}

.message-content {
    white-space: pre-wrap; /* zachovává odřádkování */
}

.message-content img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
}

/* Bublina jen s přílohou – tenký rámeček kolem náhledu. */
.message-media-only {
    padding: 4px 4px 0.3rem;
}

.message-media-only .message-meta {
    padding: 0 0.5rem;
}

/* Anketa má vlastní bílou kartu – bublina kolem ní jen úzký lem. */
.message-poll {
    padding: 4px 4px 0.3rem;
}

.message-poll .message-meta {
    padding: 0 0.5rem;
}

/* Karta ankety vyplní bublinu pevné šířky – na telefonu nesmí přetéct přes její okraj. */
.message.message-poll {
    width: min(360px, 82%);
}

.message-poll .poll-card {
    min-width: 0;
    width: 100%;
}

.message-sender {
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.message-sender a {
    color: inherit;
    text-decoration: none;
}

/* Čas, příznaky a fajfky – vpravo dole, při nedostatku místa se zalomí (nic nepřeteče z bubliny).
   Tlumí se jednotlivé položky, ne celý řádek – průhlednost rodiče by ztlumila i fajfky „přečteno". */
.message-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    column-gap: 6px;
    row-gap: 0;
    margin-top: 2px;
    font-size: 0.7rem;
    line-height: 1.5;
    white-space: nowrap;
}

.message-meta > * {
    opacity: 0.75;
}

.message-time {
    font-size: inherit;
}

.message-flag {
    font-size: inherit;
    font-style: italic;
}

.message-flag-btn {
    border: none;
    background: none;
    padding: 0;
    color: inherit;
    cursor: pointer;
    text-decoration: underline dotted;
}

.message-status {
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

.message-status i {
    font-size: 0.95rem;
}

/* Přečteno – fajfky naplno ve světle mátové a mírně zesílené: odstínem se liší od bílých fajfek
   „doručeno" a na modré bublině mají kontrast přes 3 : 1. */
.message-meta > .message-status.is-read {
    color: #8affc1;
    opacity: 1;
}

.message-status.is-read i {
    -webkit-text-stroke: 0.4px currentColor;
}

/* ---------- Citace (reply) ---------- */

.message-reply-quote {
    border-left: 3px solid var(--primary-color);
    padding: 3px 8px;
    margin: 2px 0 5px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    font-size: 0.82rem;
    line-height: 1.25;
    max-width: 100%;
    overflow: hidden;
}

.message-sent .message-reply-quote {
    border-left-color: rgba(255, 255, 255, 0.85);
    background-color: rgba(255, 255, 255, 0.16);
}

.message-reply-quote .reply-quote-author {
    display: block;
    font-weight: 600;
    color: var(--primary-color);
}

.message-sent .message-reply-quote .reply-quote-author {
    color: #fff;
}

.message-reply-quote .reply-quote-text {
    display: block;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-reply-quote.unavailable {
    font-style: italic;
    opacity: 0.7;
}

/* ---------- Přílohy ---------- */

.message-media {
    margin-bottom: 2px;
}

/* Náhled fotky a videa: rozumná velikost na počítači, na telefonu do šířky bubliny. */
.chat-media-image,
.chat-media-video {
    display: block;
    width: auto;
    max-width: min(320px, 64vw);
    max-height: 340px;
    border-radius: 14px;
    background: #1a1a24;
}

.chat-media-image {
    cursor: zoom-in;
    object-fit: cover;
}

.chat-media-video {
    width: min(320px, 64vw);
}

.chat-media-audio {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-media-audio audio {
    max-width: min(240px, 58vw);
    height: 36px;
}

/* Karta souboru: ikona podle přípony, název (ořez), ikona stažení. */
.chat-file {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    max-width: min(300px, 64vw);
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.75);
    color: inherit;
    text-decoration: none;
}

.message-sent .chat-file {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.chat-file:hover {
    color: inherit;
    filter: brightness(0.97);
}

.chat-file-icon {
    font-size: 1.7rem;
    flex-shrink: 0;
}

.chat-file-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.chat-file-download {
    flex-shrink: 0;
    opacity: 0.7;
}

.chat-media-expired {
    padding: 10px;
    border: 1px dashed currentColor;
    border-radius: 10px;
    font-size: 0.85rem;
    opacity: 0.7;
}

.chat-media-expiry {
    font-style: normal;
    margin-right: auto; /* platnost vlevo, čas a fajfky vpravo */
}

/* ---------- Plovoucí lišta akcí ---------- */

.message-toolbar {
    position: absolute;
    top: -1.35rem;
    left: 0.25rem;
    z-index: 2;
    display: none;
    align-items: center;
    gap: 1px;
    padding: 2px 4px;
    background: #fff;
    border: 1px solid #e1e4ea;
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.message-row.mine .message-toolbar {
    left: auto;
    right: 0.25rem;
}

/* Dotykový displej: lišta po klepnutí na bublinu. Počítač: i při najetí myší. */
.message-row.is-active .message-toolbar {
    display: inline-flex;
}

@media (hover: hover) {
    .message-row:hover .message-toolbar {
        display: inline-flex;
    }
}

.message-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: none;
    color: #5f6570;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
}

.message-action-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #1f1f1f;
}

.message-action-btn i {
    font-size: 0.95rem;
}

.message-delete-btn:hover {
    color: #dc3545;
}

/* ---------- Reakce ---------- */

/* Pilulky reakcí přesahují spodní okraj bubliny (jako v appce). */
.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: -8px;
    padding: 0 10px;
    position: relative;
    z-index: 1;
}

/* Pilulka = tlačítko „emoji + počet" (klik přepne moji reakci); vlastní reakce zvýrazněná. */
.reaction-pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #fff;
    border: 1px solid #d9dce2;
    border-radius: 12px;
    padding: 0 7px;
    font: inherit;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #495057;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    /* Podržení otevírá seznam jmen – bez systémové nabídky a výběru textu. */
    -webkit-touch-callout: none;
    user-select: none;
    touch-action: manipulation;
}

.reaction-pill:hover {
    border-color: #b9bfc9;
}

.reaction-pill.mine {
    border-color: var(--primary-color);
    background: var(--light-primary-color-ultra-light);
    color: var(--primary-color);
}

.reaction-pill.readonly {
    cursor: default;
}

.reaction-count {
    font-size: 0.78rem;
    font-weight: 600;
}

/* Kdo reagoval: bublina NAD pilulkou. Zobrazuje ji najetí myší (jen zařízení s hoverem) nebo třída
   is-open po podržení (dotyk). U vlastních bublin (vpravo) je zarovnaná k pravému okraji, aby nepřetekla.
   U úplně první načtené zprávy ji může oříznout horní okraj .messages-container (overflow:auto) –
   varianta pod pilulkou by naopak ořezávala u nejnovější zprávy, na kterou se najíždí nejčastěji. */
.reaction-popover {
    display: none;
    position: absolute;
    left: 0;
    bottom: calc(100% + 6px);
    z-index: 5;
    min-width: 120px;
    max-width: 260px;
    width: max-content;
    padding: 6px 10px;
    background: #212529;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.35;
    text-align: left;
    white-space: normal;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
    pointer-events: none;
}

.message-row.mine .reaction-popover {
    left: auto;
    right: 0;
}

@media (hover: hover) {
    .reaction-pill:hover .reaction-popover {
        display: block;
    }
}

.reaction-pill.is-open .reaction-popover {
    display: block;
}

/* Výběr rychlých emoji a panel nahlášení jsou záměrně v NORMÁLNÍM TOKU (ne position:absolute):
   absolutně pozicované by je .messages-container (overflow:auto) u vysokých bublin ořízl. */
.reaction-picker {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    margin-top: 6px;
    max-width: 100%;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 4px 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.reaction-emoji-btn {
    border: none;
    background: none;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 50%;
}

.reaction-emoji-btn:hover {
    background: rgba(0, 0, 0, 0.08);
}

.message-report-panel {
    width: 100%;
    max-width: 320px;
    margin-top: 6px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 6px 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

/* ---------- Indikátor „píše…" ---------- */

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    margin: 0 0 8px 0.75rem;
    background-color: var(--chat-theirs-bg);
    border-radius: 14px;
    width: fit-content;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #8a8a8e;
    opacity: 0.4;
    animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* ---------- Vstupní lišta ---------- */

.chat-composer {
    padding: 0.5rem 0.6rem;
    background: #fff;
}

.chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

.chat-icon-btn,
.chat-input-row .emoji-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--primary-color);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
}

.chat-icon-btn:hover,
.chat-icon-btn.active,
.chat-input-row .emoji-toggle-btn:hover {
    background: var(--secondary-color);
}

/* Pole zprávy roste s textem (kde to prohlížeč umí) až do stropu, pak se posouvá. */
.chat-textarea {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 40px;
    max-height: 160px;
    field-sizing: content;
    resize: none;
    padding: 8px 14px;
    border: 1px solid #d5d9e0;
    border-radius: 20px;
    background: #f6f7fa;
    font-size: 1rem;
    line-height: 1.4;
    outline: none;
}

.chat-textarea:focus {
    border-color: var(--primary-color);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(58, 124, 213, 0.15);
}

.chat-send-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
}

.chat-send-btn:hover:not(:disabled) {
    background: var(--primary-color-hover);
}

.chat-send-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

/* Výběr emoji ve vstupní liště: panel jako vyskakovací okno nad lištou. */
.chat-input-row .emoji-picker-wrapper {
    position: static;
}

.chat-composer {
    position: relative;
}

.chat-input-row .emoji-list-panel {
    position: absolute;
    left: 0.5rem;
    right: 0.5rem;
    bottom: calc(100% - 0.25rem);
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    max-height: 220px;
    overflow-y: auto;
    padding: 8px;
    background: #fff;
    border: 1px solid #e1e4ea;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.chat-input-row .emoji-list-panel .emoji {
    font-size: 1.35rem;
    padding: 3px 4px;
    border-radius: 8px;
    cursor: pointer;
}

.chat-input-row .emoji-list-panel .emoji:hover {
    background: rgba(0, 0, 0, 0.07);
}

/* Nabídka 📎 – vyskakovací seznam nad tlačítkem. */
.chat-attach-wrap {
    position: relative;
    flex-shrink: 0;
}

.chat-attach-menu {
    position: absolute;
    left: 0;
    bottom: calc(100% + 6px);
    z-index: 6;
    display: flex;
    flex-direction: column;
    min-width: 230px;
    max-width: calc(100vw - 40px);
    padding: 6px;
    background: #fff;
    border: 1px solid #e1e4ea;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.chat-attach-item {
    display: block;
    width: 100%;
    margin: 0;
    padding: 9px 12px;
    border: none;
    border-radius: 10px;
    background: none;
    text-align: left;
    font-size: 0.95rem;
    color: #1f1f1f;
    white-space: nowrap;
    cursor: pointer;
}

.chat-attach-item:hover {
    background: var(--light-primary-color-ultra-light);
    color: var(--primary-color);
}

/* Přílohy čekající v řádku psaní: vodorovná lišta náhledů (fotka miniatura, video/soubor karta) s ✕. */
.chat-compose-attachments {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 6px 2px 8px;
    margin-bottom: 4px;
}

.chat-compose-item {
    position: relative;
    flex: 0 0 auto;
    width: 76px;
    height: 76px;
    border-radius: 10px;
    background: var(--light-primary-color-ultra-light);
    border: 1px solid var(--secondary-color);
    overflow: hidden;
}

.chat-compose-item.loading {
    opacity: 0.7;
}

.chat-compose-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chat-compose-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 100%;
    height: 100%;
    padding: 4px;
    color: var(--primary-color);
}

.chat-compose-card i {
    font-size: 1.4rem;
}

.chat-compose-card span {
    max-width: 100%;
    font-size: 0.6rem;
    line-height: 1.1;
    color: #333;
    text-align: center;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow-wrap: anywhere;
}

.chat-compose-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    background: #dde5f2;
}

.chat-compose-progress span {
    display: block;
    height: 100%;
    background: var(--primary-color);
    transition: width 0.2s ease;
}

.chat-compose-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 0.7rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.chat-compose-remove:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Bublina „Odesílám…" odesílané přílohy na konci konverzace (nahradí ji echo skutečné zprávy). */
.message-pending {
    opacity: 0.8;
}

.message-pending-thumb {
    display: block;
    max-width: 200px;
    max-height: 200px;
    border-radius: 10px;
}

.message-pending-file {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.message-pending-file i {
    font-size: 1.3rem;
}

.message-pending-state {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-size: 0.8rem;
    opacity: 0.85;
}

/* Lišta nad polem: náhled odpovědi / režim úpravy + zavření (×). */
.compose-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    margin-bottom: 6px;
    background-color: var(--light-primary-color-ultra-light);
    border-left: 3px solid var(--primary-color);
    border-radius: 8px;
}

.compose-bar-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.compose-bar-title {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--primary-color);
}

.compose-bar-snippet {
    font-size: 0.8rem;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compose-bar-close {
    flex: 0 0 auto;
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
}

.compose-bar-close:hover {
    color: #333;
}

/* ---------- Přetažení souborů ---------- */

.chat-drop-zone {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 20;
    background: rgba(58, 124, 213, 0.12);
    border: 3px dashed var(--primary-color);
    border-radius: inherit;
}

.chat-drop-zone.active {
    display: block;
}

.chat-drop-hint {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--primary-color);
    font-size: 1.1rem;
    font-weight: 600;
    pointer-events: none;
}

.chat-drop-hint i {
    font-size: 2.6rem;
}

/* Průhledný výběr souborů přes celou plochu – upuštění na něj předá soubory Blazoru. */
.chat-drop-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: copy;
}
