/* ════════════════════════════════════════
   WebChat – mobile-first, Catppuccin Mocha
   ════════════════════════════════════════ */

:root {
    --base:     #1e1e2e;
    --mantle:   #181825;
    --crust:    #11111b;
    --surface0: #313244;
    --surface1: #45475a;
    --surface2: #585b70;
    --overlay0: #6c7086;
    --subtext:  #a6adc8;
    --text:     #cdd6f4;
    --blue:     #89b4fa;
    --green:    #a6e3a1;
    --red:      #f38ba8;
    --yellow:   #f9e2af;
    --mauve:    #5ef706;
    --peach:    #fab387;
    --teal:     #94e2d5;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--crust);
    color: var(--text);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* ── Screens ── */
.screen { display: none; }
.screen.active { display: flex; }   /* výchozí pro přihlášení / registraci */
#screen-app.active { display: flex; } /* mobil – sidebar/chat jsou absolute */

#screen-login,
#screen-register {
    height: 100dvh;
    align-items: center;
    justify-content: center;
    background: var(--crust);
}

#screen-app {
    height: 100dvh;
    width: 100%;
    position: relative;
    overflow: hidden;
}

/* ── Auth box ── */
.auth-box {
    background: var(--base);
    border: 1px solid var(--surface1);
    border-radius: 14px;
    padding: 32px 26px 24px;
    width: min(400px, 94vw);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-logo {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--blue);
    text-align: center;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.auth-box form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-box input {
    background: var(--surface0);
    border: 1px solid var(--surface1);
    border-radius: 9px;
    padding: 11px 14px;
    font-size: 0.95rem;
    color: var(--text);
    outline: none;
    width: 100%;
    transition: border-color 0.15s;
}
.auth-box input:focus { border-color: var(--blue); }

.auth-box button[type="submit"] {
    background: var(--blue);
    color: var(--crust);
    border: none;
    border-radius: 9px;
    padding: 11px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s;
    margin-top: 2px;
}
.auth-box button[type="submit"]:hover { opacity: 0.88; }
.auth-box button[type="submit"]:disabled { opacity: 0.5; cursor: default; }

.auth-error {
    color: var(--red);
    font-size: 0.8rem;
    text-align: center;
    min-height: 16px;
}

.link-btn {
    background: none;
    border: none;
    color: var(--overlay0);
    font-size: 0.82rem;
    cursor: pointer;
    text-align: center;
    padding: 4px;
    transition: color 0.15s;
}
.link-btn:hover { color: var(--subtext); }

.apk-btn {
    display: block;
    text-align: center;
    text-decoration: none;
    background: var(--green);
    color: var(--crust);
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 9px;
    padding: 11px;
    transition: opacity 0.15s;
}
.apk-btn:hover { opacity: 0.88; }

/* ── Avatary ── */
.avatar {
    border-radius: 50%;
    background: var(--surface1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    color: var(--subtext);
    flex-shrink: 0;
    overflow: hidden;
    text-transform: uppercase;
}
.avatar.sm { width: 38px; height: 38px; font-size: 0.95rem; }
.avatar.md { width: 44px; height: 44px; font-size: 1.1rem; }
.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* ── Ikona tlačítko ── */
.icon-btn {
    background: none;
    border: 1px solid var(--surface1);
    border-radius: 7px;
    color: var(--subtext);
    font-size: 1rem;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s;
    user-select: none;
}
.icon-btn:hover { background: var(--surface0); color: var(--text); }
.icon-btn.danger:hover { border-color: var(--red); color: var(--red); }

/* ── SIDEBAR ── */
#sidebar {
    position: absolute;
    inset: 0;
    background: var(--mantle);
    display: flex;
    flex-direction: column;
    z-index: 20;
    transition: transform 0.22s ease;
}

#sidebar.slide-out {
    transform: translateX(-100%);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--crust);
    border-bottom: 1px solid var(--surface0);
    flex-shrink: 0;
    min-height: 58px;
}

.user-info { flex: 1; min-width: 0; overflow: hidden; }
.user-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-sub {
    font-size: 0.68rem;
    color: var(--overlay0);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-sub:hover { color: var(--blue); text-decoration: underline; }

#contact-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.loading-spinner {
    color: var(--overlay0);
    font-size: 0.82rem;
    text-align: center;
    padding: 28px 16px;
}

#notif-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: var(--yellow);
    color: var(--crust);
    font-size: 0.78rem;
    font-weight: 600;
    flex-shrink: 0;
}
#notif-banner button {
    background: var(--crust);
    color: var(--yellow);
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--surface0);
    cursor: pointer;
    position: relative;
    transition: background 0.1s;
    user-select: none;
}
.contact-item:hover { background: var(--surface0); }
.contact-item.active {
    background: var(--surface0);
    border-left: 3px solid var(--blue);
    padding-left: 11px;
}

.contact-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--green);
    border: 2px solid var(--mantle);
    box-shadow: 0 0 0 1px var(--mantle);
}

.contact-data { flex: 1; min-width: 0; }
.contact-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.contact-last {
    font-size: 0.71rem;
    color: var(--overlay0);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.contact-badge {
    background: var(--blue);
    color: var(--crust);
    border-radius: 10px;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 2px 7px;
    flex-shrink: 0;
    min-width: 20px;
    text-align: center;
}

.empty-contacts {
    color: var(--overlay0);
    font-size: 0.82rem;
    text-align: center;
    padding: 36px 20px;
    line-height: 1.7;
}

/* ── CHAT PANEL ── */
#chat-panel {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--base);
    z-index: 10;
    transform: translateX(100%);
    transition: transform 0.22s ease;
}

#chat-panel.slide-in {
    transform: translateX(0);
}

#chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--crust);
    border-bottom: 1px solid var(--surface0);
    flex-shrink: 0;
    min-height: 58px;
}

.chat-title { flex: 1; min-width: 0; }
.chat-name {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-status {
    font-size: 0.71rem;
    margin-top: 1px;
}
.chat-status.online { color: var(--green); }
.chat-status.offline { color: var(--overlay0); }

/* ── Zprávy ── */
#messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 10px 8px 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overscroll-behavior: contain;
}

.date-sep {
    text-align: center;
    font-size: 0.68rem;
    color: var(--overlay0);
    background: var(--surface0);
    border-radius: 10px;
    padding: 3px 10px;
    margin: 8px auto;
    max-width: 160px;
    flex-shrink: 0;
}

.msg-row {
    display: flex;
    align-items: flex-end;
    gap: 4px;
}
.msg-row.mine  { flex-direction: row-reverse; }
.msg-row.theirs { flex-direction: row; }

.msg-del-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.7rem;
    color: var(--red);
    opacity: 0;
    padding: 4px;
    transition: opacity 0.12s;
    flex-shrink: 0;
    align-self: center;
}
.msg-row:hover .msg-del-btn { opacity: 0.6; }
.msg-del-btn:hover { opacity: 1 !important; }

.msg-report-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.7rem;
    opacity: 0;
    padding: 0 2px;
    transition: opacity 0.12s;
    flex-shrink: 0;
    line-height: 1;
}
.msg-bubble:hover .msg-report-btn { opacity: 0.6; }
.msg-report-btn:hover { opacity: 1 !important; }
.msg-report-btn:disabled { opacity: 0.25; cursor: default; }

.msg-reply-btn {
    background: var(--teal);
    color: var(--crust);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 7px;
    flex-shrink: 0;
    transition: opacity 0.12s;
}
.msg-reply-btn:hover { opacity: 0.82; }

.msg-bubble {
    max-width: 95%;
    padding: 8px 12px;
    border-radius: 16px;
    font-size: 0.875rem;
    line-height: 1.48;
    word-break: break-word;
    position: relative;
}

/* AI chat – širší bubliny pro delší texty */
#messages-area.ai-mode .msg-bubble {
    max-width: 95%;
}
.msg-row.mine .msg-bubble {
    background: var(--blue);
    color: var(--crust);
    border-bottom-right-radius: 4px;
}
.msg-row.theirs .msg-bubble {
    background: var(--surface0);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.msg-text { white-space: pre-wrap; }

.msg-link { color: inherit; text-decoration: underline; opacity: 0.85; word-break: break-all; }
.msg-link:hover { opacity: 1; }

.msg-img {
    max-width: 240px;
    max-height: 300px;
    border-radius: 10px;
    display: block;
    cursor: pointer;
}

.msg-meta {
    font-size: 0.6rem;
    opacity: 0.65;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 3px;
}
.msg-row.mine  .msg-meta { justify-content: flex-end; }
.msg-row.theirs .msg-meta { justify-content: flex-start; }

.msg-read-tick { font-size: 0.65rem; }
.msg-read-tick.read { color: var(--teal); }

.msgs-empty {
    color: var(--overlay0);
    font-size: 0.82rem;
    text-align: center;
    margin: auto;
    padding: 20px;
}

/* ── Emoji picker ── */
#emoji-picker {
    position: absolute;
    bottom: calc(100% + 6px);  /* nad input-barem, relativně k #input-bar */
    left: 0;
    background: var(--mantle);
    border: 1px solid var(--surface1);
    border-radius: 12px;
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 2px;
    z-index: 200;
    box-shadow: 0 4px 16px rgba(0,0,0,.35);
    width: max-content;
}
#emoji-picker[hidden] { display: none; }
#emoji-picker button {
    background: none;
    border: none;
    font-size: 1.45rem;
    cursor: pointer;
    border-radius: 6px;
    padding: 4px;
    line-height: 1;
    transition: background 0.1s;
}
#emoji-picker button:hover { background: var(--surface0); }

/* ── Vstup ── */
#input-bar {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 8px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    background: var(--mantle);
    border-top: 1px solid var(--surface0);
    flex-shrink: 0;
}

#msg-input {
    flex: 1;
    background: var(--surface0);
    border: 1px solid var(--surface1);
    border-radius: 22px;
    padding: 9px 16px;
    font-size: 0.9rem;
    color: var(--text);
    outline: none;
    resize: none;
    max-height: 130px;
    overflow-y: auto;
    line-height: 1.4;
    font-family: inherit;
    transition: border-color 0.15s;
}
#msg-input:focus { border-color: var(--blue); }

.send-btn {
    background: var(--blue);
    color: var(--crust);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s, transform 0.1s;
}
.send-btn:hover { opacity: 0.88; }
.send-btn:active { transform: scale(0.93); }
.send-btn:disabled { opacity: 0.4; cursor: default; }

/* ── Placeholder (desktop) ── */
#no-chat-placeholder {
    display: none;
    flex: 1;
    overflow-y: auto;
    background: var(--base);
}

.welcome-page {
    max-width: 480px;
    margin: 0 auto;
    padding: 40px 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.welcome-logo {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--blue);
    letter-spacing: -0.5px;
}

.welcome-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.welcome-section-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--subtext);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.welcome-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.welcome-list li {
    font-size: 0.875rem;
    color: var(--text);
    padding: 8px 12px;
    background: var(--mantle);
    border-radius: 8px;
    border-left: 3px solid var(--surface1);
    line-height: 1.4;
}

.welcome-link {
    color: var(--blue);
    text-decoration: none;
}
.welcome-link:hover { text-decoration: underline; }

.welcome-hint {
    font-size: 0.78rem;
    color: var(--overlay0);
    text-align: center;
    margin-top: 4px;
}

/* ── Modály ── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 50;
    align-items: center;
    justify-content: center;
}
.modal.is-open { display: flex; }

.modal-box {
    background: var(--base);
    border: 1px solid var(--surface1);
    border-radius: 14px;
    padding: 22px 24px;
    width: min(380px, 92vw);
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}
.modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--blue);
}
.modal-desc {
    font-size: 0.8rem;
    color: var(--overlay0);
    line-height: 1.4;
}
.modal-box input {
    background: var(--surface0);
    border: 1px solid var(--surface1);
    border-radius: 9px;
    padding: 10px 14px;
    font-size: 0.9rem;
    color: var(--text);
    outline: none;
    width: 100%;
    font-family: 'Consolas', monospace;
    letter-spacing: 1px;
    transition: border-color 0.15s;
}
.modal-box input:focus { border-color: var(--blue); }

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 2px;
}
.modal-actions button {
    flex: 1;
    padding: 10px;
    border-radius: 9px;
    border: none;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    background: var(--blue);
    color: var(--crust);
    transition: opacity 0.15s;
}
.modal-actions button:hover { opacity: 0.88; }
.modal-actions button:disabled { opacity: 0.5; cursor: default; }
.modal-actions button.secondary {
    background: var(--surface1);
    color: var(--text);
}

.code-display {
    background: var(--surface0);
    border: 1px solid var(--surface1);
    border-radius: 9px;
    padding: 12px 16px;
    font-family: 'Consolas', monospace;
    font-size: 1.05rem;
    color: var(--green);
    text-align: center;
    letter-spacing: 2px;
    word-break: break-all;
}

/* ── Lightbox ── */
#lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 100;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    cursor: zoom-out;
}
#lightbox.open { display: flex; }
#lightbox img {
    max-width: 95vw;
    max-height: 80dvh;
    border-radius: 6px;
    object-fit: contain;
}
.lb-ai-btn {
    background: var(--mauve);
    color: var(--crust);
    border: none;
    border-radius: 20px;
    padding: 8px 20px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s;
}
.lb-ai-btn:hover { opacity: 0.88; }

/* ══════════════════════════════════
   Desktop layout ≥ 640px
   ══════════════════════════════════ */
@media (min-width: 640px) {
    #screen-app.active {
        display: grid;
        grid-template-columns: 300px 1fr;
        grid-template-rows: 1fr;
        /* overflow: hidden je už na #screen-app */
    }

    /* Sidebar – fixní levý sloupec, nesmí se scvrknout */
    #sidebar {
        position: static;
        transform: none !important;
        grid-row: 1;
        grid-column: 1;
        width: 300px;
        min-width: 0;      /* grid fix: nedovolí obsahu roztáhnout buňku */
        min-height: 0;     /* grid+flex fix: respektuj výšku buňky */
        overflow: hidden;
        border-right: 1px solid var(--surface0);
    }

    /* Chat panel – pravý sloupec, viditelný jen když je otevřen chat */
    #chat-panel {
        position: static;
        transform: none !important;
        grid-row: 1;
        grid-column: 2;
        min-height: 0;
        min-width: 0;
        height: 100%;
        overflow: hidden;
        display: none;      /* skrytý dokud není otevřen chat */
    }

    #screen-app.chat-open #chat-panel  { display: flex; }
    #screen-app.chat-open #no-chat-placeholder { display: none !important; }

    #no-chat-placeholder {
        display: flex;      /* výchozí stav na desktopu = vitací stránka */
        grid-row: 1;
        grid-column: 2;
        min-height: 0;
        min-width: 0;
        overflow-y: auto;
    }

    #btn-back { display: none !important; }
}

@media (min-width: 900px) {
    #screen-app.active {
        grid-template-columns: 340px 1fr;
    }
    #sidebar { width: 340px; }
}

/* ── AI modal ── */
.ai-modal-box {
    width: min(500px, 96vw);
    max-height: 90dvh;
    overflow-y: auto;
    gap: 10px;
}
.ai-row { display: flex; flex-direction: column; gap: 4px; }
.ai-row-inline { flex-direction: row; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.ai-label { font-size: 0.72rem; color: var(--overlay0); text-transform: uppercase; letter-spacing: 0.5px; }

/* Režim tlačítka */
.ai-mode-btns { display: flex; gap: 4px; }
.ai-mode-btn {
    flex: 1;
    padding: 8px 6px;
    background: var(--surface0);
    border: 1px solid var(--surface1);
    border-radius: 8px;
    color: var(--subtext);
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.ai-mode-btn:hover { background: var(--surface1); }
.ai-mode-btn.active { background: var(--blue); color: var(--crust); border-color: var(--blue); font-weight: 700; }

/* Checkbox */
.ai-checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text);
    cursor: pointer;
}
.ai-checkbox-row input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--blue); }

/* Skupinová tlačítka */
.ai-btn-group { display: flex; gap: 4px; flex-wrap: wrap; }
.ai-grp-btn {
    padding: 6px 12px;
    background: var(--surface0);
    border: 1px solid var(--surface1);
    border-radius: 7px;
    color: var(--subtext);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.12s;
}
.ai-grp-btn.active { background: var(--blue); color: var(--crust); border-color: var(--blue); font-weight: 700; }

/* Pokročilá nastavení */
.ai-details { border-top: 1px solid var(--surface0); padding-top: 8px; margin-top: 2px; }
.ai-summary {
    font-size: 0.78rem;
    color: var(--overlay0);
    cursor: pointer;
    user-select: none;
    list-style: none;
}
.ai-summary::-webkit-details-marker { display: none; }
.ai-adv { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; }
.ai-adv-row { display: flex; justify-content: space-between; align-items: center; }
.ai-adv-label { font-size: 0.78rem; color: var(--text); }
.ai-adv-val { font-size: 0.78rem; color: var(--blue); font-family: 'Consolas', monospace; }
.ai-slider {
    width: 100%;
    accent-color: var(--blue);
    height: 4px;
    margin: 2px 0 8px;
}

/* Mask toolbar */
.ai-mask-tools {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    padding: 6px 0 4px;
}
.ai-mask-btn {
    padding: 5px 10px;
    background: var(--surface0);
    border: 1px solid var(--surface1);
    border-radius: 7px;
    color: var(--subtext);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.12s;
}
.ai-mask-btn:hover { background: var(--surface1); }
.ai-mask-btn.active { background: var(--mauve); color: var(--crust); border-color: var(--mauve); font-weight: 700; }
.ai-mask-btn.secondary { color: var(--red); border-color: var(--red); }
.ai-mask-btn.secondary:hover { background: #3d1a1a; }

/* Drag drop */
.ai-img-drop {
    border: 2px dashed var(--surface1);
    border-radius: 10px;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.15s;
}
.ai-img-drop:hover, .ai-img-drop.drag-over { border-color: var(--blue); }
.ai-img-drop img { max-width: 100%; max-height: 180px; border-radius: 8px; display: block; }
#ai-drop-hint { font-size: 0.78rem; color: var(--overlay0); padding: 12px; }

.ai-textarea {
    background: var(--surface0);
    border: 1px solid var(--surface1);
    border-radius: 9px;
    padding: 9px 12px;
    font-size: 0.88rem;
    color: var(--text);
    outline: none;
    resize: vertical;
    font-family: inherit;
    width: 100%;
    transition: border-color 0.15s;
}
.ai-textarea:focus { border-color: var(--blue); }

.ai-input {
    background: var(--surface0);
    border: 1px solid var(--surface1);
    border-radius: 9px;
    padding: 8px 12px;
    font-size: 0.88rem;
    color: var(--text);
    outline: none;
    width: 100%;
    transition: border-color 0.15s;
}
.ai-input:focus { border-color: var(--blue); }

.ai-result-img {
    max-width: 100%;
    border-radius: 10px;
    display: block;
    margin-top: 4px;
    cursor: zoom-in;
}

/* ── AI chat ── */
.ai-avatar {
    background: linear-gradient(135deg, var(--mauve), var(--blue));
    color: var(--crust);
    font-size: 1.1rem;
}

.ai-dots {
    display: flex;
    gap: 5px;
    padding: 4px 2px;
    align-items: center;
}
.ai-dots span {
    width: 7px;
    height: 7px;
    background: var(--overlay0);
    border-radius: 50%;
    animation: aiDotBounce 1.2s ease-in-out infinite;
}
.ai-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiDotBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.45; }
    40%            { transform: scale(1);   opacity: 1; }
}

#ai-model-select {
    background: var(--surface0);
    border: 1px solid var(--surface1);
    border-radius: 7px;
    color: var(--text);
    font-size: 0.72rem;
    padding: 4px 6px;
    cursor: pointer;
    outline: none;
    max-width: 170px;
    flex-shrink: 0;
    transition: border-color 0.15s;
}
#ai-model-select:focus { border-color: var(--blue); }

.ai-msg-img {
    max-width: 220px;
    max-height: 200px;
    border-radius: 8px;
    display: block;
    margin-bottom: 6px;
    cursor: zoom-in;
}

/* ── Scrollbary ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--surface2); }

/* ── Animace nové zprávy ── */
@keyframes msgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.msg-row.new { animation: msgIn 0.18s ease; }

/* ── Indikátor nových zpráv při scrollu nahoru ── */
.new-msg-indicator {
    position: absolute;
    bottom: 70px;          /* nad input-barem */
    left: 50%;
    transform: translateX(-50%);
    background: var(--blue);
    color: var(--crust);
    border: none;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    z-index: 5;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
    white-space: nowrap;
    animation: fadeInUp 0.18s ease;
}
.new-msg-indicator:hover { opacity: 0.88; }
@keyframes fadeInUp {
    from { opacity: 0; transform: translateX(-50%) translateY(6px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Indikátor načítání starších zpráv ── */
.older-loading {
    text-align: center;
    font-size: 0.72rem;
    color: var(--overlay0);
    padding: 8px 12px;
    margin: 4px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
}
.older-loading::before {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid var(--surface1);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
