/* Conversations, on both the buyer and the merchant surfaces. Token colours only, so each surface's own palette and dark mode apply. */
@layer components {
  /* A display rule on .btn or .chat__reply would otherwise beat the hidden attribute. */
  .chat [hidden], [data-staff-push] [hidden], [data-live-page] [hidden] { display: none; }
  .chat { display: flex; flex-direction: column; gap: var(--s-3); min-inline-size: 0; }
  .chat__log {
    display: flex; flex-direction: column; gap: var(--s-2);
    max-block-size: min(52vh, 38rem); min-block-size: 12rem; overflow-y: auto; overscroll-behavior: contain;
    padding: var(--s-3); margin: 0; list-style: none;
    background: var(--surface-2); border-radius: var(--radius);
  }
  .chat__sr { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .chat__below { align-self: center; }
  .chat__composer { display: flex; flex-direction: column; gap: var(--s-2); }
  .chat__composer textarea {
    inline-size: 100%; min-block-size: 5rem; padding: var(--s-3); font: inherit; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line-strong, var(--line)); border-radius: var(--radius); resize: vertical;
  }
  .chat__reply { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-2) var(--s-3); background: var(--surface-2); border-radius: var(--radius-sm); font-size: var(--text-sm); overflow-wrap: anywhere; }
  .chat__tools { display: flex; flex-wrap: wrap; gap: var(--s-2); }

  .bubble { align-self: flex-start; display: flex; flex-direction: column; gap: 2px; max-inline-size: min(85%, 32rem); min-inline-size: 0; padding: var(--s-2) var(--s-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-wrap: anywhere; }
  .bubble--mine { align-self: flex-end; background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
  .bubble--failed { outline: 2px solid var(--bad); }
  .bubble__who { font-size: var(--text-xs); font-weight: var(--weight-bold); }
  .bubble__body { white-space: pre-wrap; }
  .bubble__quote { padding-inline-start: var(--s-2); border-inline-start: 3px solid currentColor; font-size: var(--text-sm); opacity: 0.85; }
  .bubble__ref { padding: var(--s-2); border: 1px dashed currentColor; border-radius: var(--radius-sm); font-size: var(--text-sm); }
  .bubble__ref a { color: inherit; }
  .bubble__meta { display: flex; flex-wrap: wrap; gap: var(--s-2); font-size: var(--text-xs); opacity: 0.85; }
  .bubble__reply { align-self: flex-start; min-block-size: var(--tap); padding: 0; background: none; border: 0; color: inherit; font-size: var(--text-xs); text-decoration: underline; cursor: pointer; }
  /* Replying to one message needs the script. The plain form still sends. */
  html:not(.js) .bubble__reply { display: none; }
  .bubble--mine .btn--quiet { color: inherit; }

  .note { padding: var(--s-3); background: var(--warn-bg, var(--surface-2)); border-inline-start: 4px solid var(--warn, var(--line)); border-radius: var(--radius-sm); overflow-wrap: anywhere; }
  .note__label { font-size: var(--text-xs); font-weight: var(--weight-bold); }
  .note__body { white-space: pre-wrap; }

  .inbox-filter { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: 0; padding: 0; list-style: none; }
  .inbox-filter a { display: inline-flex; align-items: center; min-block-size: var(--tap); padding-inline: var(--s-3); border: 1px solid var(--line); border-radius: var(--radius-full); color: var(--ink); text-decoration: none; }
  .inbox-filter a[aria-current] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

  .count-badge { display: inline-flex; align-items: center; justify-content: center; min-inline-size: 1.25rem; padding-inline: 4px; background: var(--accent); color: var(--on-accent); border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--weight-bold); }
  .header-btn { position: relative; }
  .header-btn .count-badge { position: absolute; inset-block-start: 0; inset-inline-end: 0; }

  .post-card { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow-wrap: anywhere; }
  .post-card__meta { color: var(--ink-2); font-size: var(--text-sm); }
  .post-card__body { white-space: pre-wrap; }
  .post-card__terms { padding: var(--s-3); background: var(--surface-2); border-radius: var(--radius-sm); font-size: var(--text-sm); }
  .post-card__correction { padding: var(--s-2) var(--s-3); background: var(--info-bg); color: var(--info); border-radius: var(--radius-sm); font-size: var(--text-sm); }

  .approval-facts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: var(--s-2) var(--s-4); margin: 0; }
  .approval-facts dt { color: var(--ink-2); }
  .approval-facts dd { margin: 0; overflow-wrap: anywhere; }
  .approval-code { font-size: 2rem; font-weight: var(--weight-bold); letter-spacing: 0.2em; font-variant-numeric: tabular-nums; }
  .simulator-flag { padding: var(--s-2) var(--s-3); background: var(--warn-bg, var(--surface-2)); color: var(--warn, var(--ink)); border-radius: var(--radius-sm); font-weight: var(--weight-bold); }

  @media (prefers-reduced-motion: no-preference) {
    .chat__log { scroll-behavior: smooth; }
  }
}
