/* Haan group chat — TikTok-style bottom sheet */

.haan-chat-fab {
  position: fixed;
  left: max(14px, env(safe-area-inset-left));
  bottom: calc(74px + env(safe-area-inset-bottom));
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 8px;
  font-size: 20px;
  border: 2px solid #281b3b;
  border-radius: 50%;
  background: #fff8eb;
  box-shadow: 3px 3px 0 #3a9bdd;
  z-index: 901;
  touch-action: manipulation;
  cursor: pointer;
}

body.haan-chat-open { overflow: hidden; }

.haan-chat-sheet[hidden],
.haan-chat-backdrop[hidden] { display: none; }

.haan-chat-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 8, 18, 0.45);
  z-index: 9499;
}

.haan-chat-sheet {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #fff8f0;
  color: #221733;
  border-radius: 0;
  box-shadow: none;
  z-index: 9500;
  overflow: hidden;
  font-family: inherit;
  animation: haan-chat-up 0.22s ease-out;
}
@keyframes haan-chat-up {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.haan-chat-handle {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: rgba(34, 23, 51, 0.25);
  margin: 8px auto 2px;
  flex: none;
}

.haan-chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 10px;
  border-bottom: 1px solid rgba(34, 23, 51, 0.12);
  flex: none;
}
.haan-chat-head h3 { font-size: 16px; font-weight: 700; margin: 0; }
.haan-chat-who {
  font-size: 11px;
  opacity: 0.55;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.haan-chat-close {
  margin-inline-start: auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(34, 23, 51, 0.08);
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
  flex: none;
}

.haan-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.haan-chat-empty { text-align: center; opacity: 0.6; font-size: 14px; margin-top: 30px; }

.haan-chat-row { display: flex; flex-direction: column; }
.haan-chat-row.own { align-items: flex-end; }
.haan-chat-row:not(.own) { align-items: flex-start; }

.haan-chat-bubble-wrap {
  position: relative;
  max-width: 78%;
  display: flex;
  flex-direction: column;
}
.haan-chat-row.own .haan-chat-bubble-wrap { align-items: flex-end; }

.haan-chat-name { font-size: 11px; opacity: 0.55; margin: 0 6px 2px; }

.haan-chat-bubble {
  background: #efe3d2;
  color: #221733;
  padding: 8px 12px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.35;
  word-break: break-word;
  white-space: pre-wrap;
  user-select: none;
  -webkit-user-select: none;
}
.haan-chat-row.own .haan-chat-bubble {
  background: #2e9bef;
  color: #fff;
}

.haan-chat-sticker {
  font-size: 46px;
  line-height: 1.1;
  user-select: none;
  -webkit-user-select: none;
}

.haan-chat-time { font-size: 10px; opacity: 0.45; margin: 2px 6px 0; }

.haan-chat-react-pill {
  position: absolute;
  bottom: -9px;
  inset-inline-end: 6px;
  display: flex;
  gap: 2px;
  background: #fff;
  border: 1px solid rgba(34, 23, 51, 0.15);
  border-radius: 12px;
  padding: 1px 5px;
  box-shadow: 0 1px 4px rgba(12, 8, 18, 0.15);
  z-index: 2;
}
.haan-chat-react-one { font-size: 12px; padding: 0 2px; border-radius: 8px; }
.haan-chat-react-one.mine { background: rgba(46, 155, 239, 0.18); }

.haan-chat-reactbar {
  position: absolute;
  top: -40px;
  inset-inline-start: 0;
  display: flex;
  gap: 2px;
  background: #fff;
  border: 1px solid rgba(34, 23, 51, 0.15);
  border-radius: 22px;
  padding: 4px 8px;
  box-shadow: 0 4px 14px rgba(12, 8, 18, 0.25);
  z-index: 5;
  animation: haan-chat-pop 0.12s ease-out;
}
@keyframes haan-chat-pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.haan-chat-reactbar button { font-size: 20px; padding: 2px 4px; border-radius: 50%; }
.haan-chat-reactbar button:active { transform: scale(1.25); }
.haan-chat-reactbar .haan-chat-del { font-size: 16px; }

.haan-chat-composer {
  flex: none;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(34, 23, 51, 0.12);
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: inherit;
}
.haan-chat-inputrow { display: flex; align-items: flex-end; gap: 4px; }
textarea.haan-chat-input {
  resize: none;
  font-family: inherit;
  line-height: 1.35;
  max-height: 110px;
  overflow-y: auto;
  display: block;
}
.haan-chat-emoji {
  font-size: 22px;
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
}
.haan-chat-input,
.haan-chat-nameinput {
  flex: 1;
  min-width: 0;
  background: rgba(34, 23, 51, 0.07);
  border: none;
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 15px;
  color: inherit;
  outline: none;
}
.haan-chat-nameinput { border-radius: 12px; font-size: 13px; padding: 7px 12px; }
.haan-chat-send {
  flex: none;
  min-width: 38px;
  height: 38px;
  border-radius: 19px;
  background: #fe2c55;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  display: grid;
  place-items: center;
  padding: 0 12px;
}
[dir="rtl"] .haan-chat-sendarrow { transform: scaleX(-1); }
.haan-chat-signin input { margin-bottom: 6px; width: 100%; }
.haan-chat-signin-btns { display: flex; gap: 8px; }
.haan-chat-alt {
  height: 38px;
  border-radius: 19px;
  border: 1.5px solid rgba(34, 23, 51, 0.35);
  color: inherit;
  font-size: 14px;
  padding: 0 14px;
}

.haan-chat-stickerbtn {
  background: #fff;
  border: 2px solid rgba(34, 23, 51, 0.35);
  border-radius: 9px;
  font-size: 16px;
  box-shadow: 1px 1px 0 rgba(34, 23, 51, 0.2);
}

.haan-chat-stickers {
  flex: none;
  border-top: 1px solid rgba(34, 23, 51, 0.12);
  background: rgba(34, 23, 51, 0.04);
}
.haan-chat-tabs { display: flex; gap: 4px; padding: 8px 14px 0; }
.haan-chat-tab { font-size: 13px; padding: 5px 12px; border-radius: 14px; opacity: 0.65; }
.haan-chat-tab.active { background: rgba(34, 23, 51, 0.12); opacity: 1; font-weight: 700; }
.haan-chat-stickergrid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  padding: 8px 14px calc(12px + env(safe-area-inset-bottom));
  max-height: 170px;
  overflow-y: auto;
}
.haan-chat-stickergrid button { font-size: 26px; padding: 5px 0; border-radius: 10px; }
.haan-chat-stickergrid button.big { font-size: 32px; }
.haan-chat-stickergrid button:active { background: rgba(34, 23, 51, 0.1); transform: scale(1.15); }

.haan-chat-status {
  flex: none;
  margin: 0;
  padding: 0 14px 4px;
  font-size: 12px;
  min-height: 14px;
  color: #c03;
  text-align: center;
}
.haan-chat-status:empty { padding: 0; min-height: 0; }

/* TikTok-style header */
.haan-chat-head.tiktok { gap: 10px; }
.haan-chat-gavatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg,#fe2c55,#b98cf0);
  display: grid; place-items: center; font-size: 20px; flex: none;
}
.haan-chat-gtitles { display: flex; flex-direction: column; min-width: 0; }
.haan-chat-gmembers { font-size: 11px; opacity: 0.55; }

/* pinned bar */
.haan-chat-pinned {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; font-size: 13px;
  border-bottom: 1px solid rgba(34,23,51,0.12);
  background: rgba(34,23,51,0.04);
}
.haan-chat-pinned[hidden] { display: none; }
.haan-chat-pintext { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* avatars */
.haan-chat-row { flex-direction: row; align-items: flex-end; gap: 7px; }
.haan-chat-row.own { justify-content: flex-end; }
.haan-chat-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  color: #fff; font-size: 13px; font-weight: 700;
  margin-bottom: 2px;
}

/* reply quote */
.haan-chat-quote {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: rgba(34,23,51,0.08);
  border-inline-start: 3px solid #b98cf0;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  margin-bottom: 3px;
  text-align: start;
  max-width: 100%;
}
.haan-chat-qname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: 0.8; }
.haan-chat-qthumb { font-size: 26px; }

/* new messages pill */
.haan-chat-newpill {
  position: absolute;
  top: 120px;
  inset-inline-end: 14px;
  background: #fff;
  color: #fe2c55;
  border: none;
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(12,8,18,0.25);
  z-index: 6;
}
.haan-chat-newpill[hidden] { display: none; }

/* reply chip above composer */
.haan-chat-replychip {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 14px; font-size: 12px;
  border-top: 1px solid rgba(34,23,51,0.12);
  background: rgba(34,23,51,0.04);
}
.haan-chat-replychip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.haan-chat-seclabel { margin: 6px 14px 0; font-size: 12px; opacity: 0.55; }

/* image stickers */
.haan-chat-filepick { display: none; }
.haan-chat-stickerimg { max-width: 120px; max-height: 120px; border-radius: 12px; display: block; }
.haan-chat-stickerthumb { width: 52px; height: 52px; object-fit: cover; border-radius: 10px; display: block; }
.haan-chat-stickergrid button.big:has(img) { padding: 3px; }
.haan-chat-qthumbimg { width: 30px; height: 30px; object-fit: cover; border-radius: 8px; }
.haan-chat-addtile {
  font-size: 26px; font-weight: 700; color: #fe2c55;
  border: 2px dashed rgba(254, 44, 85, 0.5) !important;
  background: none !important;
  box-shadow: none !important;
}

/* Account name reuse: hide per-form name fields once the account has a name */
label.haan-name-hidden { display: none !important; }

.haan-chat-namehint { margin: 0; font-size: 13px; opacity: 0.7; }

/* Admin */
.haan-admin-fab {
  position: fixed;
  left: max(14px, env(safe-area-inset-left));
  bottom: calc(130px + env(safe-area-inset-bottom));
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 8px;
  font-size: 18px;
  border: 2px solid #281b3b;
  border-radius: 50%;
  background: #fff8eb;
  box-shadow: 3px 3px 0 #b98cf0;
  z-index: 901;
  touch-action: manipulation;
  cursor: pointer;
}
.haan-admin-fab[hidden] { display: none; }

.haan-admin-sheet {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #fff8f0;
  color: #221733;
  z-index: 9600;
  overflow: hidden;
  font-family: inherit;
}
.haan-admin-sheet[hidden] { display: none; }
.haan-admin-body { flex: 1; overflow-y: auto; padding: 12px 14px 40px; -webkit-overflow-scrolling: touch; }

/* Dark mode */
html[data-theme="dark"] .haan-chat-fab {
  background: #2c2140;
  color: #fff8eb;
  border-color: #0f0a16;
  box-shadow: 3px 3px 0 #3a9bdd;
}
html[data-theme="dark"] .haan-chat-sheet { background: #241a30; color: #f3ebdd; }
html[data-theme="dark"] .haan-chat-handle { background: rgba(243, 235, 221, 0.25); }
html[data-theme="dark"] .haan-chat-head { border-bottom-color: rgba(243, 235, 221, 0.14); }
html[data-theme="dark"] .haan-chat-close { background: rgba(243, 235, 221, 0.12); }
html[data-theme="dark"] .haan-chat-bubble { background: #3a2d4a; color: #f3ebdd; }
html[data-theme="dark"] .haan-chat-row.own .haan-chat-bubble { background: #2e9bef; color: #fff; }
html[data-theme="dark"] .haan-chat-react-pill,
html[data-theme="dark"] .haan-chat-reactbar { background: #332644; border-color: rgba(243, 235, 221, 0.2); }
html[data-theme="dark"] .haan-chat-react-one.mine { background: rgba(46, 155, 239, 0.35); }
html[data-theme="dark"] .haan-chat-composer { border-top-color: rgba(243, 235, 221, 0.14); }
html[data-theme="dark"] .haan-chat-input,
html[data-theme="dark"] .haan-chat-nameinput { background: rgba(243, 235, 221, 0.1); }
html[data-theme="dark"] .haan-chat-alt { border-color: rgba(243, 235, 221, 0.4); }
html[data-theme="dark"] .haan-chat-stickers { background: rgba(243, 235, 221, 0.05); border-top-color: rgba(243, 235, 221, 0.14); }
html[data-theme="dark"] .haan-chat-stickerbtn { background: #3a2d4a; border-color: rgba(243, 235, 221, 0.4); box-shadow: 1px 1px 0 rgba(0,0,0,0.4); }
html[data-theme="dark"] .haan-chat-tab.active { background: rgba(243, 235, 221, 0.15); }
html[data-theme="dark"] .haan-chat-pinned { border-bottom-color: rgba(243,235,221,0.14); background: rgba(243,235,221,0.05); }
html[data-theme="dark"] .haan-chat-quote { background: rgba(243,235,221,0.1); }
html[data-theme="dark"] .haan-chat-newpill { background: #332644; }
html[data-theme="dark"] .haan-chat-replychip { border-top-color: rgba(243,235,221,0.14); background: rgba(243,235,221,0.05); }
html[data-theme="dark"] .haan-chat-status { color: #ff8f8f; }
html[data-theme="dark"] .haan-admin-fab { background: #2c2140; color: #fff8eb; border-color: #0f0a16; box-shadow: 3px 3px 0 #b98cf0; }
html[data-theme="dark"] .haan-admin-sheet { background: #1c1423; color: #f3ebdd; }

/* ---------- main page cleanup: controls live in the tools menu ---------- */
.theme-switch, .lang-switch { display: none !important; }
.haan-chat-fab { display: none !important; }
.haan-bell-button { display: none !important; }
.haan-admin-fab { display: none !important; }

/* ---------- tools menu ---------- */
.haan-menu-fab {
  position: fixed;
  top: 14px;
  inset-inline-start: 14px;
  z-index: 9502;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  font-size: 20px;
  background: rgba(255, 255, 255, 0.92);
  color: #221733;
  box-shadow: 0 2px 10px rgba(12, 8, 18, 0.25);
}
html[data-theme="dark"] .haan-menu-fab { background: rgba(51, 38, 68, 0.92); color: #f3ebdd; }
.haan-menu-sheet {
  position: fixed;
  top: 62px;
  inset-inline-start: 14px;
  z-index: 9503;
  width: min(300px, 86vw);
  max-height: 70vh;
  overflow-y: auto;
  border-radius: 18px;
  background: #fffdf8;
  color: #221733;
  box-shadow: 0 8px 30px rgba(12, 8, 18, 0.35);
  padding-bottom: 10px;
}
html[data-theme="dark"] .haan-menu-sheet { background: #221733; color: #f3ebdd; }
.haan-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  border: none;
  background: none;
  color: inherit;
  font-size: 15px;
  text-align: start;
}
.haan-menu-item:active { background: rgba(34, 23, 51, 0.06); }
.haan-menu-icon { font-size: 18px; }
.haan-menu-sub { margin-inline-start: 30px; border-inline-start: 2px solid rgba(34,23,51,0.12); }
html[data-theme="dark"] .haan-menu-sub { border-inline-start-color: rgba(243,235,221,0.15); }
.haan-menu-langs { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 16px; }
.haan-menu-lang {
  border: 1.5px solid rgba(34, 23, 51, 0.25);
  background: none;
  color: inherit;
  border-radius: 14px;
  padding: 5px 12px;
  font-size: 13px;
}
.haan-menu-lang.active { background: #fe2c55; border-color: #fe2c55; color: #fff; }
html[data-theme="dark"] .haan-menu-lang { border-color: rgba(243,235,221,0.3); }
html[data-theme="dark"] .haan-menu-lang.active { background: #fe2c55; border-color: #fe2c55; color: #fff; }

/* ---------- profile page ---------- */
.haan-profile-page {
  position: fixed;
  inset: 0;
  z-index: 9504;
  background: #fffdf8;
  color: #221733;
  overflow-y: auto;
}
html[data-theme="dark"] .haan-profile-page { background: #1c1428; color: #f3ebdd; }
.haan-profile-body { padding: 8px 16px 30px; max-width: 480px; margin: 0 auto; }
.haan-profile-avwrap { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 10px 0 18px; }
.haan-profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
}
.haan-profile-initial { color: #fff; font-size: 40px; font-weight: 700; }
.haan-profile-change {
  border: 1.5px solid rgba(34, 23, 51, 0.3);
  background: none;
  color: inherit;
  border-radius: 16px;
  padding: 6px 16px;
  font-size: 13px;
}
html[data-theme="dark"] .haan-profile-change { border-color: rgba(243,235,221,0.35); }
.haan-profile-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.haan-profile-field label { font-size: 13px; font-weight: 700; opacity: 0.75; }
.haan-profile-field .haan-chat-send { align-self: flex-start; }
.haan-profile-info { margin-top: 18px; font-size: 13px; opacity: 0.7; }


/* full-page chat extras */
.haan-chat-handle { display: none; }
.haan-chat-iconbtn {
  font-size: 17px;
  line-height: 1;
  padding: 6px 5px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  flex: none;
}
.haan-chat-iconbtn:active { transform: scale(1.15); }
.haan-chat-plusbtn { font-size: 21px; font-weight: 700; padding: 4px 7px; }
.haan-chat-plusmenu {
  display: flex;
  gap: 10px;
  padding: 10px 14px 4px;
}
.haan-chat-plusopt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}
.haan-chat-plusicon {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  border-radius: 50%;
  background: rgba(34, 23, 51, 0.08);
}
html[data-theme="dark"] .haan-chat-plusicon { background: rgba(243, 235, 221, 0.12); }
.haan-chat-recbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
}
.haan-chat-recdot { color: #fe2c55; animation: haan-rec-blink 1s infinite; font-size: 14px; }
@keyframes haan-rec-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.haan-chat-rectime { font-weight: 700; font-variant-numeric: tabular-nums; }
.haan-chat-reclabel { flex: 1; opacity: 0.7; font-size: 13px; }
.haan-chat-reccancel {
  font-size: 18px;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  padding: 4px 8px;
}
.haan-chat-audio { width: 210px; max-width: 60vw; height: 38px; display: block; }
.haan-chat-voicedur { font-size: 12px; opacity: 0.85; margin-top: 2px; display: block; }
.haan-chat-voice { min-width: 220px; }
.haan-chat-photo { max-width: 240px; max-height: 320px; border-radius: 14px; display: block; }
.haan-chat-filelink { color: inherit; text-decoration: underline; word-break: break-all; cursor: pointer; }
.haan-chat-favempty { font-size: 12.5px; opacity: 0.75; padding: 4px 14px 10px; margin: 0; }

.haan-chat-swipehint {
  display: block;
  width: calc(100% - 28px);
  margin: 2px 14px 0;
  padding: 5px 10px;
  font-size: 11.5px;
  font-family: inherit;
  text-align: center;
  color: inherit;
  opacity: 0.7;
  background: rgba(34, 23, 51, 0.06);
  border: none;
  border-radius: 10px;
  cursor: pointer;
}
html[data-theme="dark"] .haan-chat-swipehint { background: rgba(243, 235, 221, 0.08); }
.haan-profile-share { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
.haan-profile-share input[type="checkbox"] { width: 20px; height: 20px; accent-color: #fe2c55; flex: none; }
.haan-profile-share label { flex: 1; }
.haan-profile-sharehelp { width: 100%; font-size: 12px; line-height: 1.5; opacity: .7; margin: 2px 0 0; }

/* Floating page buttons must never cover the chat sheet (sign-in form, composer, keyboard) */
body.haan-chat-open .jin-music,
body.haan-chat-open .occasion-back-top,
body.haan-chat-open .jin-refresh { display: none !important; }

/* password show/hide eye */
.haan-pass-wrap { position: relative; width: 100%; }
.haan-pass-wrap .haan-chat-input { width: 100%; box-sizing: border-box; padding-inline-end: 46px; }
.haan-pass-eye { position: absolute; inset-inline-end: 5px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; padding: 7px; border: 0; background: none; color: inherit; opacity: .7; cursor: pointer; display: grid; place-items: center; border-radius: 50%; }
.haan-pass-eye:hover, .haan-pass-eye:focus-visible { opacity: 1; }
.haan-pass-eye svg { width: 22px; height: 22px; display: block; }

/* close buttons: always high-contrast, beat generic site button rules */
.haan-chat-close { background: #221733 !important; color: #f3ebdd !important; font-weight: 700; font-size: 19px; }
html[data-theme="dark"] .haan-chat-close { background: #f3ebdd !important; color: #241a30 !important; }
.haan-bell-close { font-weight: 700; }
.haan-chat-diag{display:block;font-size:10px;opacity:.55;margin-top:3px;font-family:monospace;direction:ltr;text-align:left}
