.chat-page-active .shell { padding-block-end: 22px; }
.chat-page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; }
.chat-page-header nav { display: flex; gap: 4px; }
.chat-page-header [aria-current] { background: #dceaf8; color: var(--accent); border-radius: 12px; }
.chat-screen {
  --chat-surface: #f8fbff;
  --chat-panel: #fff;
  --chat-ink: #18293a;
  --chat-muted: #4c6074;
  --chat-border: #dce6ef;
  color: var(--chat-ink);
}
.chat-ready {
  position: relative;
  display: grid;
  grid-template-columns: minmax(215px, 29%) minmax(0, 1fr);
  min-height: 410px;
  height: calc(100dvh - clamp(20px, 3.3vw, 48px) - 92px);
  overflow: hidden;
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  background: var(--chat-surface);
}
.chat-sign-in { max-width: 410px; padding: 28px 20px 38px; }
.chat-sign-in h1, .chat-inbox h1 { margin: 0 0 14px; font-size: 1.6rem; letter-spacing: -.03em; }
.chat-sign-in label { display: grid; gap: 6px; }
.chat-sign-in select { padding: 9px 12px; min-height: 44px; border: 1px solid var(--chat-border); border-radius: 10px; background: #fff; }
.chat-sign-in button { margin-top: 14px; }
.chat-inbox { min-height: 0; overflow: auto; padding: 19px 12px 12px; border-inline-end: 1px solid var(--chat-border); background: var(--chat-panel); }
.chat-inbox h1 { padding-inline: 9px; }
.chat-threads { display: grid; gap: 2px; }
.chat-thread { display: flex; align-items: center; gap: 11px; min-height: 64px; padding: 8px; border-radius: 12px; }
.chat-threads button.chat-thread { width: 100%; text-align: start; }
.chat-thread:hover { background: #f0f6fb; }
.chat-thread[aria-current="page"] { background: #e7f2fc; }
.chat-unread { margin-inline-start: auto; flex: none; min-width: 22px; padding: 2px 6px; border-radius: 999px; background: #1b5a8a; color: white; text-align: center; font-size: .74rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.chat-avatar { flex: none; display: grid; place-items: center; inline-size: 42px; block-size: 42px; overflow: hidden; border-radius: 12px; color: #215684; background: #e3eef8; }
.chat-avatar img { inline-size: 100%; block-size: 100%; object-fit: cover; }
.chat-identity { display: grid; min-width: 0; align-content: center; gap: 2px; line-height: 1.24; }
.chat-identity strong, .chat-identity small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-identity strong { font-size: .98rem; font-weight: 660; }
.chat-identity small { font-size: .78rem; color: var(--chat-muted); font-weight: 400; }
.chat-queue, .chat-account { margin: 10px 8px 0; border-top: 1px solid var(--chat-border); }
.chat-inbox .action { border-radius: 10px; padding-inline: 8px; color: var(--accent); font-size: .88rem; }
.chat-queue summary, .chat-account summary { padding: 11px 4px; min-height: 44px; cursor: pointer; color: var(--chat-muted); font-size: .88rem; font-weight: 600; }
.chat-queue summary span { margin-inline-start: 3px; font-variant-numeric: tabular-nums; }
.chat-queue ul { font-size: .88rem; }
.chat-conversation { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.chat-peer { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 64px; padding: 9px 14px; border-bottom: 1px solid var(--chat-border); background: var(--chat-panel); }
.chat-peer h2 { flex: 1; display: flex; align-items: center; gap: 11px; min-width: 0; margin: 0; }
.chat-peer h2:focus, .chat-inbox h1:focus { outline: none; }
.chat-back { display: none; }
.chat-peer button, .chat-back { width: 44px; height: 44px; flex: none; padding: 0; color: var(--accent); }
.chat-peer button svg, .chat-back svg { width: 20px; height: 20px; }
.chat-feed { position: relative; display: grid; min-height: 0; }
.chat-messages { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; min-height: 0; padding: 16px 21px 18px; overflow: auto; overscroll-behavior: contain; }
.chat-messages::before { content: ""; margin-block-start: auto; }
.chat-history { align-self: center; margin-bottom: 4px; color: var(--accent); font-size: .84rem; }
.chat-new-messages { position: absolute; inset-block-end: 10px; inset-inline-end: 12px; min-height: 44px; padding-inline: 13px; border: 1px solid var(--chat-border); border-radius: 14px; background: var(--chat-panel); color: var(--accent); font-size: .84rem; font-weight: 650; box-shadow: 0 2px 8px #17395421; }
.chat-messages:focus-visible { outline-offset: -3px; }
.chat-message { display: grid; gap: 2px; max-width: min(80%, 48ch); padding: 8px 11px 6px; border-radius: 15px 15px 15px 5px; background: #eaf0f6; }
.chat-message.own { align-self: flex-end; border-radius: 15px 15px 5px 15px; background: #dbeefa; }
.chat-message strong { font-weight: 650; color: #174b76; font-size: .76rem; }
.chat-message-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-message time { justify-self: end; font-variant-numeric: tabular-nums; color: var(--chat-muted); font-size: .68rem; line-height: 1; }
.chat-day { align-self: center; margin: 5px 0 9px; color: var(--chat-muted); font-size: .74rem; text-align: center; }
.chat-empty, .chat-placeholder { color: var(--chat-muted); font-size: .9rem; }
.chat-threads .chat-empty, .chat-queue .chat-empty { margin: 8px; }
.chat-messages .chat-empty, .chat-placeholder { place-self: center; margin: auto; padding: 16px; text-align: center; }
.chat-placeholder a { color: var(--accent); text-decoration: underline; }
.chat-conversation > form { display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: end; gap: 9px; padding: 10px 14px; border-top: 1px solid var(--chat-border); background: var(--chat-panel); }
.chat-conversation textarea { display: block; width: 100%; min-height: 44px; max-height: 112px; padding: 10px 13px; border: 1px solid var(--chat-border); border-radius: 14px; background: #eff5fa; color: inherit; font: inherit; resize: none; }
.chat-conversation textarea { field-sizing: content; }
.chat-conversation textarea::placeholder { color: var(--chat-muted); }
.chat-send { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 14px; background: #1b5a8a; color: #fff; }
.chat-send:disabled { background: #e2edf6; color: #4e6d86; cursor: default; }
.chat-send svg { width: 21px; height: 21px; }
.chat-status { position: absolute; z-index: 1; inset: auto 10px 66px auto; max-width: calc(100% - 20px); padding: 5px 8px; border-radius: 8px; background: var(--chat-panel); color: #8b272b; font-size: .79rem; }
.chat-status:empty { width: 0; height: 0; margin: 0; padding: 0; }
@media (max-width: 780px) {
  .chat-page-active .shell { margin: 0; width: 100%; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
  .chat-page-header, .chat-page-active:has(.has-thread) .mobile-nav { display: none; }
  .chat-sign-in { padding-top: max(28px, env(safe-area-inset-top)); }
  .chat-ready { display: block; min-height: 0; height: calc(var(--chat-viewport, 100dvh) - 63px - max(8px, env(safe-area-inset-bottom))); border: 0; border-radius: 0; }
  .chat-ready.has-thread { height: var(--chat-viewport, 100dvh); }
  .chat-inbox { height: 100%; padding-top: max(16px, env(safe-area-inset-top)); border: 0; }
  .chat-inbox h1 { margin-bottom: 10px; }
  .chat-conversation { display: none; }
  .chat-ready.has-thread .chat-inbox { display: none; }
  .chat-ready.has-thread .chat-conversation { display: grid; height: 100%; }
  .chat-peer { gap: 4px; padding: max(7px, env(safe-area-inset-top)) 8px 7px 4px; }
  .chat-back { display: inline-grid; place-items: center; }
  .chat-peer h2 { gap: 8px; }
  .chat-peer .chat-avatar { width: 36px; height: 36px; border-radius: 10px; }
  .chat-messages { padding: 13px 12px; }
  .chat-conversation > form { padding: 8px 10px max(8px, env(safe-area-inset-bottom)); }
  .chat-ready.has-thread .chat-placeholder { grid-row: 2; }
}
