/* 沿用_original/styles.css聊天元件。 */
.customer-chat-header,
.admin-conversation-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.customer-chat-header img,
.admin-conversation-header img {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}

.customer-chat-header h2,
.admin-conversation-header h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.customer-chat-header p,
.admin-conversation-header p {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.chat-size-control {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.15rem;
  margin-left: auto;
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
}

.chat-size-control > span {
  padding-inline: 0.35rem 0.2rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.chat-size-control button {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 800;
}

.chat-size-control button:hover,
.chat-size-control button:focus-visible {
  color: var(--brand-dark);
  outline: none;
  box-shadow: var(--focus-ring);
}

.chat-size-control button[aria-pressed="true"] {
  background: var(--brand);
  color: white;
}

.chat-size-control.is-compact {
  width: max-content;
  margin: 0;
}

.chat-timeline {
  min-width: 0;
  min-height: 0;
  padding: 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    linear-gradient(rgba(255, 250, 245, 0.92), rgba(255, 250, 245, 0.92)),
    radial-gradient(circle at 16% 12%, rgba(200, 105, 88, 0.12), transparent 28%);
}

.chat-timeline-frame {
  --chat-text-size: 1rem;
  --chat-meta-size: 0.72rem;
  --chat-divider-size: 0.75rem;
  --chat-reference-media: 48px;
  --chat-reference-width: 360px;
  --chat-reference-padding: 0.55rem;
  --chat-reference-meta-size: 0.75rem;
  --chat-reference-title-size: 0.95rem;
  --chat-image-height: 150px;
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.chat-timeline-frame.chat-size-small {
  --chat-text-size: 0.88rem;
  --chat-meta-size: 0.66rem;
  --chat-divider-size: 0.68rem;
  --chat-reference-media: 42px;
  --chat-reference-width: 320px;
  --chat-reference-padding: 0.45rem;
  --chat-reference-meta-size: 0.68rem;
  --chat-reference-title-size: 0.86rem;
  --chat-image-height: 112px;
}

.chat-timeline-frame.chat-size-large {
  --chat-text-size: 1.12rem;
  --chat-meta-size: 0.8rem;
  --chat-divider-size: 0.82rem;
  --chat-reference-media: 56px;
  --chat-reference-width: 400px;
  --chat-reference-padding: 0.65rem;
  --chat-reference-meta-size: 0.82rem;
  --chat-reference-title-size: 1.05rem;
  --chat-image-height: 190px;
}

.chat-timeline-frame > .chat-timeline {
  min-height: 0;
}

.chat-timeline-frame.is-modal {
  max-height: min(440px, 52dvh);
}

.chat-jump-latest {
  position: absolute;
  right: 1rem;
  bottom: 0.8rem;
  z-index: 2;
  box-shadow: var(--shadow);
}

.chat-jump-latest[hidden] {
  display: none;
}

.chat-timeline.is-modal {
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.chat-date-divider {
  display: flex;
  justify-content: center;
  margin: 0.75rem 0;
}

.chat-date-divider span {
  padding: 0.2rem 0.6rem;
  border: 1px solid rgba(234, 217, 205, 0.9);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--muted);
  font-size: var(--chat-divider-size, 0.75rem);
}

.chat-message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  margin: 0.65rem 0;
}

.chat-message.is-own {
  align-items: flex-end;
}

.chat-message-bubble {
  max-width: min(76%, 520px);
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.3rem var(--radius) var(--radius) var(--radius);
  background: var(--surface);
  box-shadow: 0 3px 10px rgba(112, 76, 55, 0.07);
}

.chat-message.is-own .chat-message-bubble {
  border-color: rgba(110, 146, 121, 0.38);
  border-radius: var(--radius) 0.3rem var(--radius) var(--radius);
  background: #e8f2e6;
}

.chat-message-bubble > p {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: var(--chat-text-size, 1rem);
}

.chat-message-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: var(--chat-meta-size, 0.72rem);
}

.chat-read-receipt {
  color: var(--accent);
  font-weight: 700;
}

.chat-reference-card {
  display: grid;
  grid-template-columns: var(--chat-reference-media, 48px) minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
  width: min(var(--chat-reference-width, 360px), 100%);
  margin-bottom: 0.55rem;
  padding: var(--chat-reference-padding, 0.55rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fffdf9;
}

.chat-reference-card:hover,
.chat-reference-card:focus-visible {
  border-color: var(--brand);
  outline: none;
  box-shadow: var(--focus-ring);
}

.chat-reference-card img,
.chat-reference-icon {
  display: grid;
  place-items: center;
  width: var(--chat-reference-media, 48px);
  height: var(--chat-reference-media, 48px);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  object-fit: cover;
}

.chat-reference-card > span:nth-child(2) {
  display: grid;
  min-width: 0;
  line-height: 1.35;
}

.chat-reference-card small,
.chat-reference-card span span {
  color: var(--muted);
  font-size: var(--chat-reference-meta-size, 0.75rem);
}

.chat-reference-card strong {
  font-size: var(--chat-reference-title-size, 0.95rem);
}

.chat-reference-card strong,
.chat-reference-card span span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-image-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.chat-image-grid button {
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: zoom-in;
}

.chat-image-grid img {
  width: 100%;
  height: var(--chat-image-height, 150px);
  object-fit: cover;
}

.chat-composer {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.chat-composer-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: end;
}

.chat-composer .textarea {
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  overflow-y: auto;
  resize: none;
}

.chat-attach-button,
.chat-send-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
}

.chat-attach-button {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--brand-dark);
  cursor: pointer;
}

.chat-attach-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.chat-composer-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.chat-image-preview {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
}

.chat-image-preview figure {
  position: relative;
  flex: 0 0 72px;
  margin: 0;
}

.chat-image-preview img {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.chat-image-preview button {
  position: absolute;
  top: -0.3rem;
  right: -0.3rem;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--danger);
}

.chat-pending-reference {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.4rem 0.75rem;
  align-items: center;
}

.chat-pending-reference > span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.75rem;
}

.chat-empty {
  display: grid;
  place-content: center;
  gap: 0.25rem;
  min-height: 180px;
  padding: 1.5rem;
  color: var(--muted);
  text-align: center;
}


@media(max-width:640px){  .customer-chat {
    min-height: calc(100dvh - 7rem);
    border-radius: 1rem;
  }

  .customer-chat-header,
  .admin-conversation-header {
    padding: 0.85rem;
  }

  .customer-chat-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }

  .customer-chat-header > div:not(.chat-size-control) {
    min-width: 0;
  }

  .customer-chat-header .chat-size-control {
    grid-column: 1 / -1;
    justify-self: end;
    margin-left: 0;
  }

  .chat-timeline {
    padding: 0.8rem;
  }

  .chat-message-bubble {
    max-width: 88%;
  }

  .chat-composer {
    padding: 0.7rem;
  }

  .chat-reference-card {
    grid-template-columns: var(--chat-reference-media, 44px) minmax(0, 1fr) auto;
  }

  .chat-reference-card img,
  .chat-reference-icon {
    width: var(--chat-reference-media, 44px);
    height: var(--chat-reference-media, 44px);
  }

  .chat-image-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chat-timeline-frame {
    --chat-image-height: 120px;
  }

  .chat-timeline-frame.chat-size-small {
    --chat-image-height: 96px;
  }

  .chat-timeline-frame.chat-size-large {
    --chat-image-height: 148px;
  }


}
.chat-message-bubble > p {white-space:pre-wrap;}
.chat-feedback:empty {display:none;}
.chat-feedback {margin:0;color:var(--muted);font-size:.8rem;}
.chat-attach-button:disabled {opacity:.55;cursor:not-allowed;}
.chat-size-control button {min-width:28px;}

.chat-thread-host{display:contents}.chat-thread-host .chat-timeline-frame{min-height:0}.chat-size-control{white-space:nowrap}.chat-feedback button{margin-left:.5rem}

.chat-composer .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


.chat-image-preview[hidden]{display:none}.chat-attach-button:focus-visible{outline:2px solid var(--brand);outline-offset:2px}

/* 背景暫停／重新連線提示保留一行，恢復前景時不推動整塊聊天。 */
#chat-status{line-height:1.65;min-height:1.65em;}

.chat-timeline{overflow-anchor:none}.chat-date-divider[hidden]{display:none}.chat-page-edge{display:block;width:100%;min-height:32px;border:0;background:transparent;color:var(--muted);font-size:.78rem;cursor:pointer}.chat-page-edge:disabled{cursor:default}.chat-image-grid img{display:block}
