/* CLINED — Discord-style Right Member Sidebar (PC, Tablet & iPad ≥768px). Mobile phones (<768px) untouched. */
.ms-sidebar,
.ms-reopen,
.ms-backdrop {
  display: none;
}

@media (min-width: 768px) {
  :root {
    --ms-w: 268px;
    --ms-half: 134px;
  }

  /* Overlay backdrop for tablet/iPad portrait (768px–1023px) */
  .ms-backdrop {
    position: fixed;
    inset: 0;
    z-index: 895;
    background: rgba(15, 23, 42, 0.34);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    display: block;
  }
  body.ms-open:not(.quiz-context):not(.auth-pending) .ms-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .ms-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--ms-w);
    z-index: 900;
    display: flex;
    flex-direction: column;
    background: var(--card, #ffffff);
    border-left: 1.5px solid var(--line, #e2e8e4);
    box-shadow: -8px 0 28px rgba(15, 23, 42, 0.12);
    color: var(--text, #1f2a23);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
    font-family: inherit;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  body.dark .ms-sidebar,
  html.dark .ms-sidebar {
    background: #14171f;
    border-left-color: rgba(255, 255, 255, 0.08);
    box-shadow: -10px 0 32px rgba(0, 0, 0, 0.42);
    color: #eef2f7;
  }
  body:not(.ms-open) .ms-sidebar,
  body.quiz-context .ms-sidebar,
  body.auth-pending .ms-sidebar {
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
  }

  /* Floating tab to open/reopen when collapsed */
  .ms-reopen {
    position: fixed;
    top: calc(14px + env(safe-area-inset-top, 0px));
    right: 14px;
    z-index: 890;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 38px;
    padding: 0 13px;
    border-radius: 13px;
    border: 1.5px solid var(--line, #dbe4de);
    border-bottom-width: 3px;
    background: var(--card, #ffffff);
    color: var(--text, #1f2a23);
    font: 800 12.5px/1 inherit;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.1);
    transition: transform 0.16s ease, box-shadow 0.16s ease;
  }
  .ms-reopen:hover {
    transform: translateY(-1px);
  }
  body.dark .ms-reopen,
  html.dark .ms-reopen {
    background: #1b202b;
    border-color: rgba(255, 255, 255, 0.12);
    color: #eef2f7;
  }
  .ms-reopen-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.8);
  }
  body.ms-open .ms-reopen,
  body.quiz-context .ms-reopen,
  body.auth-pending .ms-reopen {
    display: none !important;
  }

  /* Sidebar Header */
  .ms-head {
    flex: none;
    padding: 14px 12px 10px;
    border-bottom: 1.5px solid var(--line, #e6ece8);
    display: grid;
    gap: 9px;
  }
  body.dark .ms-head,
  html.dark .ms-head {
    border-bottom-color: rgba(255, 255, 255, 0.07);
  }
  .ms-head-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .ms-title {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13.5px;
    font-weight: 900;
    letter-spacing: -0.01em;
  }
  .ms-online-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 99px;
    background: rgba(34, 197, 94, 0.14);
    color: #15803d;
    font-size: 11px;
    font-weight: 900;
  }
  body.dark .ms-online-pill,
  html.dark .ms-online-pill {
    background: rgba(34, 197, 94, 0.18);
    color: #4ade80;
  }
  .ms-online-pill i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.85);
    display: inline-block;
  }
  .ms-hide-btn {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    border: 1.5px solid var(--line, #dbe4de);
    background: var(--surface, #f3f6f4);
    color: var(--muted, #64748b);
    font: 900 16px/1 inherit;
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 0;
  }
  .ms-hide-btn:hover {
    color: var(--text, #1f2a23);
  }
  body.dark .ms-hide-btn,
  html.dark .ms-hide-btn {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
  }
  .ms-search {
    width: 100%;
    height: 36px;
    min-height: 36px !important;
    padding: 0 11px !important;
    border-radius: 10px !important;
    border: 1.5px solid var(--line, #dbe4de) !important;
    background: var(--surface, #f4f7f5) !important;
    color: inherit !important;
    font-size: 13px !important;
    font-weight: 700 !important;
  }
  .ms-search:focus {
    outline: none;
    border-color: var(--sky, #1cb0f6) !important;
  }
  body.dark .ms-search,
  html.dark .ms-search {
    background: #0d0f14 !important;
    border-color: rgba(255, 255, 255, 0.09) !important;
    color: #e2e8f0 !important;
  }

  /* Scrollable Member List */
  .ms-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 10px 8px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.25) transparent;
  }
  .ms-body::-webkit-scrollbar {
    width: 5px;
  }
  .ms-body::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.28);
    border-radius: 99px;
  }

  .ms-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .ms-group-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 8px 3px;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted, #64748b);
    user-select: none;
  }
  body.dark .ms-group-hdr,
  html.dark .ms-group-hdr {
    color: #949ba4;
  }
  .ms-group-toggle {
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    border-radius: 8px;
    cursor: pointer;
  }
  .ms-group-toggle:hover {
    background: rgba(100, 116, 139, 0.08);
  }

  /* Member Row — Discord style with nameplate/banner support */
  .ms-row {
    position: relative;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 6px 8px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    transition: background 0.14s ease, transform 0.14s ease;
  }
  .ms-row:hover {
    background: rgba(100, 116, 139, 0.1);
  }
  body.dark .ms-row:hover,
  html.dark .ms-row:hover {
    background: rgba(255, 255, 255, 0.06);
  }
  .ms-row.is-offline {
    opacity: 0.56;
  }
  .ms-row.is-offline:hover {
    opacity: 0.92;
  }

  /* Equipped Nameplate / Banner background */
  .ms-row.has-banner {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  }
  .ms-row.has-banner::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(10, 14, 22, 0.72) 0%, rgba(10, 14, 22, 0.44) 62%, rgba(10, 14, 22, 0.22) 100%);
    pointer-events: none;
    z-index: 0;
    transition: background 0.15s ease;
  }
  .ms-row.has-banner:hover::before {
    background: linear-gradient(90deg, rgba(10, 14, 22, 0.62) 0%, rgba(10, 14, 22, 0.34) 62%, rgba(10, 14, 22, 0.16) 100%);
  }
  .ms-row.has-banner > * {
    position: relative;
    z-index: 1;
  }
  .ms-row.has-banner .ms-name:not([data-name-color]) {
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  }
  .ms-row.has-banner .ms-sub {
    color: rgba(255, 255, 255, 0.84);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
  }

  /* Avatar + Decoration + Presence Dot */
  .ms-av {
    position: relative;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 12.5px;
    font-weight: 900;
    flex: none;
    overflow: visible;
  }
  .ms-av > img.ms-av-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
  }
  .ms-av .avatar-deco-img {
    position: absolute;
    inset: -18%;
    width: 136%;
    height: 136%;
    max-width: none;
    pointer-events: none;
    z-index: 3;
    object-fit: contain;
  }
  .ms-av::after {
    content: "";
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid var(--card, #ffffff);
    background: #94a3b8;
    z-index: 4;
  }
  body.dark .ms-av::after,
  html.dark .ms-av::after {
    border-color: #14171f;
    background: #5c6370;
  }
  .ms-av.on::after {
    background: #22c55e;
    box-shadow: 0 0 7px 1px rgba(34, 197, 94, 0.85);
  }

  /* Member Name & Meta */
  .ms-meta {
    min-width: 0;
    display: grid;
    gap: 1px;
  }
  .ms-name-line {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
  }
  .ms-name {
    font-size: 13px;
    font-weight: 800;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .ms-role-tag {
    flex: none;
    padding: 1px 5px;
    border-radius: 5px;
    font-size: 9.5px;
    font-weight: 900;
    letter-spacing: 0.02em;
    line-height: 1.35;
  }
  .ms-role-tag.admin {
    background: rgba(245, 158, 11, 0.22);
    color: #b45309;
  }
  body.dark .ms-role-tag.admin,
  html.dark .ms-role-tag.admin,
  .ms-row.has-banner .ms-role-tag.admin {
    background: rgba(245, 158, 11, 0.28);
    color: #fde68a;
  }
  .ms-role-tag.helper {
    background: rgba(28, 176, 246, 0.2);
    color: #0369a1;
  }
  body.dark .ms-role-tag.helper,
  html.dark .ms-role-tag.helper,
  .ms-row.has-banner .ms-role-tag.helper {
    background: rgba(28, 176, 246, 0.28);
    color: #bae6fd;
  }
  .ms-role-tag.mentor {
    background: rgba(88, 204, 2, 0.2);
    color: #2f7d00;
  }
  body.dark .ms-role-tag.mentor,
  html.dark .ms-role-tag.mentor,
  .ms-row.has-banner .ms-role-tag.mentor {
    background: rgba(88, 204, 2, 0.28);
    color: #bbf7d0;
  }
  .ms-role-tag.me {
    background: rgba(139, 92, 246, 0.2);
    color: #6d28d9;
  }
  body.dark .ms-role-tag.me,
  html.dark .ms-role-tag.me,
  .ms-row.has-banner .ms-role-tag.me {
    background: rgba(139, 92, 246, 0.34);
    color: #e9d5ff;
  }
  .ms-xp100k {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 1px 6px;
    border-radius: 99px;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 0.02em;
    line-height: 1.4;
    color: #422006;
    background: linear-gradient(120deg, #fde68a 0%, #fbbf24 50%, #f59e0b 100%);
    border: 1px solid rgba(217, 119, 6, 0.55);
    box-shadow: 0 1px 4px rgba(245, 158, 11, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.65);
    white-space: nowrap;
  }
  body.dark .ms-xp100k,
  html.dark .ms-xp100k,
  .ms-row.has-banner .ms-xp100k,
  .ms-pop-hero.has-banner .ms-xp100k {
    color: #fef3c7;
    background: linear-gradient(120deg, rgba(180, 83, 9, 0.92), rgba(217, 119, 6, 0.95));
    border-color: rgba(253, 224, 71, 0.72);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  }
  .ms-sub {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted, #64748b);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  body.dark .ms-sub,
  html.dark .ms-sub {
    color: #949ba4;
  }

  .ms-unread {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 99px;
    background: #ef4444;
    color: #fff;
    font-size: 10.5px;
    font-weight: 900;
    display: grid;
    place-items: center;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.45);
  }

  .ms-empty {
    padding: 20px 10px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted, #64748b);
  }
}

/* Docked side-by-side layout on PC & iPad/Tablet Landscape (≥1024px) */
@media (min-width: 1024px) {
  :root {
    --ms-w: 248px;
    --ms-half: 124px;
  }
  .ms-backdrop {
    display: none !important;
  }
  .ms-sidebar {
    box-shadow: -8px 0 28px rgba(15, 23, 42, 0.06);
  }
  body.ms-open {
    padding-right: var(--ms-w) !important;
  }
  body.ms-open.quiz-context {
    padding-right: 0 !important;
  }
  body.ms-open .floating-dashboard-nav {
    left: calc(50% - var(--ms-half)) !important;
  }
  body.ms-open.quiz-context .floating-dashboard-nav {
    left: 50% !important;
  }
  html body.ms-open .card-shop-fab {
    right: calc(var(--ms-w) + 18px);
  }
}

@media (min-width: 1280px) {
  :root {
    --ms-w: 268px;
    --ms-half: 134px;
  }
}

/* Admin-only Member Action Pop-up (Chat & Fitur Admin) */
.ms-pop-layer {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: ms-pop-fade 0.16s ease both;
}
.ms-pop-card {
  width: min(370px, 100%);
  border-radius: 22px;
  border: 2px solid var(--line, #dbe4de);
  border-bottom-width: 5px;
  background: var(--card, #ffffff);
  color: var(--text, #1f2a23);
  box-shadow: 0 22px 54px rgba(15, 23, 42, 0.34);
  overflow: hidden;
  animation: ms-pop-in 0.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}
body.dark .ms-pop-card,
html.dark .ms-pop-card {
  background: #171b24;
  border-color: rgba(255, 255, 255, 0.11);
  color: #eef2f7;
}
.ms-pop-hero {
  position: relative;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 30px;
  gap: 11px;
  align-items: center;
  padding: 15px 14px;
  background: var(--surface, #f2f6f4);
  border-bottom: 1.5px solid var(--line, #e2e8e4);
}
body.dark .ms-pop-hero,
html.dark .ms-pop-hero {
  background: #1e2330;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}
.ms-pop-hero.has-banner {
  background-size: cover;
  background-position: center;
}
.ms-pop-hero.has-banner::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(10, 14, 22, 0.78) 0%, rgba(10, 14, 22, 0.45) 70%, rgba(10, 14, 22, 0.25) 100%);
  pointer-events: none;
}
.ms-pop-hero > * {
  position: relative;
  z-index: 1;
}
.ms-pop-hero .ms-av {
  width: 44px;
  height: 44px;
  font-size: 16px;
}
.ms-pop-hero.has-banner .ms-name:not([data-name-color]) {
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
}
.ms-pop-hero.has-banner .ms-sub {
  color: rgba(255, 255, 255, 0.86);
}
.ms-pop-close {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 0;
  background: rgba(15, 23, 42, 0.14);
  color: inherit;
  font: 900 15px/1 inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.ms-pop-hero.has-banner .ms-pop-close {
  background: rgba(0, 0, 0, 0.42);
  color: #fff;
}
.ms-pop-body {
  padding: 14px;
  display: grid;
  gap: 10px;
}
.ms-pop-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.ms-pop-btn {
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 2px solid var(--line, #dbe4de);
  border-bottom-width: 4px;
  background: var(--card, #ffffff);
  color: inherit;
  font: 800 13.5px/1.2 inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}
.ms-pop-btn:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}
.ms-pop-btn.chat {
  background: #1cb0f6;
  border-color: #0d8fd0;
  color: #fff;
}
.ms-pop-btn.admin {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.14), rgba(139, 92, 246, 0.14));
  border-color: rgba(245, 158, 11, 0.55);
  color: #b45309;
}
body.dark .ms-pop-btn.admin,
html.dark .ms-pop-btn.admin {
  color: #fde68a;
  border-color: rgba(251, 191, 36, 0.45);
}
.ms-pop-btn.admin.on {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #b45309;
  color: #fff;
}

.ms-pop-admin-panel {
  display: grid;
  gap: 11px;
  padding: 12px;
  border-radius: 15px;
  background: var(--surface, #f4f7f5);
  border: 1.5px solid var(--line, #dbe4de);
}
.ms-pop-admin-panel[hidden] {
  display: none !important;
}
body.dark .ms-pop-admin-panel,
html.dark .ms-pop-admin-panel {
  background: #11141c;
  border-color: rgba(255, 255, 255, 0.08);
}
.ms-pop-sec-lbl {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted, #64748b);
}
.ms-pop-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ms-pop-chip {
  height: 30px;
  padding: 0 10px;
  border-radius: 99px;
  border: 1.5px solid var(--line, #dbe4de);
  background: var(--card, #fff);
  color: inherit;
  font: 800 12px/1 inherit;
  cursor: pointer;
}
.ms-pop-chip:hover {
  border-color: #0ea5e9;
  color: #0284c7;
}
body.dark .ms-pop-chip,
html.dark .ms-pop-chip {
  background: #1b202c;
  border-color: rgba(255, 255, 255, 0.12);
}
.ms-pop-dia-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.ms-pop-input {
  height: 40px;
  min-height: 40px !important;
  padding: 0 12px !important;
  border-radius: 12px !important;
  border: 2px solid var(--line, #dbe4de) !important;
  background: var(--card, #fff) !important;
  color: inherit !important;
  font: 800 14px/1 inherit !important;
}
body.dark .ms-pop-input,
html.dark .ms-pop-input {
  background: #1b202c !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
}
.ms-pop-send-dia {
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  border: 2px solid #0284c7;
  border-bottom-width: 4px;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  color: #fff;
  font: 900 13px/1 inherit;
  cursor: pointer;
  white-space: nowrap;
}
.ms-pop-send-dia:disabled {
  opacity: 0.55;
  cursor: progress;
}
.ms-pop-reset-btn {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1.5px solid rgba(28, 176, 246, 0.45);
  background: rgba(28, 176, 246, 0.1);
  color: #0b7bb3;
  font: 800 12.5px/1.2 inherit;
  cursor: pointer;
}
body.dark .ms-pop-reset-btn,
html.dark .ms-pop-reset-btn {
  color: #7dd3fc;
}
.ms-pop-reset-out {
  display: grid;
  gap: 6px;
  padding: 9px 10px;
  border-radius: 12px;
  border: 1.5px dashed #1cb0f6;
  background: var(--card, #fff);
  text-align: center;
}
body.dark .ms-pop-reset-out,
html.dark .ms-pop-reset-out {
  background: #1b202c;
}
.ms-pop-reset-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.12em;
  user-select: all;
}
.ms-pop-status {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
  padding: 8px 10px;
  border-radius: 10px;
}
.ms-pop-status[hidden] { display: none; }
.ms-pop-status.ok { background: rgba(34, 197, 94, 0.14); color: #15803d; }
.ms-pop-status.bad { background: rgba(239, 68, 68, 0.14); color: #dc2626; }
body.dark .ms-pop-status.ok, html.dark .ms-pop-status.ok { color: #86efac; }
body.dark .ms-pop-status.bad, html.dark .ms-pop-status.bad { color: #fca5a5; }
@keyframes ms-pop-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ms-pop-in { from { opacity: 0; transform: translateY(10px) scale(0.96); } to { opacity: 1; transform: none; } }

/* ── Floating Chat Box (muncul melayang saat klik bannerplate → chat, tanpa pindah halaman) ── */
.chat-float {
  position: fixed;
  right: 14px;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  width: min(364px, calc(100vw - 24px));
  z-index: 2147483001;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--card, #ffffff);
  color: var(--text, #1f2a23);
  border: 2px solid var(--line, #dbe4de);
  border-bottom-width: 4px;
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.24), 0 4px 14px rgba(15, 23, 42, 0.1);
  opacity: 0;
  transform: translateY(18px) scale(0.97);
  transition: opacity 0.2s ease, transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), right 0.22s ease;
  font-family: inherit;
}
.chat-float.open {
  opacity: 1;
  transform: none;
}
body.dark .chat-float,
html.dark .chat-float {
  background: #141a18;
  color: #eef5f1;
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.56);
}
body.quiz-context .chat-float,
body.auth-pending .chat-float {
  display: none !important;
}

@media (min-width: 1024px) {
  body.ms-open:not(.quiz-context) .chat-float {
    right: calc(var(--ms-w, 268px) + 16px);
  }
}
@media (min-width: 1340px) {
  .chat-float {
    bottom: 16px;
  }
}

/* Header dengan bannerplate milik peer */
.cf-head {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto auto;
  gap: 9px;
  align-items: center;
  padding: 10px 10px 10px 11px;
  color: #ffffff;
  background: linear-gradient(135deg, #0ea5e9 0%, #0d9488 100%);
  overflow: hidden;
  user-select: none;
}
.cf-head > *:not(.chat-row-bg) {
  position: relative;
  z-index: 2;
}
.cf-head .chat-row-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: right center;
  background-repeat: no-repeat;
}
.cf-head.has-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(90deg, rgba(10, 16, 20, 0.78) 0%, rgba(10, 16, 20, 0.48) 55%, rgba(10, 16, 20, 0.65) 100%);
}
.cf-head .soc-av {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  flex: none;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.55);
  overflow: visible;
}
.cf-head .soc-av-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.cf-head .soc-av.on::after {
  content: '';
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #0f172a;
  z-index: 3;
}
.cf-who {
  min-width: 0;
  display: grid;
  gap: 1px;
}
.cf-who-top {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.cf-who-top b {
  font-size: 13.5px;
  font-weight: 900;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}
.cf-who small {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.88);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}
.cf-head .chat-badge {
  font-style: normal;
  font-size: 9.5px;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  white-space: nowrap;
  flex: none;
}
.cf-head .chat-badge.b-xp100k {
  background: linear-gradient(120deg, #fde68a 0%, #f59e0b 55%, #fef08a 100%);
  color: #3f2200;
  border: 1px solid rgba(255, 255, 255, 0.72);
}
.cf-min-badge {
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 99px;
  background: #ef4444;
  color: #fff;
  font-size: 10.5px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.55);
}
.cf-acts {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cf-act {
  width: 28px;
  height: 28px;
  min-height: 28px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 9px !important;
  background: rgba(255, 255, 255, 0.18) !important;
  color: #ffffff !important;
  font: 900 13px/1 inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
  backdrop-filter: blur(4px);
  transition: background 0.15s ease, transform 0.12s ease;
}
.cf-act:hover {
  background: rgba(255, 255, 255, 0.3) !important;
}
.cf-act:active {
  transform: scale(0.93);
}

/* Minimized state: hanya bar header rapi yang bisa diklik untuk membuka lagi */
.chat-float.is-min {
  width: min(296px, calc(100vw - 24px));
  border-radius: 16px;
}
.chat-float.is-min .cf-head {
  cursor: pointer;
}
.chat-float.is-min .cf-body {
  display: none;
}

.cf-body {
  display: flex;
  flex-direction: column;
}
.cf-ttl {
  padding: 5px 10px;
  text-align: center;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--muted, #5c6d63);
  background: var(--surface, #eef3ef);
  border-bottom: 1px solid var(--line, #e2e8e4);
}
body.dark .cf-ttl,
html.dark .cf-ttl {
  background: #101614;
  border-bottom-color: rgba(255, 255, 255, 0.07);
  color: #93a79d;
}
.cf-msgs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 290px;
  max-height: min(46vh, 340px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 11px;
  background: var(--surface, #f2f6f3);
}
body.dark .cf-msgs,
html.dark .cf-msgs {
  background: #0e1412;
}
.cf-loading {
  margin: auto;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted, #64748b);
}
.cf-msgs .chat-empty {
  margin: auto;
  text-align: center;
  display: grid;
  gap: 3px;
  padding: 14px 8px;
}
.cf-msgs .chat-empty span { font-size: 26px; }
.cf-msgs .chat-empty b { font-size: 13.5px; font-weight: 900; }
.cf-msgs .chat-empty small { font-size: 12px; color: var(--muted, #64748b); font-weight: 700; }
.cf-msgs .chat-day {
  align-self: center;
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 10px;
  margin: 6px 0 4px;
  border-radius: 99px;
  background: var(--card, #fff);
  border: 1px solid var(--line, #dbe4de);
  color: var(--muted, #5c6d63);
}
body.dark .cf-msgs .chat-day,
html.dark .cf-msgs .chat-day {
  background: #1a2420;
  border-color: rgba(255, 255, 255, 0.08);
  color: #a7bab0;
}
.cf-msgs .chat-msg {
  max-width: 82%;
  padding: 7px 11px 5px;
  border-radius: 16px;
  display: grid;
  gap: 1px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07);
}
.cf-msgs .chat-msg p {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.42;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cf-msgs .chat-msg small {
  font-size: 10px;
  font-weight: 800;
  opacity: 0.68;
  justify-self: end;
}
.cf-msgs .chat-msg.me {
  align-self: flex-end;
  background: linear-gradient(135deg, #0ea5e9, #0d9488);
  color: #ffffff;
  border-bottom-right-radius: 5px;
}
.cf-msgs .chat-msg.them {
  align-self: flex-start;
  background: var(--card, #ffffff);
  color: var(--text, #1f2a23);
  border: 1.5px solid var(--line, #dbe4de);
  border-bottom-left-radius: 5px;
}
body.dark .cf-msgs .chat-msg.them,
html.dark .cf-msgs .chat-msg.them {
  background: #1b2421;
  color: #eef5f1;
  border-color: rgba(255, 255, 255, 0.09);
}
.cf-msgs .chat-msg.gap { margin-top: 6px; }

.cf-foot {
  background: var(--card, #ffffff);
  border-top: 1.5px solid var(--line, #e2e8e4);
}
body.dark .cf-foot,
html.dark .cf-foot {
  background: #141a18;
  border-top-color: rgba(255, 255, 255, 0.08);
}
.cf-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 7px;
  align-items: end;
  padding: 8px 9px;
}
.cf-compose textarea {
  min-height: 40px;
  max-height: 96px;
  box-sizing: border-box;
  resize: none;
  border-radius: 20px !important;
  border: 1.5px solid var(--line, #dbe4de);
  padding: 9px 13px;
  font: 600 13.5px/1.32 inherit;
  background: var(--surface, #f2f6f3);
  color: inherit;
  outline: none;
}
.cf-compose textarea:focus {
  border-color: #0ea5e9;
  background: var(--card, #ffffff);
}
body.dark .cf-compose textarea,
html.dark .cf-compose textarea {
  background: #0e1412;
  border-color: rgba(255, 255, 255, 0.12);
  color: #eef5f1;
}
body.dark .cf-compose textarea:focus,
html.dark .cf-compose textarea:focus {
  background: #17201d;
  border-color: #38bdf8;
}
.cf-send {
  width: 40px;
  height: 40px;
  min-height: 40px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #0ea5e9, #0d9488) !important;
  color: #ffffff !important;
  font-size: 17px;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 0 #0f766e;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.cf-send:active { transform: translateY(1px); box-shadow: none; }
.cf-send:disabled { opacity: 0.42; box-shadow: none; cursor: default; }

.cf-locked {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted, #5c6d63);
}
.cf-friend-btn {
  flex: none;
  min-height: 32px !important;
  padding: 0 11px !important;
  border: 0 !important;
  border-radius: 10px !important;
  background: linear-gradient(135deg, #0ea5e9, #0d9488) !important;
  color: #fff !important;
  font: 900 12px/1 inherit;
  cursor: pointer;
}
@media (prefers-reduced-motion: reduce) {
  .chat-float { transition: none; }
}
