/* Live shop chat: compact messenger dock. Hat carries meaning; the list stays small. */
.live-chat {
  --lc-launch: 3.15rem;
  --lc-panel-w: 20.5rem;
  --lc-panel-h: 28rem;
  --lc-type: 0.9375rem;
  --lc-meta: 0.68rem;
  --lc-gap: 0.38rem;
  --lc-pad: 0.62rem;
  --lc-radius: 1.05rem;
  position: fixed;
  inset-inline-end: max(0.85rem, env(safe-area-inset-right));
  inset-block-end: max(0.85rem, env(safe-area-inset-bottom), var(--app-kb, 0px));
  z-index: 2400;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
  pointer-events: none;
  isolation: isolate;
  mix-blend-mode: normal;
  filter: none;
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: var(--lc-type);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.45;
  text-transform: none;
  color: var(--text);
  color-scheme: light;
}
.live-chat[data-scheme="dark"] { color-scheme: dark; }
.live-chat[hidden],
.live-chat-launch[hidden],
.live-chat-panel[hidden] { display: none !important; }
.live-chat > * { pointer-events: auto; mix-blend-mode: normal; }

html body .live-chat .live-chat-launch,
.live-chat-launch {
  position: relative;
  width: var(--lc-launch);
  height: var(--lc-launch);
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--ink-on-accent, #111114);
  box-shadow:
    0 0 0 2px var(--bg, #fff),
    0 10px 22px color-mix(in srgb, var(--text) 20%, transparent);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.live-chat-launch:hover,
.live-chat-launch:focus-visible {
  transform: translateY(-2px) scale(1.03);
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.live-chat-launch svg { width: 1.28rem; height: 1.28rem; display: block; }
.live-chat-dot {
  position: absolute;
  inset-inline-end: 0.12rem;
  inset-block-start: 0.12rem;
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 999px;
  background: #22c55e;
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 3px rgb(0 0 0 / 55%);
}
.live-chat-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  border: 2px solid #22c55e;
  animation: live-chat-ping 1.8s ease-out infinite;
}
.live-chat-badge {
  position: absolute;
  inset-inline-start: -0.12rem;
  inset-block-start: -0.16rem;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.24rem;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.64rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 2px var(--bg, #fff);
}
.live-chat-badge[hidden] { display: none; }

.live-chat-panel {
  position: relative;
  width: min(var(--lc-panel-w), calc(100vw - 1.4rem));
  height: min(var(--lc-panel-h), calc(var(--app-vvh, 100dvh) - 6.4rem));
  min-width: 17.5rem;
  min-height: 18rem;
  max-width: min(56rem, calc(100vw - 0.8rem));
  max-height: calc(var(--app-vvh, 100dvh) - 6.4rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--lc-radius);
  background: var(--surface, #fff);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
  box-shadow:
    0 18px 48px color-mix(in srgb, var(--text) 24%, transparent),
    0 0 0 1px color-mix(in srgb, var(--accent) 16%, transparent);
  transform-origin: bottom right;
  animation: live-chat-in 0.2s ease-out;
}
[dir="rtl"] .live-chat-panel { transform-origin: bottom left; }
.live-chat-panel[hidden] { display: none; }
.live-chat-handle {
  position: absolute;
  z-index: 6;
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
  min-height: 0;
  width: auto;
  height: auto;
  background: transparent;
  box-shadow: none;
  font-size: 0;
  line-height: 0;
  touch-action: none;
}
.live-chat-handle.is-n {
  inset-inline: 1.5rem;
  inset-block-start: 0;
  height: 1.05rem;
  min-height: 0;
  cursor: ns-resize;
}
.live-chat-handle.is-w {
  inset-block: 1.1rem;
  inset-inline-start: 0;
  width: 0.85rem;
  min-width: 0;
  cursor: ew-resize;
}
.live-chat-handle.is-nw {
  inset-block-start: 0;
  inset-inline-start: 0;
  width: 1.2rem;
  height: 1.2rem;
  min-width: 0;
  min-height: 0;
  cursor: nwse-resize;
}
[dir="rtl"] .live-chat-handle.is-w { cursor: ew-resize; }
[dir="rtl"] .live-chat-handle.is-nw { cursor: nesw-resize; }
.live-chat-handle.is-n::after,
.live-chat-handle.is-w::after,
.live-chat-handle.is-nw::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink-on-accent, #111114) 48%, transparent);
}
.live-chat-handle.is-n::after {
  inset-inline-start: 50%;
  inset-block-start: 0.22rem;
  width: 2.4rem;
  height: 0.24rem;
  transform: translateX(-50%);
}
.live-chat-handle.is-w::after {
  inset-block-start: 50%;
  inset-inline-start: 0.28rem;
  width: 0.24rem;
  height: 2.2rem;
  transform: translateY(-50%);
  background: color-mix(in srgb, var(--text) 42%, transparent);
}
.live-chat-handle.is-nw::after {
  inset: 0.28rem auto auto 0.28rem;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 0.12rem 0 0.4rem 0;
  background: color-mix(in srgb, var(--ink-on-accent, #111114) 55%, transparent);
}
.live-chat-handle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.live-chat-head {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.62rem 0.62rem 0.55rem 0.7rem;
  color: var(--ink-on-accent, #111114);
  background: var(--accent);
  border-bottom: 0;
  flex: none;
}
.live-chat-avatar {
  position: relative;
  width: 1.9rem;
  height: 1.9rem;
  margin-top: 0.08rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--ink-on-accent, #111114) 14%, transparent);
  color: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  flex: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ink-on-accent, #111114) 28%, transparent);
}
.live-chat-avatar .live-chat-dot {
  inset-inline-end: -1px;
  inset-block-start: auto;
  inset-block-end: -1px;
  width: 0.52rem;
  height: 0.52rem;
}
.live-chat #sn-live-chat-title,
.live-chat-head h2 {
  margin: 0;
  font-family: var(--font-heading, inherit);
  font-size: 0.92rem;
  line-height: 1.2;
  letter-spacing: 0;
  font-weight: 700;
  text-transform: none;
  color: inherit;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.live-chat-status {
  margin: 0.08rem 0 0;
  font-size: var(--lc-meta);
  font-weight: 650;
  letter-spacing: 0.01em;
  color: inherit;
  opacity: 0.82;
}
.live-chat-lead {
  margin: 0.22rem 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  color: inherit;
  opacity: 0.9;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.live-chat-lead[hidden] { display: none; }
.live-chat-head-text { min-width: 0; flex: 1; }
.live-chat-head-actions {
  display: flex;
  align-items: flex-start;
  gap: 0.12rem;
  flex: none;
}
.live-chat-x,
.live-chat-grow {
  width: 2.25rem;
  height: 2.25rem;
  margin-top: -0.12rem;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink-on-accent, #111114) 12%, transparent);
  color: inherit;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: none;
}
.live-chat-x:hover,
.live-chat-grow:hover,
.live-chat-x:focus-visible,
.live-chat-grow:focus-visible {
  background: color-mix(in srgb, var(--ink-on-accent, #111114) 20%, transparent);
  outline: 2px solid color-mix(in srgb, var(--ink-on-accent, #111114) 55%, transparent);
  outline-offset: 2px;
}
.live-chat-x svg,
.live-chat-grow svg { width: 1.05rem; height: 1.05rem; display: block; }

.live-chat-offer {
  margin: 0;
  padding: 0.4rem 0.75rem;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--text) 8%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface, var(--bg, #fff)));
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.35;
  flex: none;
}

.live-chat-log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0.55rem 0.7rem 0.35rem;
  display: flex;
  flex-direction: column;
  gap: var(--lc-gap);
  background: var(--surface, #fff);
  color: var(--text);
}
.live-chat-empty,
.live-chat-note {
  margin: auto 0.2rem;
  padding: 0.35rem 0.2rem 0.7rem;
  text-align: center;
  background: transparent;
  color: color-mix(in srgb, var(--text) 62%, var(--surface, #fff));
  font-size: 0.8rem;
  line-height: 1.4;
}
.live-chat-note {
  margin: 0.15rem 0 0;
  padding: 0.4rem 0.55rem;
  border-radius: 0.7rem;
  background: color-mix(in srgb, var(--text) 6%, var(--surface, #fff));
  text-align: start;
  color: var(--text);
}
.live-chat-bubble {
  max-width: 86%;
  padding: 0.42rem 0.7rem 0.38rem;
  border-radius: 0.9rem;
  font-size: var(--lc-type);
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.live-chat-bubble p { margin: 0; }
.live-chat-bubble p + p { margin-top: 0.22rem; }
.live-chat-meta {
  display: block;
  margin-top: 0.18rem;
  font-size: var(--lc-meta);
  font-weight: 600;
  opacity: 0.72;
}
.live-chat-bubble.is-you {
  align-self: flex-end;
  background: var(--accent);
  color: var(--ink-on-accent, #111114);
  border-bottom-right-radius: 0.28rem;
}
[dir="rtl"] .live-chat-bubble.is-you { border-bottom-right-radius: 0.9rem; border-bottom-left-radius: 0.28rem; }
.live-chat-bubble.is-shop {
  align-self: flex-start;
  background: color-mix(in srgb, var(--text) 6%, var(--bg, var(--surface, #fff)));
  color: var(--text);
  border: 0;
  border-bottom-left-radius: 0.28rem;
}
[dir="rtl"] .live-chat-bubble.is-shop { border-bottom-left-radius: 0.9rem; border-bottom-right-radius: 0.28rem; }
.live-chat-bubble.is-follow {
  padding-bottom: 0.22rem;
}
.live-chat-bubble.is-continued {
  margin-top: 0;
  padding-top: 0.28rem;
}
.live-chat-bubble.is-you.is-continued { border-top-right-radius: 0.4rem; }
.live-chat-bubble.is-shop.is-continued { border-top-left-radius: 0.4rem; }
.live-chat-bubble.is-deleted { opacity: 0.7; font-style: italic; }
.live-chat-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  margin-top: 0.28rem;
}
.live-chat-photos a {
  display: block;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 0.4rem;
  overflow: hidden;
}
.live-chat-photos img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

html body.has-pack .live-chat-card,
html body.has-pack .thread .live-chat-card,
.live-chat-card {
  display: grid;
  grid-template-columns: 3.1rem 1fr;
  gap: 0.4rem 0.55rem;
  align-items: center;
  margin: 0.3rem 0 0;
  padding: 0.4rem;
  border: 1px solid color-mix(in srgb, var(--text) 16%, transparent);
  border-radius: 0.65rem;
  background: var(--surface, var(--bg, #111114));
  color: var(--text, #f4f4f4);
}
.live-chat-card img {
  width: 3.1rem;
  height: 3.1rem;
  max-height: none;
  object-fit: cover;
  border-radius: 0.4rem;
  margin: 0;
  grid-row: span 3;
}
html body.has-pack .live-chat-card-name,
html body.has-pack .live-chat-card-price,
html body.has-pack .thread .live-chat-card-name,
html body.has-pack .thread .live-chat-card-price,
.live-chat-card-name,
.live-chat-card-price {
  margin: 0;
  color: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.3;
}
.live-chat-card-price { font-weight: 700; }
html body.has-pack .live-chat .live-chat-card-add,
html body.has-pack .thread .live-chat-card-add,
html body .live-chat .live-chat-card-add,
.live-chat-card-add {
  margin: 0;
  width: auto;
  justify-self: start;
  border: 0;
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  background: var(--accent);
  color: var(--ink-on-accent, #111114);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 750;
  cursor: pointer;
}
.live-chat-card-add:disabled { opacity: 0.55; cursor: wait; }
.live-chat-card:not(:has(img)) {
  grid-template-columns: 1fr;
}

.live-chat-compose {
  display: flex;
  align-items: flex-end;
  gap: 0.38rem;
  padding: 0.45rem 0.55rem calc(0.5rem + env(safe-area-inset-bottom));
  border-top: 1px solid color-mix(in srgb, var(--text) 8%, transparent);
  background: var(--surface, #fff);
  flex: none;
}
.live-chat .live-chat-compose textarea {
  flex: 1;
  min-height: 2.35rem;
  max-height: 6.5rem;
  resize: none;
  border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
  border-radius: 0.95rem;
  padding: 0.42rem 0.7rem;
  background: var(--bg, #fff);
  color: var(--text);
  font: inherit;
  font-size: var(--lc-type);
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.35;
  box-shadow: none;
  filter: none;
}
.live-chat .live-chat-compose textarea::placeholder {
  color: color-mix(in srgb, var(--text) 62%, var(--bg, #fff));
  opacity: 1;
}
.live-chat .live-chat-compose textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.live-chat-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}
html body .live-chat .live-chat-send,
.live-chat-send {
  width: 2.35rem;
  height: 2.35rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--ink-on-accent, #111114);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: none;
  box-shadow: none;
  filter: none;
  text-transform: none;
}
.live-chat-send:disabled { opacity: 0.55; cursor: wait; }
.live-chat-send svg { width: 0.95rem; height: 1.05rem; }

@keyframes live-chat-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes live-chat-ping {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.9); opacity: 0; }
}

@media (max-width: 640px) {
  .live-chat {
    inset-inline: 0;
    inset-block-end: max(0px, var(--app-kb, 0px));
    align-items: stretch;
    padding-inline: 0;
  }
  .live-chat-launch {
    margin-inline: max(0.85rem, env(safe-area-inset-right));
    margin-block-end: max(0.85rem, env(safe-area-inset-bottom));
    align-self: flex-end;
  }
  .live-chat-panel {
    width: 100% !important;
    height: min(var(--lc-panel-h, 72dvh), calc(var(--app-vvh, 100dvh) - 4.4rem));
    min-width: 0;
    min-height: 16rem;
    max-width: none;
    max-height: calc(var(--app-vvh, 100dvh) - 4.4rem);
    border-radius: 1.05rem 1.05rem 0 0;
  }
  .live-chat-handle.is-w,
  .live-chat-handle.is-nw,
  .live-chat-grow { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .live-chat-launch,
  .live-chat-panel,
  .live-chat-dot::after { animation: none; transition: none; }
}
