:root {
  --line: #2f2f2f;
  --muted: #a1a1aa;
  --text: #ececec;
  --red: #ef4444;
  --green: #22c55e;
  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --card: #1f1f1f;
  --card-2: #171717;
  --bg: #212121;
  --shadow-lg: 0 18px 60px rgba(0, 0, 0, 0.38);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.24);
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  min-width: 0;
}

html, body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: auto;
  overflow-y: auto;
}

.app {
  width: 100%;
  min-width: 840px;
  height: calc(100vh - 16px);
  min-height: calc(100vh - 16px);
  background: var(--card-2);
  border: 1px solid #2a2a2a;
  border-radius: 20px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 64px 320px minmax(0, 1fr);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.32);
}

.left-rail {
  background: var(--card-2);
  border-right: 1px solid #2a2a2a;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 12px;
  min-height: 0;
}

.rail-bottom {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid #2a2a2a;
  width: calc(100% - 16px);
}

.chat-sidebar {
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.sidebar-header {
  height: 60px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 18px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.2px;
  flex-shrink: 0;
}

.sidebar-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 10px 14px;
}

.sidebar-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  margin: 2px 8px 10px;
  color: var(--text);
}

.sidebar-section .muted-link {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition: 0.18s ease;
  color: var(--text);
  border: 1px solid transparent;
}

.chat-item:hover {
  background: #242424;
  border-color: #2f2f2f;
}

.chat-item.active {
  background: #2a2a2a;
  border-color: #3a3a3a;
  box-shadow: none;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #ffffff;
  flex-shrink: 0;
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
}

.chat-meta {
  min-width: 0;
}

.chat-name {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-preview {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.chat-time {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  align-self: start;
  padding-top: 2px;
}

.chat-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  align-self: stretch;
}

.chat-unread-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.28);
}

.chat-unread-badge.is-large {
  min-width: 22px;
  padding: 0 7px;
}

.chat-menu-label {
  padding: 8px 12px 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.chat-menu-divider {
  height: 1px;
  margin: 6px 4px;
  background: #262626;
}

.chat-menu-item.archive:hover {
  color: #ffd89a;
  background: rgba(245, 158, 11, 0.12);
}

.chat-menu-item.unban:hover {
  color: #b6ffd0;
  background: rgba(34, 197, 94, 0.12);
}

.main {
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.chat-panel {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: 60px minmax(0, 1fr);
}

.chat-header {
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--bg);
  min-width: 0;
}

.chat-title {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chat-info-wrap,
.chat-menu-wrap {
  position: relative;
}

.chat-info-btn svg {
  width: 18px;
  height: 18px;
}

.chat-info-card {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(340px, 86vw);
  padding: 12px;
  border-radius: 16px;
  background: linear-gradient(180deg, #1b1f28 0%, #151922 100%);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 18px 38px rgba(0,0,0,0.36);
  z-index: 40;
}

.chat-info-card__label {
  padding: 2px 2px 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.chat-info-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 8px 2px;
  border-top: 1px solid #2a2a2a;
}

.chat-info-row:first-of-type {
  border-top: 0;
}

.chat-info-key {
  font-size: 12px;
  font-weight: 700;
  color: #aeb6c7;
}

.chat-info-value {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}

.chat-info-card.hidden {
  display: none !important;
}

.chat-info-btn {
  color: var(--muted);
}

.action-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: 0.18s ease;
  font-size: 16px;
}

.action-btn:hover {
  background: #2a2a2a;
  border-color: #3a3a3a;
  color: var(--text);
}

.action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.action-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-menu-wrap {
  position: relative;
}

.chat-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  padding: 8px;
  border-radius: 14px;
  background: #1f1f1f;
  border: 1px solid #343434;
  box-shadow: var(--shadow-md);
  z-index: 50;
}

.chat-menu-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.18s ease;
  text-align: left;
}

.chat-menu-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-menu-item:hover {
  background: #2a2a2a;
}

.chat-menu-item.ban:hover {
  color: #ffb4b4;
  background: rgba(239, 68, 68, 0.10);
}

.chat-menu-item.stop:hover {
  color: #ffb4b4;
  background: rgba(239, 68, 68, 0.14);
}

.chat-menu-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.conversation-wrap {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  overflow: hidden;
}

.messages {
  min-height: 0;
  overflow: auto;
  padding: 18px 22px 14px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;

  /* cegah browser auto-scroll anchoring bentrok dengan restore scrollTop manual */
  overflow-anchor: none;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;

  /* PERF */
  scrollbar-gutter: stable;
  will-change: scroll-position;
  contain: paint;
}

.scroll-bottom-btn {
  position: absolute;
  left: 50%;
  right: auto;
  bottom: 110px;
  transform: translateX(-50%);
  width: 42px;
  height: 42px;
  border: 1px solid #3a3a3a;
  border-radius: 999px;
  background: #2a2a2a;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 26;
  box-shadow: var(--shadow-md);
  transition: transform 0.18s ease, filter 0.18s ease, opacity 0.18s ease;
  will-change: transform, opacity;
}

.scroll-bottom-btn:hover {
  filter: brightness(1.06);
  transform: translateX(-50%) translateY(-1px);
}

.scroll-bottom-btn:active {
  transform: translateX(-50%) translateY(0);
}

.scroll-bottom-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.message-block {
  width: 100%;
  display: flex;
}

.message-block.left {
  justify-content: flex-start;
}

.message-block.right {
  justify-content: flex-end;
}

.message-shell {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  width: fit-content;
  max-width: min(78%, 760px);
}

.message-block.right .message-shell {
  flex-direction: row-reverse;
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}

.message-block.left .message-content {
  align-items: flex-start;
}

.message-block.right .message-content {
  align-items: flex-end;
}

.sender-name {
  font-size: 11px;
  color: var(--muted);
  padding: 0 4px;
  margin: 0;
}

.message-block.is-grouped .sender-name {
  display: none;
}

.message-block.is-grouped .message-shell {
  align-items: flex-start;
}

.avatar-spacer {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  visibility: hidden;
  pointer-events: none;
}

.bubble.left {
  background: #2a2a2a;
  color: var(--text);
  border: 1px solid #343434;
  border-top-left-radius: 8px;
}

.bubble.right {
  background: #2f6fed;
  color: #fff;
  border: 1px solid transparent;
  border-top-right-radius: 8px;
}

.tiny-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  flex-shrink: 0;
  box-shadow: none;
}

.agent-avatar {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  color: var(--text);
  background: radial-gradient(circle at 30% 30%, #f8d866, #7a100d 60%, #1a0d0b 100%);
  border: 2px solid #d39b1b;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}

.agent-avatar.has-photo {
  background: #101216;
  border-color: rgba(255,255,255,0.14);
}

.system-line {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  background: #262626;
  border: 1px solid #343434;
  padding: 8px 12px;
  border-radius: 999px;
  margin-top: 8px;
}

.system-line.system-line-separator {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin: 8px 0 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.system-line.system-line-separator::before,
.system-line.system-line-separator::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: #343434;
  min-width: 24px;
}

.system-line.system-line-separator > .system-line-separator__label {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  /* pertahankan tampilan bubble lama */
  color: var(--muted);
  font-size: 12px;
  background: #262626;
  border: 1px solid #343434;
  padding: 8px 12px;
  border-radius: 999px;

  line-height: 1;
  white-space: nowrap;
}

/* hanya untuk event tertentu yang memang ingin kecil di kanan */
.system-line.system-line-event {
  align-self: flex-end;
  display: block;
  width: fit-content;
  margin-left: auto;
  margin-right: 40px; /* 32px avatar + 8px gap */
  max-width: min(calc(78% - 40px), 520px);
  background: transparent;
  border: 0;
  padding: 0;
  border-radius: 0;
  font-size: 11px;
  line-height: 1.45;
  text-align: right;
  color: var(--muted);
  white-space: normal;
  word-break: break-word;
}

.composer {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  flex-shrink: 0;
  position: relative;
}

.typing-preview {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #343434;
  background: #262b36;
  box-shadow: none;
}

.typing-preview-label {
  font-size: 11px;
  font-weight: 700;
  color: #bfdbfe;
  margin-bottom: 4px;
}

.typing-preview-text {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 72px;
  overflow: auto;
}

.typing-message-block {
  opacity: 1;
}

.typing-message-block .message-shell {
  gap: 8px;
  align-items: center;
  max-width: min(58%, 520px);
}

.typing-message-block .message-content {
  gap: 4px;
}

.typing-message-block .sender-name {
  font-size: 12px;
  color: var(--muted);
  padding: 0 2px;
}

.bubble.left.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  padding: 7px 11px;
  border-radius: 14px;
  border-top-left-radius: 14px;
  background: #262626;
  color: var(--muted);
  border: 1px solid #343434;
  box-shadow: none;
}

.typing-bubble-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: #1f1f1f;
  border: 1px solid #343434;
}

.typing-bubble-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.typing-bubble-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: auto;
}

.typing-bubble-dots span {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: #c4c4c7;
  opacity: 0.28;
  animation: typingBubblePulse 1.1s infinite ease-in-out;
}

.typing-bubble-dots span:nth-child(2) {
  animation-delay: 0.12s;
}

.typing-bubble-dots span:nth-child(3) {
  animation-delay: 0.24s;
}

@keyframes typingBubblePulse {
  0%, 80%, 100% {
    opacity: 0.28;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-1px);
  }
}

.emoji-picker {
  position: absolute;
  right: 16px;
  bottom: 72px;
  width: min(280px, calc(100% - 32px));
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  padding: 12px;
  background: #1f1f1f;
  border: 1px solid #343434;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  z-index: 30;
}

.emoji-item {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 0;
  border-radius: 10px;
  background: #2a2a2a;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
}

.emoji-item:hover {
  background: #343434;
  transform: scale(1.05);
}

.composer-box {
  min-height: 72px;
  background: #171717;
  border: 1px solid #343434;
  border-radius: 18px;
  display: flex;
  align-items: flex-end;
  padding: 10px 12px;
  gap: 8px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}

.composer-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-end;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
}

.composer-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.composer-icon:hover {
  background: #262626;
  color: var(--text);
  transform: scale(1.04);
}

.composer-icon:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
}

.emoji-btn.active {
  background: #262626;
  color: var(--text);
}

.composer-input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  min-width: 0;
  resize: none;
  overflow-y: auto;
  min-height: 52px;
  max-height: 140px;
  padding: 14px 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.composer-input::placeholder {
  color: var(--muted);
}

.composer-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.bubble {
  padding: 12px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  max-width: 100%;

  /* PERF: kurangi blur radius 24px → 10px, visual hampir identik tapi 2-3x lebih murah */
  box-shadow: none;
}

.send-btn {
  height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: #2f6fed;
  color: #fff;
  border: 1px solid transparent;
  font-weight: 700;
  cursor: pointer;
  transition: 0.18s ease;
  flex-shrink: 0;
  align-self: flex-end;
}
.send-btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.send-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
  filter: none;
  transform: none;
}

.quick-response-menu {
  position: absolute;
  left: 16px;
  bottom: 82px;
  width: min(332px, calc(100% - 32px));
  max-height: min(480px, 54vh);
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid #343434;
  background: #1f1f1f;
  box-shadow: var(--shadow-lg);
  z-index: 35;
}

.quick-response-list {
  max-height: min(430px, 49vh);
  overflow: auto;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.quick-response-list::-webkit-scrollbar {
  width: 10px;
}

.quick-response-list::-webkit-scrollbar-track {
  background: transparent;
}

.quick-response-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.14);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.quick-response-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
  border: 2px solid transparent;
  background-clip: padding-box;
}

.quick-response-item {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px 0 16px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
  text-align: left;
  position: relative;
}

.quick-response-item:hover {
  background: rgba(255,255,255,0.04);
}

.quick-response-item.active {
  background: #343434;
}

.quick-response-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: #3b82f6;
}

.quick-response-item-left {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
}

.quick-response-shortcut-main {
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0;
}

.quick-response-item-right {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.quick-response-shortcut-more {
  min-width: 16px;
  text-align: right;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 0;
}

.quick-response-chevron {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  opacity: 0.9;
}

.quick-response-chevron svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 760px) {
  .quick-response-menu {
    left: 12px;
    bottom: 74px;
    width: min(332px, calc(100% - 24px));
    max-height: min(420px, 50vh);
  }

  .quick-response-list {
    max-height: min(370px, 44vh);
  }

  .quick-response-item {
    min-height: 40px;
    padding: 0 12px 0 14px;
  }

  .quick-response-shortcut-main {
    font-size: 14px;
  }

  .composer-box {
    min-height: 66px;
    padding: 9px 10px;
    border-radius: 16px;
  }

  .composer-input {
    min-height: 46px;
    padding: 12px 0;
  }

  .composer-icon,
  .send-btn {
    height: 40px;
  }
}

.sidebar-content::-webkit-scrollbar, .messages::-webkit-scrollbar {
  width: 10px;
}

.sidebar-content::-webkit-scrollbar-track, .messages::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb, .messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.10);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.sidebar-content::-webkit-scrollbar-thumb:hover, .messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.16);
  border: 2px solid transparent;
  background-clip: padding-box;
}

@media (max-width: 1200px) {
  .app {
    grid-template-columns: 64px 290px minmax(0, 1fr);
  }

  .message-shell {
    max-width: min(84%, 720px);
  }
}

@media (max-width: 980px) {
  body {
    padding: 0;
  }

  .app {
    height: 100vh;
    min-height: 100vh;
    min-width: 780px;   
    border-radius: 0;
    max-width: none;
    grid-template-columns: 64px 280px minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 64px minmax(0, 1fr);
    min-width: 380px;  
  }

  .chat-sidebar {
    display: none;
  }

  .messages {
    padding: 16px 14px 12px;
  }

  .composer {
    padding: 10px 12px 12px;
  }

  .message-shell {
    max-width: 92%;
  }

  .quick-response-menu {
    left: 12px;
    right: 12px;
    bottom: 74px;
    max-height: min(330px, 50vh);
  }

  .quick-response-list {
    max-height: min(230px, 32vh);
  }

  .scroll-bottom-btn {
    left: 50%;
    right: auto;
    bottom: 96px;
    transform: translateX(-50%);
  }
}

.composer-input::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.composer-input::-webkit-scrollbar-track {
  background: transparent;
}

.composer-input::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(122, 122, 128, 0.9);
  border: 2px solid transparent;
  background-clip: padding-box;
}

.composer-input::-webkit-scrollbar-thumb:hover {
  background: rgba(166, 166, 173, 0.92);
}

/* ============================================
   CLOSED CHAT STATE — gaya mirip livechat
   ============================================ */

.chat-item.is-closed .chat-name, .chat-item.is-closed .chat-preview {
  opacity: 0.68;
}

/* Chat yang sudah diread — sedikit lebih redup dari yg belum diread */
.chat-item.is-read .chat-name {
  opacity: 0.72;
}

.chat-item.is-read .chat-preview {
  opacity: 0.72;
}

.chat-item.is-read .chat-time {
  opacity: 0.62;
}

/* hapus pseudo label lama supaya tidak dobel dengan label dari JS */

.chat-item.is-closed .chat-name::after {
  content: "";
}

/* panel bawah, bukan overlay fullscreen */

/* ============================================
   CLOSED CHAT STATE
   ============================================ */

.conversation-closed-overlay {
  display: none;
  position: relative;
  z-index: 6;
  align-items: center;
  justify-content: center;
  padding: 20px 16px 22px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.conversation-closed-overlay.visible {
  display: flex;
}

.closed-chat-banner {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: center;
}

.closed-chat-reason {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  color: var(--text);
  text-align: center;
}

.closed-chat-reason strong {
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
  font-weight: 600;
}

.closed-chat-reason small {
  display: none;
}

.open-chat-btn {
  min-height: 34px;
  min-width: 92px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: #2f6fed;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  transition: opacity 0.18s ease, background-color 0.18s ease;
}

.open-chat-btn:hover:not(:disabled),
.open-chat-btn:active:not(:disabled) {
  box-shadow: none;
  filter: none;
  transform: none;
}

.open-chat-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  filter: none;
  transform: none;
}

.open-chat-btn svg {
  display: none;
}

/* chat tetap bisa dibaca & discroll, hanya sedikit dibedakan */

.messages.is-dimmed {
  opacity: 0.88;
  filter: saturate(0.9);
}

/* ============================================
   IMAGE MESSAGING
   ============================================ */

/* Upload preview strip di atas composer */

.image-upload-preview {
  display: none;
  padding: 10px 16px 0;
  background: var(--bg);
}

.image-upload-preview.visible {
  display: block;
}

.image-preview-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #262626;
  border: 1px solid #343434;
  max-width: 100%;
}

.image-preview-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: #1f1f1f;
  flex-shrink: 0;
}

.image-preview-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.image-preview-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.image-preview-size {
  font-size: 11px;
  color: var(--muted);
}

.image-preview-remove {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 0;
  background: rgba(239,68,68,0.12);
  color: #ef4444;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.18s ease;
}

.image-preview-remove:hover {
  background: rgba(239,68,68,0.22);
}

.image-preview-remove svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Grouped text tetap sedikit rapat, tapi aman */

.message-block.is-grouped {
  margin-top: -2px;
}

/* Image dirapatkan secukupnya, jangan sampai tabrakan */

.message-block.is-image {
  margin-top: -4px;
}

/* Antar image dibuat paling rapat, tapi tetap ada napas */

.message-block.is-image + .message-block.is-image {
  margin-top: -5px;
}

/* Kalau image juga grouped, rapatkan sedikit lagi */

.message-block.is-grouped.is-image {
  margin-top: -5px;
}

.message-block.is-grouped.is-image + .message-block.is-image {
  margin-top: -6px;
}

.bubble.bubble-media {
  padding: 0;
  overflow: hidden;
  border-radius: 16px;
  max-width: min(200px, 60vw);
  background: transparent;
  box-shadow: none;
  white-space: normal;
  line-height: 0;
}

.bubble.bubble-media .bubble-image-caption {
  white-space: pre-wrap;
  line-height: 1.42;
}

.bubble.bubble-media.has-caption {
  max-width: min(260px, 60vw);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 8px 24px rgba(0,0,0,0.14);
}

.bubble.left.bubble-media.has-caption {
  background: #2a2a2a;
}

.bubble.right.bubble-media.has-caption {
  background: #2f6fed;
}

.bubble-image-wrap {
  width: 100%;
  max-width: 100%;
  border-radius: 16px;
  overflow: hidden;
  cursor: zoom-in;
  position: relative;
  line-height: 0;
  background: #1f1f1f;
}

.bubble.bubble-media.has-caption .bubble-image-wrap {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.bubble-image-wrap img {
  width: 100%;
  max-height: min(200px, 44vh);
  object-fit: cover;
  display: block;
  border-radius: inherit;
  background: #1f1f1f;
  transition: transform 0.18s ease, filter 0.18s ease;
}

/* Transisi text ke image / image ke text */

.message-block.is-text + .message-block.is-image, .message-block.is-image + .message-block.is-text {
  margin-top: -3px;
}

/* Jarak nama pengirim ke bubble image */

.message-block.is-image .message-content {
  gap: 2px;
}

.bubble-image-wrap:hover img {
  filter: brightness(0.97);
  transform: scale(1.01);
}

.bubble-image-wrap .image-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.24);
  color: var(--text);
  font-size: 12px;
  border-radius: inherit;
}

/* Caption di bawah gambar */

.bubble-image-caption {
  padding: 8px 11px 6px;
  font-size: 13px;
  line-height: 1.42;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}

.bubble.left.bubble-media .bubble-image-caption, .bubble.right.bubble-media .bubble-image-caption {
  color: #fff;
}

/* Lightbox */

.image-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  padding: 20px;
  background: rgba(5, 7, 11, 0.76);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.image-lightbox.visible {
  display: flex;
}

.image-lightbox img {
  max-width: min(94vw, 1180px);
  max-height: calc(100vh - 48px);
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 18px 54px rgba(0,0,0,0.22);
  cursor: default;
}

.lightbox-toolbar {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 10000;
}

.lightbox-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid #3a3a3a;
  background: rgba(23, 23, 23, 0.88);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s ease, transform 0.18s ease;
  backdrop-filter: blur(3px);
}

.lightbox-btn:hover {
  background: #323232;
  transform: translateY(-1px);
}

.lightbox-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 640px) {
  .bubble.bubble-media {
    max-width: min(180px, 68vw);
  }

  .image-lightbox {
    padding: 12px;
  }

  .lightbox-toolbar {
    top: 12px;
    right: 12px;
  }
}

/* Drag overlay */

.drag-overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(47, 111, 237, 0.12);
  border: 2px dashed rgba(59, 130, 246, 0.45);
  border-radius: 16px;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drag-overlay.visible {
  display: flex;
}

.drag-overlay-label {
  font-size: 15px;
  font-weight: 700;
  color: #bfdbfe;
  background: rgba(23, 23, 23, 0.88);
  padding: 12px 24px;
  border-radius: 12px;
}

/* ============================================
   MESSAGE TIMESTAMP + READ STATUS
   ============================================ */

.bubble-footer {
  display: inline-flex;
  float: right;
  clear: right;
  align-items: center;
  gap: 2px;
  margin: 5px 0 -3px 6px;
  line-height: 1;
  user-select: none;
  pointer-events: none;
}

.bubble-footer-spacer {
  display: inline-block;
  width: 0;
  height: 1px;
  vertical-align: baseline;
  pointer-events: none;
  user-select: none;
}

.bubble-time {
  font-size: 10.5px;
  color: rgba(255,255,255,0.5);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.bubble.right .bubble-time {
  color: rgba(255,255,255,0.55);
}

.bubble-check {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 0;
}

.bubble-check svg {
  width: 18px;
  height: 11px;
}

.bubble-check.is-sent {
  color: rgba(255,255,255,0.5);
}

.bubble-check.is-read {
  color: #60a5fa;
}

/* Footer di dalam caption gambar */
.bubble-image-caption .bubble-footer {
  margin: 2px 0 -3px 8px;
}

/* Footer overlay di gambar tanpa caption */
.bubble-footer-overlay {
  position: absolute;
  right: 6px;
  bottom: 5px;
  margin: 0;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(0,0,0,0.52);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  pointer-events: none;
}

.bubble-footer-overlay .bubble-time {
  color: rgba(255,255,255,0.88);
}

.bubble-footer-overlay .bubble-check.is-sent {
  color: rgba(255,255,255,0.62);
}

.bubble-footer-overlay .bubble-check.is-read {
  color: #60a5fa;
}

/* ============================================
   CHAT LIST TYPING PREVIEW
   ============================================ */

.chat-typing-preview {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #93c5fd;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.chat-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 2.5px;
  flex-shrink: 0;
}

.chat-typing-dots span {
  width: 3.5px;
  height: 3.5px;
  border-radius: 50%;
  background: #93c5fd;
  opacity: 0.3;
  animation: chatListTypingPulse 1.1s infinite ease-in-out;
}

.chat-typing-dots span:nth-child(2) {
  animation-delay: 0.13s;
}

.chat-typing-dots span:nth-child(3) {
  animation-delay: 0.26s;
}

@keyframes chatListTypingPulse {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  40% {
    opacity: 1;
    transform: scale(1.15);
  }
}

/* ============================================
   CHAT LIST SKELETON PLACEHOLDER
   ============================================ */

.chat-skeleton {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-skeleton-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 10px;
  animation: chatSkeletonPulse 1.6s ease-in-out infinite;
}

.chat-skeleton-item:nth-child(2) {
  animation-delay: 0.2s;
}

.chat-skeleton-item:nth-child(3) {
  animation-delay: 0.4s;
}

.chat-skeleton-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #262626;
  flex-shrink: 0;
}

.chat-skeleton-lines {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-skeleton-line {
  height: 10px;
  border-radius: 5px;
  background: #262626;
}

.chat-skeleton-line.wide {
  width: 70%;
}

.chat-skeleton-line.narrow {
  width: 45%;
}

@keyframes chatSkeletonPulse {
  0%, 100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

/* Rail profile avatar — ikuti shared layout/dashboard */
.rail-icon .rail-avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.rail-icon.has-avatar {
  padding: 0;
  overflow: hidden;
}

.rail-icon.has-avatar svg {
  display: none;
}

@media (max-height: 760px) {
  .app {
    height: auto;
    min-height: 100vh;
  }
}

/* =========================================================
   PATCH: Quick response tampilkan semua hasil saat ketik #
   - tampilkan kira-kira 10 item terlebih dahulu
   - sisanya bisa discroll di dalam dropdown
   - tidak mengubah struktur/fungsi lain
   ========================================================= */

.quick-response-menu {
  --qr-visible-count: 10;
  --qr-item-height: 42px;
  --qr-list-padding-y: 8px;

  max-height: min(
    calc((var(--qr-item-height) * var(--qr-visible-count)) + (var(--qr-list-padding-y) * 2)),
    54vh
  );
}

.quick-response-list {
  max-height: min(
    calc((var(--qr-item-height) * var(--qr-visible-count)) + (var(--qr-list-padding-y) * 2)),
    54vh
  );
  overflow-y: auto;
  padding: var(--qr-list-padding-y) 0;
}

@media (max-width: 760px) {
  .quick-response-menu {
    --qr-item-height: 40px;

    max-height: min(
      calc((var(--qr-item-height) * var(--qr-visible-count)) + (var(--qr-list-padding-y) * 2)),
      50vh
    );
  }

  .quick-response-list {
    max-height: min(
      calc((var(--qr-item-height) * var(--qr-visible-count)) + (var(--qr-list-padding-y) * 2)),
      50vh
    );
  }
}

/* =========================================================
   PATCH: review respon cepat
   - klik item quick response tidak langsung masuk ke input
   - tampilkan preview lebih dulu
   - tombol "Gunakan" baru memasukkan isi ke kolom input
   ========================================================= */

.quick-response-menu.is-preview {
  width: min(420px, calc(100% - 32px));
}

.quick-response-preview {
  max-height: inherit;
}

.quick-response-preview__row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 10px 10px 8px;
}

.quick-response-preview__back {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 0.18s ease;
  margin-top: 0;
  align-self: center;
}

.quick-response-preview__back:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text);
}

.quick-response-preview__back svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.quick-response-preview__content {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  display: block;
  padding: 4px 8px 8px 4px;
  font: inherit;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  max-height: min(280px, 36vh);
  cursor: pointer;
  transition: background 0.18s ease;
}

.quick-response-preview__content:hover {
  background: rgba(255,255,255,0.03);
}

.quick-response-preview__content:focus-visible {
  outline: none;
  background: rgba(255,255,255,0.04);
}

@media (max-width: 760px) {
  .quick-response-menu.is-preview {
    left: 12px;
    right: 12px;
    width: auto;
    max-height: min(440px, 58vh);
  }

  .quick-response-preview__row {
    gap: 4px;
    padding: 10px 10px 10px 6px;
  }

  .quick-response-preview__content {
    max-height: min(240px, 32vh);
    font-size: 13px;
    padding: 4px 6px 8px 2px;
  }
}

/* =========================================================
   PATCH: tombol scroll dipindah tepat di atas blok input
   + panel/background lebar di belakang input disembunyikan
   - hanya ubah tampilan, logic/fungsi tetap
   ========================================================= */

.conversation-wrap {
  --composer-dock-offset: 116px;
  --composer-elastic-min-height: 96px;
  --composer-elastic-input-min-height: 38px;
  --composer-elastic-input-max-height: 260px;
  --composer-elastic-input-padding-y: 7px;
}

.composer {
  padding: 8px 16px 10px;
  border-top: 0;
  background: transparent;
  box-shadow: none;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}

.image-upload-preview {
  padding: 8px 16px 0;
  background: transparent;
  box-shadow: none;
}

.composer-box {
  min-height: var(--composer-elastic-min-height);
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 18px;
  background: #171717;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.03),
    0 0 0 1px rgba(255,255,255,0.03);
}

.composer-box:focus-within {
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    0 0 0 1px rgba(255,255,255,0.05);
}

.composer-main {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
}

.composer-tools {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.composer-input {
  width: 100%;
  min-height: var(--composer-elastic-input-min-height);
  max-height: var(--composer-elastic-input-max-height);
  padding: var(--composer-elastic-input-padding-y) 4px;
  display: block;
  box-sizing: border-box;
  border: 0;
  outline: none;
  background: transparent;
  resize: none;
  font-size: 15px;
  line-height: 1.58;
  color: var(--text);
  overflow-x: hidden;
  overflow-y: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  flex: 0 0 auto;
  align-self: stretch;
  scrollbar-width: thin;
  scrollbar-color: rgba(122, 122, 128, 0.9) transparent;
}

.composer-icon {
  width: 38px;
  height: 38px;
  align-self: center;
}

.shortcut-btn svg {
  width: 18px;
  height: 18px;
}

.send-btn {
  height: 38px;
  align-self: center;
  margin-left: auto;
}

.quick-response-menu {
  bottom: calc(100% - 10px);
}

.emoji-picker {
  right: 16px;
  bottom: calc(100% - 10px);
}

.scroll-bottom-btn {
  left: 50%;
  right: auto;
  bottom: var(--composer-dock-offset);
  transform: translateX(-50%);
  z-index: 7;
}

.scroll-bottom-btn:hover {
  filter: brightness(1.06);
  transform: translateX(-50%) translateY(-1px);
}

.scroll-bottom-btn:active {
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 760px) {
  .conversation-wrap {
    --composer-dock-offset: 108px;
    --composer-elastic-min-height: 88px;
    --composer-elastic-input-min-height: 34px;
    --composer-elastic-input-max-height: 180px;
    --composer-elastic-input-padding-y: 6px;
  }

  .composer {
    padding: 8px 12px 10px;
  }

  .image-upload-preview {
    padding: 8px 12px 0;
    background: transparent;
  }

  .composer-box {
    padding: 9px 10px;
    border-radius: 18px;
  }

  .composer-input {
    font-size: 14px;
  }

  .composer-toolbar {
    gap: 8px;
  }

  .composer-tools {
    gap: 6px;
  }

  .composer-icon,
  .send-btn {
    height: 36px;
  }

  .composer-icon {
    width: 36px;
  }

  .quick-response-menu {
    left: 12px;
    right: 12px;
    width: auto;
    bottom: calc(100% - 8px);
  }

  .emoji-picker {
    left: 12px;
    right: 12px;
    width: auto;
    bottom: calc(100% - 8px);
  }
}

/* =========================================================
   PATCH: emoji panel pindah ke kiri & sejajar dengan panel #
   - emoji dan quick response memakai anchor kiri yang sama
   - hanya tampilan, tidak mengubah logic lain
   ========================================================= */

.emoji-picker {
  left: 16px;
  right: auto;
  width: min(332px, calc(100% - 32px));
  bottom: calc(100% - 10px);
  max-height: min(480px, 54vh);
  z-index: 36;
}

@media (max-width: 760px) {
  .emoji-picker {
    left: 12px;
    right: 12px;
    width: auto;
    bottom: calc(100% - 8px);
  }
}
