.chat-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 700px), (orientation: landscape) and (pointer: coarse) and (max-height: 520px) {
  body.user #chat {
    --conversation-heading-height: 68px;
    position: relative;
    background: #fff;
  }
  body.user #chat .chat-heading {
    /* The App route already paints and reserves the system status bar above this frame. */
    position: absolute;
    inset: 0 0 auto;
    z-index: 1;
    isolation: isolate;
    display: flex;
    height: var(--conversation-heading-height);
    min-height: 0;
    gap: 12px;
    padding: 8px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
    border: 0;
    background: transparent;
    pointer-events: none;
  }
  body.user .chat-heading::before {
    content: "";
    position: absolute;
    inset: 0 0 -12px;
    z-index: -1;
    background: linear-gradient(#f4f5f1, rgba(255, 255, 255, .9) 65%);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    -webkit-mask-image: linear-gradient(#000 65%, transparent);
    mask-image: linear-gradient(#000 65%, transparent);
  }
  body.user .chat-heading .chatLogo { display: none; }
  body.user .chat-heading #back {
    pointer-events: auto;
    width: 44px;
    height: 44px;
    color: #171717;
    border: .5px solid #0000000d;
    border-radius: 50%;
    background: rgba(244, 244, 244, .92);
    box-shadow: inset 0 1px 1px #ffffff12, 0 3px 10px #0002;
  }
  body.user .chat-heading #back .wb-icon { width: 28px; height: 28px; }
  body.user .chat-heading .identity {
    pointer-events: auto;
    text-align: start;
  }
  body.user .chat-heading #title {
    color: #171717;
    font-size: 16px;
    font-weight: 650;
    line-height: 20px;
  }
  body.user .chat-heading #subtitle {
    display: block;
    min-height: 15px;
    margin-top: 3px;
    color: #646469;
    font-size: 12px;
    line-height: 15px;
  }
  body.user #chat #timeline {
    --timeline-start: calc(var(--conversation-heading-height) + 12px);
    --timeline-paper: #fff;
    background: #fff;
  }
}

#timeline {
  --timeline-start: 16px;
  --day-divider-height: 28px;
  --timeline-paper: var(--canvas, #f7f7f5);
  isolation: isolate;
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0 clamp(16px, 3vw, 40px) 24px;
  scroll-padding-top: calc(var(--conversation-heading-height, 0px) + var(--day-divider-height));
  background: var(--timeline-paper);
}
/* Leading space scrolls away; the sticky date starts directly below the navigation. */
#timeline::before {
  content: "";
  display: block;
  height: var(--timeline-start);
}
#timeline .message-day { display: flow-root; }
#timeline article {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 0 0 16px;
}
#timeline article:last-child { margin-bottom: 0; }
#timeline article.mine { align-items: flex-end; }
#timeline .day-divider,
#timeline .center {
  display: flex;
  justify-content: center;
  align-items: center;
  align-self: stretch;
  gap: 12px;
  color: var(--muted, #646660);
  font-size: 12px;
  font-weight: 400;
  line-height: 16px;
  text-align: center;
}
#timeline .day-divider {
  position: sticky;
  top: var(--conversation-heading-height, 0px);
  z-index: 1;
  height: var(--day-divider-height);
  margin-bottom: 12px;
  background: var(--timeline-paper);
  color: var(--muted, #52574f);
  font-weight: 600;
  white-space: nowrap;
}
#timeline .day-divider::before,
#timeline .day-divider::after {
  content: "";
  height: 1px;
  background: #d2d5ce;
  flex: 1;
}
#timeline .center { padding: 8px 16px; }
#timeline .bubble {
  min-width: 0;
  max-width: min(82%, 584px);
  padding: 12px 16px;
  border: 1px solid var(--line, #dedfda);
  border-radius: 16px 16px 16px 4px;
  color: var(--ink, #20211f);
  background: white;
  font: inherit;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: normal;
}
#timeline .mine .bubble {
  border-radius: 16px 16px 4px 16px;
  background: #eceeeb;
  border-color: transparent;
}
#timeline .note .bubble {
  background: #fbf6e7;
  border-color: #e8dfc4;
}
#timeline .bubble > small:first-child {
  color: var(--muted, #646660);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 4px;
}
#timeline .auto-reply-label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.auto-reply-label .chat-icon { width: 14px; height: 14px; }
#timeline .bubble.has-record {
  padding: 0;
  background: transparent;
  border: 0;
  width: min(82%, 276px);
}
#timeline .bubble.has-record .render:not(:empty) {
  margin-top: 8px;
  padding: 10px 14px;
  background: white;
  border: 1px solid var(--line, #dedfda);
  border-radius: 12px;
}
#timeline .mine .bubble.has-record .render:not(:empty) {
  background: #eceeeb;
  border-color: transparent;
}
.render > :first-child { margin-top: 0; }
.render > :last-child { margin-bottom: 0; }
.render p { margin: 0 0 8px; }
.render ul, .render ol { padding-inline-start: 20px; }
.render pre {
  max-width: 100%;
  overflow-x: auto;
  padding: 12px;
  margin: 8px 0;
  border-radius: 8px;
  background: #f4f4f1;
  font-size: 13px;
}
.render a { color: inherit; text-decoration: underline; }
.copy-code {
  padding: 4px 8px;
  margin-top: 4px;
  font-size: 12px;
}
#timeline .meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 2px;
  min-height: 28px;
  font-size: 12px;
  color: var(--muted, #646660);
  font-variant-numeric: tabular-nums;
}
.meta .message-receipt { display: inline-flex; align-items: center; gap: 2px; }
.message-receipt .chat-icon { width: 14px; height: 14px; }
#timeline .message-more {
  width: 32px;
  height: 28px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  color: var(--muted, #646660);
  background: transparent;
}
#timeline .message-more:hover,
#timeline .message-more:focus-visible {
  color: var(--ink, #20211f);
  background: #e6e7e3;
}
#timeline .record-card, #sheetBody .record-card,
#timeline .message-file {
  margin: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  text-align: start;
  padding: 12px 16px;
  gap: 8px;
  border: 1px solid var(--line, #dedfda);
  border-radius: 12px;
  background: white;
  color: var(--ink, #20211f);
  font-weight: 400;
}
#sheetBody .record-card { margin: 8px 0; }
#timeline .record-card:hover, #sheetBody .record-card:hover,
#timeline .message-file:hover { border-color: #a7a9a2; }
.record-caption {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  color: var(--muted, #646660);
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
}
.record-caption .chat-icon:first-child { color: var(--ink, #20211f); }
.record-caption .chat-icon:last-child,
.message-file .chat-icon:last-child {
  margin-inline-start: auto;
  width: 14px;
  height: 14px;
  color: var(--muted, #646660);
}
.record-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 20px;
  overflow-wrap: anywhere;
}
.record-footer {
  width: 100%;
  border-top: 1px dashed #d2d3cd;
  padding-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted, #646660);
}
.order-number {
  font: 500 20px/24px ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.record-number {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  color: var(--ink, #20211f);
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
#timeline .message-file {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}
.message-file > span { min-width: 0; }
.message-file strong { font-weight: 500; font-size: 14px; }
.message-file small { display: block; font-size: 12px; color: var(--muted, #646660); }
#composer {
  flex: none;
  border-top: 1px solid var(--line, #dedfda);
  background: white;
  padding: 12px clamp(16px, 3vw, 40px) max(12px, env(safe-area-inset-bottom));
}
#composer .writing {
  display: block;
  padding: 4px;
  border: 1px solid #cfd1cb;
  border-radius: 12px;
  background: white;
}
#composer .writing:focus-within { border-color: #71736a; }
#composer #draft {
  display: block;
  flex: initial;
  margin: 0;
  width: 100%;
  min-height: 44px;
  max-height: 24vh;
  resize: vertical;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  background: transparent;
  color: var(--ink, #20211f);
  font: inherit;
  line-height: 1.45;
}
#composer #draft:focus { outline: 0; }
#composer .composer-toolbar,
#composer .composer-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
#composer .composer-toolbar { justify-content: space-between; }
#composer .composer-tools > button,
#composer #send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  padding: 0 8px;
  color: var(--muted, #646660);
  background: transparent;
  font-size: 13px;
}
#composer .composer-tools > button:hover { background: var(--canvas, #f7f7f5); }
#composer #add { width: 36px; padding: 0; }
#composer #send {
  background: var(--accent, #ffcb35);
  color: #242015;
  padding: 0 12px;
  font-weight: 600;
}
#composer #send:hover { background: #f1bd28; }
#composer button:disabled { opacity: .5; }
#attachment:not(:empty) {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px 8px;
}
#attachment strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
}
#attachment button { min-height: 32px; font-size: 12px; }
#attachment.card-reference {
  gap: 8px;
  color: var(--muted);
}
#attachment.card-reference strong {
  flex: 1;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
#attachment.card-reference > .chat-icon { width: 16px; height: 16px; }
#attachment.card-reference button {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
}
#attachment.card-reference button .chat-icon { width: 16px; height: 16px; }
#attachment.card-reference button:active { color: var(--ink); }
#attachment.card-reference button:focus-visible { outline: 2px solid currentColor; outline-offset: -6px; }
#sheet[data-kind="message-actions"] #sheetBody {
  display: grid;
  gap: 4px;
  padding: 8px;
}
#sheet[data-kind="message-actions"] #sheetBody > button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 8px 12px;
  margin: 0;
  background: transparent;
  border: 0;
  text-align: start;
  color: var(--ink, #20211f);
}
#sheet[data-kind="message-actions"] #sheetBody > button:hover {
  background: var(--canvas, #f7f7f5);
}
#sheet[data-kind="attachments"] {
  width: min(400px, calc(100vw - 32px));
  border-radius: 22px;
}
#sheet[data-kind="attachments"] > header {
  padding: 12px 16px 6px 24px;
  border: 0;
}
#sheet[data-kind="attachments"] #sheetTitle { font-size: 20px; }
#sheet[data-kind="attachments"] #sheetTitle:focus { outline: none; }
#sheet[data-kind="attachments"] #close {
  width: 44px;
  height: 44px;
  border: 6px solid transparent;
  border-radius: 50%;
  background: #f2f2f0;
  background-clip: padding-box;
}
#sheet[data-kind="attachments"] #sheetBody {
  padding: 8px 24px max(20px, env(safe-area-inset-bottom));
}
.attachment-group {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 0 8px;
}
.attachment-group + .attachment-group {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 16px;
}
.attachment-group h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}
.attachment-group .file-limit,
.attachment-copy small {
  font-size: 12px;
  color: var(--muted);
}
.attachment-media {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-column: 1 / -1;
  gap: 8px;
  margin-top: 10px;
}
.attachment-media button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 68px;
  padding: 8px 4px;
  border: 0;
  border-radius: 12px;
  background: #f3f3f1;
  font-weight: 500;
}
.attachment-group .chat-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.attachment-record {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 16px;
  align-items: center;
  column-gap: 12px;
  min-height: 58px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  text-align: start;
}
.attachment-copy { display: grid; gap: 1px; }
.attachment-copy strong { font-size: 15px; font-weight: 550; }
.attachment-record > .chat-icon:last-child { width: 16px; height: 16px; color: var(--muted); }
.attachment-media button:active, .attachment-record:active { background: var(--line); }
@media (max-width: 700px) {
  #sheet[data-kind="attachments"] {
    width: 100%;
    border-radius: 22px 22px 0 0;
  }
  #sheet[data-kind="attachments"] > header { padding-inline: 20px 12px; }
  #sheet[data-kind="attachments"] #sheetBody { padding-inline: 20px; }
}
@media (min-width: 701px) {
  #sheet[data-kind="message-actions"] {
    position: fixed;
    width: 208px;
    inset: auto;
    top: clamp(8px, var(--action-top), calc(100% - 168px));
    left: clamp(8px, calc(var(--action-left) - 104px), calc(100% - 216px));
    margin: 0;
  }
}
@media (max-width: 700px) {
  #timeline { --timeline-start: 12px; padding: 0 16px 16px; }
  #timeline .bubble { max-width: 88%; }
  #timeline article { margin-bottom: 12px; }
  #timeline .message-more { width: 40px; min-height: 32px; }
  #composer { padding: 8px 12px max(8px, env(safe-area-inset-bottom)); }
  #composer #draft { font-size: 16px; min-height: 40px; resize: none; }
  #composer .composer-tools > button, #composer #send { min-height: 40px; }
  #composer #add { width: 40px; }
}

.clipboard-proxy {
  position: fixed;
  inset: 0 auto auto 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
