.product-chat,
.seller-chat-row {
  margin: 0.85rem 0 0;
}

.seller-chat {
  position: fixed;
  z-index: 40;
  inset: 0;
  pointer-events: none;
}

.seller-chat-window,
.seller-chat-launcher {
  pointer-events: auto;
}

.seller-chat-window {
  position: fixed;
  display: flex;
  flex-direction: column;
  width: 380px;
  height: 560px;
  min-width: 300px;
  min-height: 360px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.seller-chat.is-min .seller-chat-window,
.seller-chat.is-closed {
  display: none;
}

.seller-chat-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 48px;
  padding: 0.4rem 0.45rem 0.4rem 0.9rem;
  background: var(--green);
  color: #fff;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.seller-chat-bar strong {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 700;
}

.seller-chat-iconbtn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}

.seller-chat-iconbtn:hover {
  background: rgb(255 255 255 / 16%);
}

.seller-chat-log {
  flex: 1;
  overflow: auto;
  padding: 0.85rem;
  background: var(--canvas);
}

.seller-chat-empty,
.seller-chat-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.seller-chat-msg {
  max-width: 85%;
  margin: 0 0 0.55rem;
  padding: 0.55rem 0.7rem;
  border-radius: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.seller-chat-msg time {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.seller-chat-msg.is-own {
  margin-left: auto;
  background: var(--mint);
  border-color: transparent;
}

.seller-chat-nudge {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.65rem 0.85rem;
  border: 0;
  border-top: 1px solid var(--line);
  background: var(--mint);
  color: var(--green-dark);
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.35;
  text-align: center;
  cursor: pointer;
}

.seller-chat-nudge[hidden] {
  display: none;
}

.seller-chat-auth {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgb(30 29 28 / 45%);
}

.seller-chat-auth[hidden] {
  display: none;
}

.seller-chat-auth-card {
  position: relative;
  width: min(360px, 100%);
  padding: 1.4rem 1.25rem 1.25rem;
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.seller-chat-auth-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
}

.seller-chat-auth-card p {
  margin: 0 0 0.85rem;
  color: var(--muted);
}

.seller-chat-auth-card input {
  width: 100%;
  min-height: 46px;
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

.seller-chat-auth-card .btn {
  width: 100%;
}

.seller-chat-auth-x {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1.15rem;
  cursor: pointer;
}

[dir="rtl"] .seller-chat-auth-x {
  right: auto;
  left: 0.45rem;
}

.seller-chat-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: flex-end;
  padding: 0.65rem;
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.seller-chat-file {
  flex: 1 0 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.55rem;
  border-radius: 10px;
  background: var(--canvas);
  color: var(--muted);
  font-size: 0.85rem;
}

.seller-chat-file button {
  min-height: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1.1rem;
  cursor: pointer;
}

.seller-chat :focus-visible {
  outline: none;
}

.seller-chat-attach {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.seller-chat-attach:hover {
  color: var(--ink);
  background: transparent;
}

.seller-chat-msg a {
  display: inline-block;
  margin-top: 0.35rem;
  color: var(--green-dark);
}

.seller-chat-msg img {
  display: block;
  max-width: 100%;
  border-radius: 10px;
}

.seller-chat-form textarea {
  flex: 1;
  min-height: 44px;
  max-height: 220px;
  resize: none;
  overflow-y: hidden;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

.seller-chat-form textarea:focus {
  border-color: var(--muted);
}

.seller-chat-form button {
  min-height: 44px;
}

.seller-chat-file button {
  min-height: 28px;
}

.seller-chat-handle {
  position: absolute;
  touch-action: none;
}

.seller-chat-handle[data-dir="n"],
.seller-chat-handle[data-dir="s"] {
  left: 12px;
  right: 12px;
  height: 8px;
  cursor: ns-resize;
}

.seller-chat-handle[data-dir="n"] { top: 0; }
.seller-chat-handle[data-dir="s"] { bottom: 0; }

.seller-chat-handle[data-dir="e"],
.seller-chat-handle[data-dir="w"] {
  top: 12px;
  bottom: 12px;
  width: 8px;
  cursor: ew-resize;
}

.seller-chat-handle[data-dir="e"] { right: 0; }
.seller-chat-handle[data-dir="w"] { left: 0; }

.seller-chat-handle[data-dir="se"] {
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
}

.seller-chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.seller-chat.is-min .seller-chat-launcher {
  display: inline-flex;
}

.seller-chat-launcher:hover {
  background: var(--green-dark);
}

.seller-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.7rem;
  line-height: 18px;
  text-align: center;
}

[dir="rtl"] .seller-chat-launcher {
  right: auto;
  left: 24px;
}

[dir="rtl"] .seller-chat-msg.is-own {
  margin-left: 0;
  margin-right: auto;
}

@media (max-width: 700px) {
  .seller-chat-window {
    inset: 0 !important;
    width: auto !important;
    height: auto !important;
    min-width: 0;
    min-height: 0;
    border-radius: 0;
  }

  .seller-chat-bar,
  .seller-chat-handle {
    cursor: default;
  }

  .seller-chat-handle {
    display: none;
  }
}
