/* Live Chat Perpustakaan — widget OPAC */
#lc-root {
  --lc-color: #0f766e;
  --lc-color-2: color-mix(in srgb, var(--lc-color) 70%, #0b3b5a);
  --lc-soft: color-mix(in srgb, var(--lc-color) 10%, #fff);
  --lc-ink: #1f2937;
  --lc-muted: #6b7280;
  --lc-line: #e5e7eb;
  --lc-bg: #f6f7f9;
  --lc-radius: 18px;
  position: fixed; right: 22px; bottom: 22px; z-index: 2147483000;
  font: 400 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--lc-ink);
  -webkit-font-smoothing: antialiased;
}
#lc-root *, #lc-root *::before, #lc-root *::after { box-sizing: border-box; }
#lc-root [hidden] { display: none !important; }
#lc-root button { font: inherit; cursor: pointer; margin: 0; }
#lc-root svg { display: block; width: 100%; height: 100%; }
#lc-root.lc-disabled { display: none; }

/* ---------- tombol pemicu ---------- */
#lc-root .lc-launcher {
  position: relative; width: 62px; height: 62px; border-radius: 50%; border: 0; padding: 0;
  background: linear-gradient(140deg, var(--lc-color), var(--lc-color-2));
  box-shadow: 0 10px 28px -6px color-mix(in srgb, var(--lc-color) 65%, transparent), 0 3px 8px rgba(0,0,0,.18);
  color: #fff; display: grid; place-items: center;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
}
#lc-root .lc-launcher:hover { transform: translateY(-2px) scale(1.04); }
#lc-root .lc-launcher:focus-visible { outline: 3px solid color-mix(in srgb, var(--lc-color) 40%, #fff); outline-offset: 3px; }
#lc-root .lc-launcher-icon { position: absolute; inset: 0; display: grid; place-items: center; transition: transform .3s ease, opacity .2s ease; }
#lc-root .lc-i-chat svg { width: 34px; height: 34px; }
#lc-root .lc-i-chat .lc-dot { fill: var(--lc-color); }
#lc-root .lc-launcher:hover .lc-dot { animation: lc-bounce 1s infinite ease-in-out; }
#lc-root .lc-launcher:hover .d2 { animation-delay: .15s; }
#lc-root .lc-launcher:hover .d3 { animation-delay: .3s; }
#lc-root .lc-i-close { opacity: 0; transform: rotate(-90deg) scale(.6); }
#lc-root .lc-i-close svg { width: 24px; height: 24px; }
#lc-root.lc-open .lc-i-chat { opacity: 0; transform: rotate(90deg) scale(.6); }
#lc-root.lc-open .lc-i-close { opacity: 1; transform: none; }
#lc-root .lc-launcher.lc-has-unread::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--lc-color) 55%, transparent);
  animation: lc-pulse 2s infinite;
}
#lc-root .lc-badge {
  position: absolute; top: -3px; right: -3px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: #ef4444; color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid #fff; z-index: 2;
}
@keyframes lc-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--lc-color) 55%, transparent); } 70% { box-shadow: 0 0 0 16px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes lc-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }

#lc-root .lc-tooltip {
  position: absolute; right: 74px; bottom: 12px; white-space: nowrap;
  background: #fff; color: var(--lc-ink); padding: 10px 14px; border-radius: 14px 14px 4px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.14); font-size: 13px;
  opacity: 0; transform: translateX(8px); pointer-events: none; transition: .3s;
}
#lc-root .lc-tooltip.lc-show { opacity: 1; transform: none; }

/* ---------- panel ---------- */
#lc-root .lc-panel {
  position: absolute; right: 0; bottom: 78px;
  width: 370px; height: min(580px, calc(100vh - 120px));
  background: #fff; border-radius: var(--lc-radius); overflow: hidden;
  box-shadow: 0 24px 60px -12px rgba(15,23,42,.35), 0 2px 6px rgba(15,23,42,.08);
  display: flex; flex-direction: column;
  opacity: 0; transform: translateY(16px) scale(.96); transform-origin: bottom right;
  pointer-events: none; visibility: hidden;
  transition: opacity .22s ease, transform .28s cubic-bezier(.2,.9,.3,1.2), visibility 0s .28s;
}
#lc-root.lc-open .lc-panel { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition-delay: 0s; }

#lc-root .lc-head {
  display: flex; align-items: center; gap: 12px; padding: 16px 14px 16px 16px; color: #fff;
  background: linear-gradient(135deg, var(--lc-color), var(--lc-color-2));
}
#lc-root .lc-avatar {
  position: relative; width: 42px; height: 42px; flex: none; border-radius: 50%;
  background: rgba(255,255,255,.18); padding: 10px; color: #fff;
}
#lc-root .lc-online { position: absolute; right: 0; bottom: 1px; width: 11px; height: 11px; border-radius: 50%; background: #34d399; border: 2px solid var(--lc-color); }
#lc-root .lc-head-text { flex: 1; min-width: 0; }
#lc-root .lc-title { font-weight: 700; font-size: 15.5px; letter-spacing: .1px; }
#lc-root .lc-sub { font-size: 12.5px; opacity: .88; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#lc-root .lc-icon-btn {
  width: 34px; height: 34px; padding: 7px; border: 0; border-radius: 10px; background: transparent; color: inherit; flex: none;
  transition: background .15s;
}
#lc-root .lc-head .lc-icon-btn:hover { background: rgba(255,255,255,.18); }

#lc-root .lc-body { position: relative; flex: 1; min-height: 0; background: var(--lc-bg); display: flex; flex-direction: column; }

/* loading */
#lc-root .lc-loading { margin: auto; display: flex; gap: 6px; }
#lc-root .lc-loading span { width: 8px; height: 8px; border-radius: 50%; background: var(--lc-color); opacity: .5; animation: lc-bounce .9s infinite; }
#lc-root .lc-loading span:nth-child(2) { animation-delay: .15s; }
#lc-root .lc-loading span:nth-child(3) { animation-delay: .3s; }

/* ---------- login ---------- */
#lc-root .lc-login { padding: 26px 22px; overflow: auto; flex: 1; text-align: center; }
#lc-root .lc-login-art { width: 74px; height: 74px; margin: 6px auto 12px; padding: 16px; border-radius: 24px; background: linear-gradient(140deg, var(--lc-color), var(--lc-color-2)); box-shadow: 0 12px 24px -10px var(--lc-color); }
#lc-root .lc-login-art .lc-dot { fill: var(--lc-color); }
#lc-root .lc-login-title { margin: 0 0 6px; font-size: 18px; font-weight: 700; color: var(--lc-ink); }
#lc-root .lc-login-text { margin: 0 0 20px; color: var(--lc-muted); font-size: 13.5px; }
#lc-root .lc-login-form { text-align: left; background: #fff; border: 1px solid var(--lc-line); border-radius: 14px; padding: 16px; }
#lc-root .lc-login-form label { display: block; font-weight: 600; font-size: 12.5px; margin: 0 0 6px; color: var(--lc-ink); }
#lc-root .lc-input-wrap { position: relative; }
#lc-root .lc-input-ico { position: absolute; left: 11px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: #9ca3af; }
#lc-root .lc-login-form input {
  width: 100%; height: 44px; padding: 0 12px 0 38px; border: 1.5px solid var(--lc-line); border-radius: 11px;
  font: inherit; font-size: 15px; color: var(--lc-ink); background: #fff; outline: none; transition: border .15s, box-shadow .15s; margin: 0;
}
#lc-root .lc-login-form input:focus { border-color: var(--lc-color); box-shadow: 0 0 0 4px color-mix(in srgb, var(--lc-color) 15%, transparent); }
#lc-root .lc-error, #lc-root .lc-send-error { margin-top: 10px; padding: 8px 10px; border-radius: 9px; background: #fef2f2; color: #b91c1c; font-size: 12.5px; }
#lc-root .lc-send-error { margin: 0 0 8px; }
#lc-root .lc-primary {
  width: 100%; height: 44px; margin-top: 12px; border: 0; border-radius: 11px; color: #fff; font-weight: 600;
  background: linear-gradient(135deg, var(--lc-color), var(--lc-color-2)); transition: filter .15s, transform .1s;
}
#lc-root .lc-primary:hover { filter: brightness(1.07); }
#lc-root .lc-primary:active { transform: scale(.98); }
#lc-root .lc-primary:disabled { opacity: .7; cursor: progress; }

/* ---------- pesan ---------- */
#lc-root .lc-chat { position: relative; flex: 1; min-height: 0; display: flex; }
#lc-root .lc-messages { flex: 1; overflow-y: auto; padding: 14px 12px 6px; scroll-behavior: smooth; overscroll-behavior: contain; }
#lc-root .lc-messages::-webkit-scrollbar { width: 6px; }
#lc-root .lc-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
#lc-root .lc-day { text-align: center; margin: 10px 0; }
#lc-root .lc-day span { display: inline-block; font-size: 11.5px; color: var(--lc-muted); background: #eceef2; padding: 3px 10px; border-radius: 10px; }
#lc-root .lc-system { margin: 4px auto 12px; max-width: 92%; text-align: center; font-size: 12.5px; color: #374151; background: var(--lc-soft); border: 1px dashed color-mix(in srgb, var(--lc-color) 30%, #fff); padding: 8px 12px; border-radius: 12px; }
#lc-root .lc-row { display: flex; margin: 4px 0; animation: lc-in .22s ease; }
#lc-root .lc-mine { justify-content: flex-end; }
#lc-root .lc-bubble { max-width: 80%; padding: 8px 11px 5px; border-radius: 16px; position: relative; word-wrap: break-word; overflow-wrap: anywhere; }
#lc-root .lc-theirs .lc-bubble { background: #fff; border: 1px solid var(--lc-line); border-bottom-left-radius: 5px; }
#lc-root .lc-mine .lc-bubble { background: linear-gradient(135deg, var(--lc-color), var(--lc-color-2)); color: #fff; border-bottom-right-radius: 5px; }
#lc-root .lc-who { font-size: 11.5px; font-weight: 700; color: var(--lc-color); margin-bottom: 2px; }
#lc-root .lc-text-content { white-space: pre-wrap; }
#lc-root .lc-text-content a { color: inherit; text-decoration: underline; }
#lc-root .lc-meta { display: flex; align-items: center; justify-content: flex-end; gap: 3px; font-size: 10.5px; opacity: .7; margin-top: 2px; }
#lc-root .lc-tick { width: 16px; height: 12px; display: inline-block; }
#lc-root .lc-tick.lc-read { color: #a7f3d0; opacity: 1; }
#lc-root .lc-img { display: block; margin: 2px 0 4px; border-radius: 10px; overflow: hidden; background: rgba(0,0,0,.05); }
#lc-root .lc-img img { display: block; max-width: 100%; max-height: 220px; object-fit: cover; }
#lc-root .lc-filechip, #lc-root .lc-attach-preview {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 11px; text-decoration: none; color: inherit; margin: 2px 0 4px;
}
#lc-root .lc-theirs .lc-filechip { background: var(--lc-bg); border: 1px solid var(--lc-line); }
#lc-root .lc-mine .lc-filechip { background: rgba(255,255,255,.16); }
#lc-root .lc-fi { width: 30px; height: 30px; flex: none; padding: 5px; border-radius: 8px; background: color-mix(in srgb, var(--lc-color) 14%, #fff); color: var(--lc-color); }
#lc-root .lc-mine .lc-fi { background: rgba(255,255,255,.22); color: #fff; }
#lc-root .lc-fmeta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
#lc-root .lc-fmeta b { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#lc-root .lc-fmeta small { font-size: 11px; opacity: .75; }
#lc-root .lc-fdl { width: 32px; height: 32px; flex: none; padding: 6px; border-radius: 8px; color: inherit; opacity: .9; }
#lc-root .lc-fdl:hover { background: rgba(0,0,0,.08); opacity: 1; }
#lc-root .lc-mine .lc-fdl:hover { background: rgba(255,255,255,.18); }
#lc-root .lc-fbtn { flex: none; font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 7px; border: 1px solid currentColor; color: inherit; text-decoration: none; opacity: .9; }
@keyframes lc-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

#lc-root .lc-drop {
  position: absolute; inset: 8px; border: 2px dashed var(--lc-color); border-radius: 14px; background: color-mix(in srgb, var(--lc-color) 8%, rgba(255,255,255,.9));
  display: none; align-items: center; justify-content: center; color: var(--lc-color); font-weight: 600; pointer-events: none;
}
#lc-root .lc-chat.lc-dragging .lc-drop { display: flex; }

/* ---------- composer ---------- */
#lc-root .lc-composer { padding: 10px 10px 12px; background: #fff; border-top: 1px solid var(--lc-line); position: relative; }
#lc-root .lc-attach-preview { background: var(--lc-soft); border: 1px solid color-mix(in srgb, var(--lc-color) 25%, #fff); margin: 0 0 8px; }
#lc-root .lc-attach-preview .lc-icon-btn { width: 28px; height: 28px; padding: 6px; color: var(--lc-muted); }
#lc-root .lc-compose-row { display: flex; align-items: flex-end; gap: 6px; }
#lc-root .lc-btn-attach { color: var(--lc-muted); }
#lc-root .lc-btn-attach:hover { background: var(--lc-bg); color: var(--lc-color); }
#lc-root .lc-text {
  flex: 1; resize: none; border: 1.5px solid var(--lc-line); border-radius: 18px; padding: 8px 14px; min-height: 38px; max-height: 120px;
  font: inherit; font-size: 14px; color: var(--lc-ink); background: var(--lc-bg); outline: none; margin: 0; line-height: 1.4; box-shadow: none;
}
#lc-root .lc-text:focus { border-color: var(--lc-color); background: #fff; }
#lc-root .lc-send {
  width: 38px; height: 38px; flex: none; border: 0; border-radius: 50%; padding: 9px 9px 9px 10px; color: #fff;
  background: linear-gradient(135deg, var(--lc-color), var(--lc-color-2)); transition: transform .15s, opacity .15s;
}
#lc-root .lc-send:not(:disabled):hover { transform: scale(1.07); }
#lc-root .lc-send:disabled { opacity: .4; cursor: default; }
#lc-root .lc-progress { position: absolute; left: 0; right: 0; top: -1px; height: 3px; background: transparent; }
#lc-root .lc-progress span { display: block; height: 100%; width: 0; background: var(--lc-color); transition: width .15s; }

/* ---------- layar kecil ---------- */
@media (max-width: 480px) {
  #lc-root { right: 14px; bottom: 14px; }
  #lc-root .lc-launcher { width: 56px; height: 56px; }
  #lc-root .lc-panel { position: fixed; inset: 0; width: auto; height: auto; border-radius: 0; bottom: 0; }
  #lc-root.lc-open .lc-launcher { display: none; }
  #lc-root .lc-tooltip { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  #lc-root * { animation: none !important; transition: none !important; }
}

/* ---------- penilaian bintang (v1.2.0) ---------- */
#lc-root .lc-row-rating .lc-bubble { max-width: 92%; }
#lc-root .lc-rate { margin: 8px 0 2px; background: linear-gradient(140deg, #fffbeb, #fff); border: 1px solid #fcd34d; border-radius: 12px; padding: 10px 10px 9px; text-align: center; }
#lc-root .lc-stars { display: flex; justify-content: center; gap: 2px; }
#lc-root .lc-star { border: 0; background: none; padding: 0 2px; font-size: 30px; line-height: 1; color: #d1d5db; transition: transform .15s cubic-bezier(.34,1.56,.64,1), color .1s; }
#lc-root .lc-star.on { color: #f59e0b; }
#lc-root .lc-star:hover { transform: scale(1.18); }
#lc-root .lc-star:focus-visible { outline: 2px solid #f59e0b; outline-offset: 1px; border-radius: 4px; }
#lc-root .lc-rate-lbl { font-size: 12.5px; font-weight: 600; color: #92400e; margin: 4px 0 2px; min-height: 18px; }
#lc-root .lc-rate-cmt { display: none; width: 100%; margin-top: 6px; border: 1px solid #e5e7eb; border-radius: 9px; padding: 7px 9px; font: inherit; font-size: 13px; resize: vertical; min-height: 44px; background: #fff; color: var(--lc-ink); }
#lc-root .lc-rate-cmt:focus { outline: none; border-color: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.18); }
#lc-root .lc-rate-picked .lc-rate-cmt { display: block; }
#lc-root .lc-rate-send { margin-top: 8px; width: 100%; border: 0; border-radius: 9px; padding: 8px 10px; background: #f59e0b; color: #fff; font-weight: 700; }
#lc-root .lc-rate-send:disabled { background: #e5e7eb; color: #9ca3af; cursor: default; }
#lc-root .lc-rate-send:not(:disabled):hover { background: #d97706; }
#lc-root .lc-rate-err { margin-top: 6px; font-size: 12px; color: #b91c1c; }
#lc-root .lc-rate-done .lc-stars-ro { font-size: 26px; }
#lc-root .lc-rate-thanks { font-size: 12.5px; color: var(--lc-muted); }
#lc-root .lc-stars-ro { display: inline-flex; gap: 1px; font-size: 18px; line-height: 1; }
#lc-root .lc-stars-ro i { font-style: normal; color: #d1d5db; }
#lc-root .lc-stars-ro i.on { color: #f59e0b; }
#lc-root .lc-mine .lc-stars-ro i { color: rgba(255,255,255,.35); }
#lc-root .lc-mine .lc-stars-ro i.on { color: #fde68a; }
#lc-root .lc-rres { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
#lc-root .lc-rres-k { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; opacity: .85; }
#lc-root .lc-rres .lc-stars-ro { font-size: 22px; }
#lc-root .lc-rres q { font-style: italic; white-space: pre-wrap; text-align: right; }
