
.chat-root { min-height: 100vh; padding: 16px; display:flex; flex-direction:column; gap:16px; box-sizing:border-box; }
.chat-root.light {
    --bg: #f5f7fb;
    --card-bg: #ffffff;
    --muted: #111827;
    --label: #4b5563;
    --header-border: #e5e7eb;
    --notice-border: #3b82f6;
    --notice-bg: #eef6ff;
    --list-bg: #f9fafb;
    --panel-bg: #f6f7fb;
    --divider: #e7e7eb;
    --compose-bg: #ffffff;
    --success: #16a34a;
    --danger: #ef4444;
    --accent1: #3b82f6;
    --accent2: #6366f1;
    --spinner-top: #3b82f6;
    --primary-title: #1f59e0;
    --title-alt: #0f172a;
}
.chat-root.dark {
    --bg: #020617;
    --card-bg: #020617;
    --muted: #e5e7eb;
    --label: #cbd5e1;
    --header-border: #1e293b;
    --notice-border: #60a5fa;
    --notice-bg: #020617;
    --list-bg: #020617;
    --panel-bg: #020617;
    --divider: #1f2937;
    --compose-bg: #020617;
    --success: #86efac;
    --danger: #f87171;
    --accent1: #3b82f6;
    --accent2: #6366f1;
    --spinner-top: #60a5fa;
    --primary-title: #bfdbfe;
    --title-alt: #e5e7eb;
}
.chat-root { background-color: var(--bg); }

.text-center { text-align: center; }
.btn-block { width: 100%; }
.btn-touch { min-height: 44px; }
.w-100 { width: 100%; }
.flex-1 { flex: 1 1 auto; }

@keyframes slideIn { from { transform: translateY(4px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.animate-slide-in { animation: slideIn 0.18s ease-out; }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

.status-card { padding: 8px 12px; border-radius: 12px; max-width: 640px; box-shadow: 0 6px 14px rgba(15,23,42,0.18); display:flex; align-items:center; gap:8px; }
.chat-root.light .status-card { background: #ffffff; border-color: #e5e7eb; }
.status-text { font-size: 12px; font-weight: 600; color: #e5e7eb; letter-spacing:0.01em; }
.chat-root.light .status-text { color:#0f172a; }
.status-dot { width: 10px; height: 10px; display:inline-block; border-radius: 50%; box-shadow:0 0 0 3px rgba(34,197,94,0.25); }
.status-dot.connected { background-color: #22c55e; }
.status-dot.disconnected { background-color: #ef4444; animation: spin 1s linear infinite; box-shadow:0 0 0 3px rgba(248,113,113,0.35); }
.chat-status-wrapper { display:flex; flex-direction:column; gap:4px; margin-left: 8px; flex:1; }

.status-inline { width: 100%; max-width: 1024px; margin: 0 auto 0; display:flex; align-items:center; gap:8px; padding: 10px 14px; border-radius: 12px; background: var(--card-bg); box-shadow: 0 10px 20px rgba(15,23,42,0.18); border:1px solid var(--header-border); }
.chat-root.dark .status-inline { background: #0b1324; border-color:#1e293b; }
.status-inline .status-text { font-size: 13px; font-weight: 600; color: var(--muted); }
.status-inline .status-dot { width: 10px; height: 10px; border-radius: 50%; box-shadow:0 0 0 3px rgba(34,197,94,0.25); }
.status-inline .status-dot.connected { background-color: #22c55e; }
.status-inline .status-dot.disconnected { background-color: #ef4444; animation: spin 1s linear infinite; box-shadow:0 0 0 3px rgba(248,113,113,0.35); }

.chat-wrapper { width: 100%; max-width: 1024px; margin:0 auto; border-radius:18px; padding:24px; display:flex; flex-direction:column; gap:18px; background-color: var(--card-bg); box-shadow: 0 20px 45px rgba(15,23,42,0.42); border:1px solid rgba(148,163,184,0.20); backdrop-filter: blur(22px); }
.chat-root.light .chat-wrapper { box-shadow: 0 18px 40px rgba(15,23,42,0.18); }

.chat-header { border-bottom-width: 2px; border-bottom-style: solid; border-bottom-color: var(--header-border); justify-content:space-between; align-items:center; padding-bottom:16px; }
.chat-title { font-size: 22px; font-weight: 700; margin:0; letter-spacing: 0.03em; text-transform:uppercase; }

.badge { padding: 4px 12px; border-radius: 9999px; font-size: 12px; font-weight: 600; transition: transform .2s ease; display:inline-flex; align-items:center; gap:6px; border:1px solid transparent; }
.badge:hover { transform: scale(1.05); }
.badge::before { content:""; width:8px; height:8px; border-radius:9999px; background:#16a34a; box-shadow:0 0 0 4px rgba(34,197,94,0.18); }
.badge-librarian::before { background:#3b82f6; box-shadow:0 0 0 4px rgba(59,130,246,0.25); }
.badge-anon::before { background:#6b7280; box-shadow:0 0 0 4px rgba(107,114,128,0.25); }
.light .badge-librarian { background:#e0edff; color:#2563eb; border:1px solid #c7d2fe; }
.dark .badge-librarian { background:#1e3a8a; color:#93c5fd; border:1px solid #3749af; }
.light .badge-patron { background:#dcfce7; color:#16a34a; border:1px solid #a7f3d0; }
.dark .badge-patron { background:#064e3b; color:#86efac; border:1px solid #065f46; }
.light .badge-anon { background:#f3f4f6; color:#4b5563; border:1px solid #e5e7eb; }
.dark .badge-anon { background:#111827; color:#d1d5db; border:1px solid #374151; }

.notification-card { padding: 12px; border-radius: 12px; display:flex; justify-content:space-between; align-items:center; border-left:4px solid var(--notice-border); background: radial-gradient(circle at top left, rgba(59,130,246,0.12), transparent 60%), var(--notice-bg); border-radius:12px; gap:10px; }
.notification-text { font-size:14px; color: var(--muted); flex:1; }
.chat-root.light .notification-card { background: linear-gradient(90deg, #eff6ff, #e0f2fe); border-left-color:#3b82f6; }
.chat-root.dark .notification-card { background: linear-gradient(90deg, #0f172a, #1f2937); border-left-color:#60a5fa; }

.panel { padding: 20px; border-radius: 18px; border: 1px solid rgba(148,163,184,0.22); background-color: var(--panel-bg); box-shadow: 0 10px 26px rgba(15,23,42,0.22); transition: box-shadow .16s ease, transform .12s ease, border-color .16s ease; }
.panel:hover { box-shadow: 0 14px 32px rgba(15,23,42,0.30); transform: translateY(-1px); border-color:rgba(59,130,246,0.50); }

.staff-panel { max-width: 970px;  }

.panel-title { font-size: 21px; margin-bottom: 16px; }

.waiting-panel { padding: 32px 20px 26px; }
.waiting-panel .panel-title { margin-bottom: 8px; }
.waiting-panel .muted { margin-bottom: 12px; }

.spinner { width: 50px; height: 50px; margin: 0 auto 18px; border: 4px solid rgba(148,163,184,0.25); border-top-color: var(--spinner-top); border-radius: 50%; animation: spin 1s linear infinite; }

.muted { color: var(--label); font-size: 15px; margin-bottom: 14px; }

.form-group { margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.form-label { font-size: 14px; font-weight: 600; color: var(--label); }
.field-error { margin-top: 6px; font-size: 12px; color: #ef4444; }

.requests-panel { padding: 18px; border-radius: 16px; border: 1px solid rgba(148,163,184,0.18); background-color: var(--panel-bg); box-shadow: 0 8px 20px rgba(15,23,42,0.10); }

.chat-card { border-radius: 22px; border: 1px solid rgba(148,163,184,0.35); box-shadow: 0 26px 60px rgba(15,23,42,0.65); background-color: var(--panel-bg); overflow:hidden; display:flex; flex-direction:column; }
.chat-card:hover { box-shadow: 0 30px 70px rgba(15,23,42,0.80); }

.active-chat { height: calc(100vh - 200px); max-height: 800px; }

.messages-container { background: radial-gradient(circle at top, rgba(59,130,246,0.16), transparent 60%), linear-gradient(145deg, rgba(15,23,42,0.96), rgba(15,23,42,0.98)); border-top: 1px solid rgba(148,163,184,0.40); border-bottom: 1px solid rgba(148,163,184,0.40); padding: 18px 16px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; flex:1; min-height:0; }
.chat-root.light .messages-container { background: linear-gradient(145deg, #ffffff, #f3f4f6); }

.message-row { display: flex; width: 100%; margin-bottom: 4px; }
.message-row.own { justify-content: flex-end; }
.message-row.other { justify-content: flex-start; }

.message-bubble { max-width: 70%; padding: 12px 15px; border-radius: 18px; box-shadow: 0 6px 18px rgba(15,23,42,0.40); word-wrap: break-word; line-height: 1.45; transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease; font-size:14px; }
.message-bubble:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(15,23,42,0.65); }
.message-bubble.own { background: linear-gradient(135deg, var(--accent1), var(--accent2));  border-radius: 18px 18px 4px 18px; }
.light .message-bubble.other, .dark .message-bubble.other { border-bottom-left-radius: 4px; }


.composer { background-color: var(--compose-bg); border-top: 1px solid var(--divider); border-radius: 0 0 22px 22px; padding: 10px 12px 12px; display: flex; gap: 10px; align-items: center; }
.sticky-composer { position: sticky; bottom: 0; }
.composer .rz-textbox { flex: 1; min-height: 44px; padding: 11px 16px; border-radius: 9999px; border:1px solid rgba(148,163,184,0.6); background-color: transparent; transition:border-color .14s ease, box-shadow .14s ease, background-color .14s ease; }
.composer .rz-textbox:focus-within { border-color:#3b82f6; box-shadow:0 0 0 1px rgba(59,130,246,0.75); background-color:rgba(15,23,42,0.60); }
.chat-root.light .composer .rz-textbox:focus-within { background-color:#ffffff; }
.composer .rz-button { box-shadow: 0 10px 25px rgba(37,99,235,0.45); min-width: 50px; min-height: 50px; border-radius: 9999px; }

.chat-bar { padding: 12px 14px; border-bottom: 1px solid var(--divider); display: flex; justify-content: space-between; align-items: center; background-color: rgba(15,23,42,0.98); border-radius: 22px 22px 0 0; backdrop-filter: blur(16px); }
.chat-root.light .chat-bar { background: linear-gradient(90deg, #eff6ff, #e0f2fe); }
.chat-peer { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--title-alt); }
.chat-peer span[aria-hidden="true"] { font-size: 24px; }

.availability-card { display: flex; justify-content: flex-start; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 16px; background: linear-gradient(135deg, rgba(15,23,42,0.96), rgba(30,64,175,0.95)); box-shadow: 0 14px 32px rgba(15,23,42,0.65); max-width: 960px; margin: 0 auto; border:1px solid rgba(148,163,184,0.40); }
.chat-root.light .availability-card { background: linear-gradient(135deg, #eff6ff, #e0f2fe); box-shadow: 0 12px 30px rgba(59,130,246,0.25); }
.availability-status { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; color:#e5e7eb; }
.chat-root.light .availability-status { color:#111827; }
.availability-status .status-dot { width: 12px; height: 12px; border-radius: 50%; box-shadow:0 0 0 3px rgba(34,197,94,0.25); }
.availability-status.available .status-dot { background-color: #22c55e; }
.availability-status.busy .status-dot { background-color: #ef4444; box-shadow:0 0 0 3px rgba(248,113,113,0.35); }
.availability-toggle { margin-left: 8px; }
.active-pill { margin-left: auto; padding: 6px 12px; background-color: rgba(15,23,42,0.80); border-radius: 9999px; font-size: 12px; font-weight: 600; gap: 8px; display: flex; align-items: center; color:#e5e7eb; }
.chat-root.light .active-pill { background-color: rgba(255,255,255,0.85); color:#111827; }

.empty-card { text-align:center; color:#6b7280; border-radius:16px; border:1px dashed rgba(148,163,184,0.6); background: rgba(15,23,42,0.80); max-width: 960px; margin: 0 auto; }
.chat-root.light .empty-card { background: #f9fafb; color:#4b5563; border-color: rgba(148,163,184,0.35); }
.chat-root.dark .empty-card { background: rgba(2,6,23,0.85); color:#cbd5e1; border-color: rgba(148,163,184,0.45);

.request-card { padding: 16px; border-radius: 12px; }
.request-header { display:flex; align-items:center; gap:12px; font-weight:600; margin-bottom:12px; }
.request-avatar { font-size:20px; }
.request-body { display:flex; flex-direction:column; gap:8px; }
.request-quote { font-style: italic; border-radius: 10px; padding: 10px; background: rgba(148,163,184,0.18); }
.chat-root.light .request-quote { background: #f3f4f6; }
.chat-root.dark .request-quote { background: #1f2937; }
.request-actions { display:flex; gap:10px; margin-top: 12px; }

.availability-status.available { color: var(--success); }
.availability-status.busy { color: var(--danger); }


@media (max-width: 640px) {
  .chat-title { font-size: 20px; }
  .badge { font-size: 11px; padding: 4px 10px; }
  .status-card { max-width: 90%; }
}

.feedback-container { display:flex; align-items:center; justify-content:center; padding: 12px; }
.feedback-card { max-width: 720px; margin: 0 auto; border-radius: 16px; border:1px solid var(--header-border); background: var(--card-bg); box-shadow: 0 14px 32px rgba(15,23,42,0.25); }
.feedback-inner { border-radius: 12px; background: var(--panel-bg); padding: 16px; }
.feedback-heading { margin: 0 0 10px; color: var(--title-alt); }
.feedback-stars { display:flex; flex-wrap:wrap; gap: 6px; align-items:center; }
.star-btn { min-width: 36px; height: 36px; border-radius: 8px; color: #cbd5e1; background: transparent; border: 1px solid rgba(148,163,184,0.35); box-shadow:none; }
.star-btn:hover { border-color: #94a3b8; }
.star-btn.active { color: #FFD700; border-color: #fbbf24; background: rgba(251,191,36,0.10); }
.feedback-textarea { width:100%; min-height: 110px; border-radius: 10px; border:1px solid rgba(148,163,184,0.35); padding: 10px; }
.feedback-actions { display:flex; gap: 10px; justify-content:flex-end; padding: 10px 16px; }
.feedback-submit { box-shadow: 0 8px 18px rgba(37,99,235,0.35); }
.feedback-cancel { box-shadow: none; }
.feedback-hint { margin-top: 6px; font-size: 12px; color: var(--label); }
.char-count { margin-top: 6px; font-size: 12px; color: var(--label); text-align: right; }


.chat-root.dark .feedback-card { background:#0b1324; border-color:#1e293b; }
.chat-root.dark .feedback-inner { background:#0f172a; }
.chat-root.dark .star-btn { color:#64748b; border-color:#334155; }
.chat-root.dark .star-btn.active { color:#FFD700; border-color:#f59e0b; background: rgba(245,158,11,0.12); }
.chat-root.dark .feedback-textarea { background:#0b1324; color:#e5e7eb; border-color:#334155; }

.ask-messages {
    max-height: 220px;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-radius: 16px;
    border: 1px solid rgba(148,163,184,0.28);
    background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), inset 0 -1px 0 rgba(0,0,0,0.08);
    color: var(--muted);
}

.chat-root.light .ask-messages {
    background: linear-gradient(180deg, rgba(0,0,0,0.92), rgba(0,0,0,0.84));
    border-color: rgba(255,255,255,0.14);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), inset 0 -1px 0 rgba(0,0,0,0.35);
    color: #ffffff;
}

.chat-root.dark .ask-messages {
    background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(255,255,255,0.84));
    border-color: rgba(15,23,42,0.12);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.75), inset 0 -1px 0 rgba(15,23,42,0.08);
    color: #111827;
}

    .ask-messages .message-row {
        display: flex;
        width: 100%;
    }

        .ask-messages .message-row.own {
            justify-content: flex-end;
        }

        .ask-messages .message-row.other {
            justify-content: flex-start;
        }

    .ask-messages .message-bubble {
        position: relative;
        max-width: 78%;
        padding: 10px 12px;
        border-radius: 16px;
        font-size: 13px;
        line-height: 1.45;
        word-wrap: break-word;
        box-shadow: 0 6px 16px rgba(15,23,42,0.25);
        transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
    }

        .ask-messages .message-bubble:hover {
            transform: translateY(-1px);
            box-shadow: 0 8px 18px rgba(15,23,42,0.35);
        }

        .ask-messages .message-bubble.own {
            background: linear-gradient(135deg, var(--accent1), var(--accent2));
            color: #ffffff;
            border-bottom-right-radius: 6px;
        }

        .ask-messages .message-bubble.other {
            background: rgba(148,163,184,0.16);
            color: var(--muted);
            border-bottom-left-radius: 6px;
        }

        .ask-messages .message-bubble.own::after {
            content: "";
            position: absolute;
            right: -6px;
            bottom: 10px;
            width: 0;
            height: 0;
            border-left: 6px solid rgba(99,102,241,0.85);
            border-top: 6px solid transparent;
            border-bottom: 6px solid transparent;
            filter: drop-shadow(0 2px 6px rgba(15,23,42,0.18));
        }

        .ask-messages .message-bubble.other::after {
            content: "";
            position: absolute;
            left: -6px;
            bottom: 10px;
            width: 0;
            height: 0;
            border-right: 6px solid rgba(148,163,184,0.22);
            border-top: 6px solid transparent;
            border-bottom: 6px solid transparent;
            filter: drop-shadow(0 2px 6px rgba(15,23,42,0.12));
        }

.chat-root.light .ask-messages .message-bubble.other {
    background: rgba(255,255,255,0.12);
    color: #ffffff;
}

.chat-root.light .ask-messages .message-bubble.other::after {
    border-right-color: rgba(255,255,255,0.12);
}

.chat-root.light .ask-messages .message-bubble.own::after {
    border-left-color: rgba(99,102,241,0.92);
}

.chat-root.dark .ask-messages .message-bubble.other {
    background: rgba(15,23,42,0.08);
    color: #111827;
}

.chat-root.dark .ask-messages .message-bubble.other::after {
    border-right-color: rgba(15,23,42,0.08);
}

.ask-messages .message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.ask-messages .message-avatar {
    width: 22px;
    height: 22px;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.02em;
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.95);
    flex: 0 0 auto;
}

.ask-messages .message-bubble.other .message-avatar {
    background: rgba(148,163,184,0.28);
    color: var(--muted);
}

.chat-root.light .ask-messages .message-bubble.other .message-avatar {
    background: rgba(255,255,255,0.18);
    color: #ffffff;
}

.chat-root.dark .ask-messages .message-bubble.other .message-avatar {
    background: rgba(15,23,42,0.12);
    color: #111827;
}

.ask-messages .message-name {
    font-size: 11px;
    font-weight: 750;
    opacity: 0.92;
    letter-spacing: 0.02em;
}

.ask-messages .message-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.ask-messages .message-time {
    margin-left: auto;
    font-size: 10.5px;
    opacity: 0.7;
    white-space: nowrap;
}

.ask-messages .animate-slide-in {
    animation: askSlideIn 0.16s cubic-bezier(.22,.61,.36,1);
}

@keyframes askSlideIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ask-messages::-webkit-scrollbar {
    width: 6px;
}

.ask-messages::-webkit-scrollbar-thumb {
    background: rgba(148,163,184,0.45);
    border-radius: 9999px;
}

.ask-messages::-webkit-scrollbar-track {
    background: transparent;
}