.chat-page { width:min(100%,760px); display:grid; gap:17px; min-width:0; }
#main-content:has(>[data-chat-inbox])>.section-head .section-title { align-items:center; gap:8px; }
#main-content:has(>[data-chat-inbox])>.section-head .title-label,
#main-content:has(>[data-chat-inbox])>.section-head .section-title>a { min-height:44px; }
.chat-section { display:grid; gap:8px; min-width:0; }
.chat-section h2 { color:var(--muted); font:var(--type-label); }
.chat-pinned { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; }
.chat-pinned-card {
  position:relative; min-width:0; display:grid; grid-template-columns:72px minmax(0,1fr);
  align-items:center; gap:12px; padding:12px 33px 12px 14px; border:1px solid var(--accent-border);
  border-radius:18px; background:linear-gradient(160deg,var(--tint-subtle),var(--tint));
}
.chat-pinned-art { display:block; width:72px; height:72px; max-width:100%; object-fit:contain; }
.chat-pinned-status { position:absolute; inset-block-start:10px; inset-inline-end:10px; display:grid; place-items:center; }
.chat-pinned-copy { display:grid; gap:4px; min-width:0; }
.chat-pinned-copy strong { font-size:14px; font-weight:680; line-height:1.2; }
.chat-pinned-copy small { color:var(--muted); font-size:12px; line-height:1.25; }
.chat-pin-mark { width:15px; height:15px; color:var(--accent); opacity:.66; }
.chat-list { display:grid; overflow:hidden; border:1px solid var(--line); border-radius:17px; background:var(--surface); }
.chat-entry { min-width:0; display:grid; grid-template-columns:43px minmax(0,1fr) auto; align-items:center; gap:11px; min-height:68px; padding:9px 12px; }
.chat-list .chat-entry + .chat-entry { border-top:1px solid var(--line); }
.chat-pinned-card.chat-feedback { background:linear-gradient(160deg,#f2faf3,#eaf5f1); border-color:#dceee6; }
.chat-feedback .chat-pin-mark { color:#286457; }
@media (max-width:640px) {
  /* Keep the card row on its own layer to avoid a paint seam in Android WebView. */
  .chat-pinned { transform:translateZ(0); }
  .chat-pinned-card {
    grid-template-columns:minmax(0,1fr); grid-template-rows:72px 1fr;
    align-items:start; gap:5px; padding:8px 11px 12px;
  }
  .chat-pinned-art { justify-self:center; }
}
.chat-entry-mark { display:grid; place-items:center; width:43px; height:43px; border-radius:14px; background:var(--tint); color:var(--accent); font-size:13px; font-weight:700; }
.chat-entry-mark svg { width:19px; height:19px; }
.chat-entry-mark.person-avatar,.chat-conversation-head .chat-entry-mark.person-avatar {border-radius:50%}
.chat-entry-copy .chat-preview {display:flex;align-items:center;gap:5px}
.chat-preview>span:last-child {min-width:0;overflow:hidden;text-overflow:ellipsis}
.chat-preview-avatar {
  width:17px;height:17px;flex:none;display:grid;place-items:center;
  background:var(--tint);color:var(--accent);font-size:7px;font-weight:720
}

.chat-mark-feedback,.chat-mark-crew { color:#286457; }
.chat-mark-feedback,.chat-mark-crew { background:#e8f4ef; }
.chat-mark-company { background:var(--tint); }
.chat-mark-direct { background:#efebfb; color:#59438e; }
.chat-entry-new .chat-entry-copy strong { color:var(--accent); }
.chat-entry-copy { display:grid; gap:3px; min-width:0; }
.chat-entry-copy strong { font:var(--type-card); overflow-wrap:anywhere; }
.chat-entry-copy small { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--muted); }
.chat-entry-meta { display:grid; justify-items:end; gap:4px; }
.chat-entry-meta time { color:var(--muted); font-size:11px; font-variant-numeric:tabular-nums; }
.chat-arrow { width:15px; height:15px; color:var(--muted); transform:rotate(-90deg); }
.chat-person-icon { width:18px; height:18px; color:var(--accent); }
.chat-people { display:grid; gap:13px; }
.chat-people h2 { margin:0 0 7px; font:var(--type-section); }
.chat-unread { min-width:21px; padding:2px 6px; border-radius:8px; background:var(--accent-fill); color:var(--accent-on); text-align:center; font-size:11px; font-variant-numeric:tabular-nums; }
.chat-empty,.chat-error { padding:12px 3px; color:var(--muted); font-size:14px; }
.chat-error,[data-chat-error] { color:var(--danger); }
.chat-context-action { min-height:44px; width:100%; }
.chat-conversation {
  height:min(76dvh,720px); grid-template-rows:auto minmax(0,1fr) auto;
  gap:0; border:1px solid var(--line); border-radius:18px; background:var(--surface);
}
.chat-conversation-head {
  display:grid; grid-template-columns:44px 40px minmax(0,1fr) auto; align-items:center; gap:9px;
  padding:11px 14px; border-bottom:1px solid var(--line);
}
.chat-conversation-head .icon-button { width:44px; height:44px; border:0; background:transparent; border-radius:13px; }
.chat-conversation-head .chat-entry-mark { width:40px; height:40px; border-radius:13px; }
.chat-conversation-head h1 { font:var(--type-section); overflow-wrap:anywhere; }
.chat-conversation-head p { color:var(--muted); font:var(--type-label); overflow-wrap:anywhere; }
.chat-conversation-head p:empty { display:none; }
.chat-conversation-head [data-chat-context] { justify-self:end; min-height:44px; padding:5px 9px; font-size:12px; }
.chat-log { display:flex; flex-direction:column; min-height:0; gap:8px; overflow:auto; overscroll-behavior:contain; padding:13px 14px; background:#eef2f7; }
.chat-log > * { flex:none; }
.chat-log > :is(.chat-message,.chat-message-day,.chat-incoming):first-child { margin-top:auto; }
.chat-log .chat-empty { margin:auto; text-align:center; }
.chat-message-day { align-self:center; margin:3px 0; padding:4px 9px; border-radius:8px; background:#e0e7f0; color:#526178; font-size:11px; font-weight:620; }
.chat-message {
  align-self:flex-start; max-width:min(84%,500px); min-width:59px; display:grid; gap:3px;
  padding:9px 11px; border:1px solid #e5eaf2; border-radius:15px 15px 15px 6px; background:var(--surface);
}
.chat-incoming {display:flex;align-items:end;align-self:flex-start;gap:7px;max-width:min(94%,540px);min-width:0}
.chat-incoming .chat-message {max-width:none;min-width:0}
.chat-sender-avatar {
  width:30px;height:30px;display:grid;place-items:center;flex:none;
  background:var(--tint);color:var(--accent);font-size:10px;font-weight:700
}
.chat-sender-avatar svg {width:15px;height:15px}
.chat-message.mine { align-self:flex-end; border-color:transparent; border-radius:15px 15px 6px 15px; background:var(--tint); }
.chat-message strong { color:var(--accent); font-size:12px; }
.chat-message.chat-greeting { max-width:min(94%,550px); }
.chat-message p { white-space:pre-wrap; overflow-wrap:anywhere; font-size:14px; }
.chat-message time { justify-self:end; color:var(--muted); font-size:11px; font-variant-numeric:tabular-nums; }
.chat-composer { display:grid; gap:5px; padding:8px 10px 10px; border-top:1px solid var(--line); }
.chat-compose-panel { min-width:0; padding:4px; border:1px solid var(--line); border-radius:18px; background:#fafbfe; }
.chat-compose-panel:focus-within { border-color:#aab6e6; }
.chat-compose-row { display:grid; grid-template-columns:44px minmax(0,1fr) 44px; align-items:end; gap:2px; }
.chat-compose-label { min-width:0; }
.chat-composer textarea { width:100%; min-width:0; min-height:44px; max-height:120px; display:block; resize:none; padding:11px 3px 9px; border:0; background:transparent; color:var(--ink); font-size:16px; line-height:1.4; }
.chat-composer textarea::placeholder { color:var(--muted); }
.chat-composer textarea:focus-visible { outline-offset:-2px; border-radius:8px; }
.chat-composer .button { padding:0; min-height:44px; border-radius:13px; box-shadow:none; }
.chat-composer .button svg { width:20px; height:20px; }
.chat-attach { position:relative; }
.chat-attach > summary { display:grid; place-items:center; width:44px; height:44px; border:0; border-radius:12px; list-style:none; padding:0; background:transparent; color:var(--muted); }
.chat-attach > summary::-webkit-details-marker { display:none; }
.chat-attach[open] > summary { background:var(--tint); color:var(--accent); }
.chat-attach-options { position:absolute; z-index:8; bottom:calc(100% + 6px); left:0; width:max-content; min-width:155px; padding:5px; background:var(--surface); border:1px solid var(--line); border-radius:13px; box-shadow:0 7px 24px #20243626; }
.chat-attach-options label { position:relative; display:flex; align-items:center; gap:9px; min-height:43px; padding:6px 10px; font-size:14px; font-weight:600; color:var(--ink); cursor:pointer; }
.chat-attach-options svg { width:17px; height:17px; color:var(--accent); }
.chat-attach-options input { position:absolute; inset:0; width:100%; height:100%; opacity:0; cursor:pointer; }
.chat-draft-attachments { display:grid; gap:4px; margin:1px 1px 4px; }
.chat-draft-item { display:grid; grid-template-columns:minmax(0,1fr) 44px; align-items:center; min-width:0;
  border-inline-start:2px solid var(--accent); border-radius:4px 11px 11px 4px; background:var(--tint); }
.chat-draft-item .icon-button { display:grid; place-items:center; width:44px; height:44px; padding:0; border:0; color:var(--muted); background:transparent; }
.chat-draft-item .icon-button svg { width:15px; height:15px; }
.chat-tool-card,.chat-file-card { display:flex; align-items:center; gap:8px; min-width:0; padding:6px 8px; border-radius:9px; background:var(--surface); border:1px solid var(--line); }
.chat-tool-card strong,.chat-file-card span { display:block; font-size:13px; overflow-wrap:anywhere; }
.chat-tool-card small { display:block; color:var(--muted); font-size:11px; overflow-wrap:anywhere; }
.chat-attachment-icon { width:36px; height:36px; flex:none; display:grid; place-items:center; overflow:hidden; border-radius:8px; color:var(--accent); background:var(--tint); }
.chat-attachment-icon img { width:100%; height:100%; object-fit:cover; }
.chat-draft-item :is(.chat-tool-card,.chat-file-card) { border:0; background:transparent; padding:6px 8px; }
.chat-draft-item .chat-attachment-icon { width:33px; height:33px; background:var(--surface); }
.chat-draft-item .chat-tool-card > span:nth-child(2) { min-width:0; }
.chat-draft-item .chat-tool-card :is(strong,small) { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.chat-file-card svg { width:18px; height:18px; color:var(--accent); }
.chat-media { display:block; max-width:100%; width:min(100%,320px); max-height:260px; border-radius:9px; overflow:hidden; }
.chat-media img { width:100%; max-height:260px; object-fit:contain; border-radius:9px; }
.chat-draft-item .chat-media { width:max-content; max-width:100%; padding:5px 8px; }
.chat-draft-item .chat-media img { width:auto; max-width:100%; height:49px; }
.chat-composer [data-chat-error] { grid-column:1/-1; font-size:13px; }
.chat-sr { position:absolute; width:1px; height:1px; padding:0; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
.chat-older { align-self:center; min-height:44px; padding:6px 13px; border:0; border-radius:10px; background:var(--surface); color:var(--accent); font-size:13px; }
@media (max-width:800px) {
  body:has(#main-content>.chat-conversation) .mobile-header { display:none; }
  body:has(#main-content>.chat-conversation) #main-content { padding:0; max-width:none; }
  .chat-conversation { width:100%; height:var(--chat-viewport-height,100dvh); min-height:150px; border:0; border-radius:0; }
  .chat-conversation-head { padding:7px 11px 7px 5px; background:var(--handheld-canvas); }
  .chat-composer { padding-bottom:max(10px,env(safe-area-inset-bottom)); }
}
@media (max-width:355px) {
  .chat-conversation-head [data-chat-context] { grid-column:3/-1; justify-self:start; }
}
@media (hover:hover) {
  .chat-entry:hover { background:var(--soft); }
  .chat-pinned-card:hover { filter:brightness(.975); }
}

@media screen and (min-width:801px) and (hover:hover) and (pointer:fine) {
  .chat-page { width:100%; }
  .chat-page[data-chat-inbox] { gap:24px; }
  .chat-page[data-chat-inbox] .chat-section { gap:10px; }
  .chat-page[data-chat-inbox] .chat-pinned { gap:14px; }
  .chat-page[data-chat-inbox] .chat-pinned-card {
    grid-template-columns:84px minmax(0,1fr);
    gap:16px;
    min-height:118px;
    padding:14px 38px 14px 19px;
  }
  .chat-page[data-chat-inbox] .chat-pinned-art { width:84px; height:84px; }
  .chat-page[data-chat-inbox] .chat-pinned-copy strong { font-size:16px; }
  .chat-page[data-chat-inbox] .chat-pinned-copy small { font-size:13px; }
  .chat-page[data-chat-inbox] .chat-pinned-card.chat-feedback {
    border-color:var(--line);
    background:var(--soft);
  }
  .chat-page[data-chat-inbox] .chat-feedback .chat-pin-mark { color:var(--muted); }
  .chat-page[data-chat-inbox] .chat-entry { padding-inline:16px; }
  .chat-page .chat-mark-crew { background:#eceef6; color:var(--muted); }
  .chat-page[data-chat-inbox] .workspace-empty.compact {
    width:100%;
    grid-template-columns:minmax(0,1fr);
    justify-items:center;
    gap:8px;
    padding:20px;
    text-align:center;
    background:#fafbfd;
  }
  .chat-page[data-chat-inbox] .workspace-empty.compact img { width:86px; }
  .chat-page[data-chat-inbox] .workspace-empty-content { justify-items:center; }
  .chat-page[data-chat-inbox] .workspace-empty-actions { justify-content:center; }
}
