.chat-action { grid-column: 1 / -1; justify-self: center; width: min(100%, max(10rem, 24%)); }
.chat-lock-mark { font-size: .56em; margin-inline-start: -.4em; }
.chat-page body { margin: 0; background: #fff; }
.chat-page #home-page, .chat-page .rail { display: none; }
#chat-route [hidden], .chat-bell [hidden], .trainer-chat-bell[hidden] { display: none !important; }
.chat-locked {
  min-height: 100svh; display: grid; place-content: center; justify-items: center; gap: .9rem;
  padding: 1.25rem; text-align: center; background: #fff; color: #393e4b;
}
.chat-locked svg { width: clamp(7rem, 20vw, 11rem); }
.chat-locked h1 { margin: 0; font-size: clamp(1.9rem, 5vw, 3.7rem); letter-spacing: -.055em; }
.chat-locked p { margin: 0 0 .25rem; color: #62697a; }
.chat-locked > a { margin-top: .2rem; color: #78434f; font-size: .85rem; }

.chat-bell { position: relative; padding: 0; border: 0; background: transparent; cursor: pointer; }
.chat-unread-dot {
  position: absolute; top: 11%; right: 11%; width: .65rem; height: .65rem; border-radius: 50%;
  background: #bf4d60; border: 1.5px solid #fff; box-shadow: 0 0 0 1px #a84352;
}
.trainer-chat-bell {
  position: fixed; z-index: 30; left: .65rem; bottom: max(.65rem, env(safe-area-inset-bottom));
  width: 2.75rem; height: 2.75rem; display: grid; place-items: center;
  border: 1px solid #fff; border-radius: 50%; background: #fff5f6; color: #914551;
  box-shadow: 0 4px 14px #40273455;
}
.trainer-chat-bell svg, .chat-header-bell svg { width: 1.55rem; height: 1.55rem; }
.chat-header-bell {
  width: 2.75rem; height: 2.75rem; margin-left: auto; display: grid; place-items: center;
  border: 1px solid #fff; border-radius: 50%; background: #ffeef0; color: #914551;
}
.chat-bell:hover { filter: brightness(.96); }
.chat-notifications {
  box-sizing: border-box; width: min(27rem, calc(100% - 2rem)); max-height: 75dvh; padding: 1.25rem;
  border: 1px solid white; border-radius: 1.3rem; background: linear-gradient(145deg, #fff, #f2f0f7);
  color: #393e4b; box-shadow: 0 16px 55px #28364b38; font: 1rem/1.4 system-ui, sans-serif;
  overscroll-behavior: contain;
}
.chat-notifications[open] { animation: chat-rise .2s ease both; }
.chat-notifications::backdrop { background: #4e526958; backdrop-filter: blur(5px); }
.chat-notifications h2 { margin: 0 2rem .8rem 0; font-size: 1.35rem; }
.chat-close {
  position: absolute; top: .65rem; right: .65rem; width: 2.35rem; height: 2.35rem;
  border: 1px solid #fff; border-radius: 50%; background: #edeaf1; font: 1.5rem system-ui; color: #43495a; cursor: pointer;
}
.chat-notice {
  display: flex; align-items: center; gap: .7rem; margin-top: .45rem; padding: .55rem;
  border: 1px solid #e2d7e2; border-radius: .85rem; color: #393e4b; text-decoration: none; background: #fff8;
}
.chat-notice:hover { background: #fae9ee; }
.chat-notice time, .chat-person-caption { display: block; color: #687081; font-size: .78rem; }
.chat-avatar {
  flex: none; width: 2.35rem; height: 2.35rem; display: grid; place-items: center;
  border: 1px solid #fff; border-radius: 50%; overflow: hidden;
  background: linear-gradient(145deg, #ffeef0, #dacddc); color: #824755; font: 700 .88rem system-ui;
}
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-app {
  display: grid; grid-template-rows: auto minmax(0, 1fr); gap: .9rem;
  height: 100dvh; padding: clamp(.55rem, 2vw, 1.65rem); color: #393e4b;
  background: radial-gradient(circle, #acb5c45c 1px, transparent 1.5px) 0 0 / 19px 19px,
    linear-gradient(150deg, #f5e9ee, #fbfbfe 49%, #e9edf8);
}
.chat-top, .chat-workspace {
  width: min(100%, 87rem); margin-inline: auto; border: 1px solid #fff;
  border-radius: 1.35rem; background: #ffffffc9; box-shadow: 0 9px 32px #5c607d1d;
}
.chat-top { display: flex; gap: clamp(.65rem, 2vw, 1.7rem); align-items: center; padding: .6rem clamp(.75rem, 2vw, 1.6rem); }
.chat-top a { text-decoration: none; color: #34394a; font-weight: 800; white-space: nowrap; }
.chat-top a span { background: #edc5cc; padding: .13em .25em; margin-left: .09em; border-radius: .28em; }
.chat-top h1 { margin: 0; padding-inline-start: 1rem; border-inline-start: 1px solid #e1dce5; font-size: clamp(1.05rem, 2.4vw, 1.55rem); }
.chat-workspace { display: grid; grid-template-columns: minmax(12rem, 22%) minmax(0, 1fr); min-height: 0; overflow: hidden; }
.chat-nav { padding: .95rem; overflow: auto; border-inline-end: 1px solid #dedfea; background: linear-gradient(180deg, #f0eaf5a1, #f5f6faa8); }
.chat-nav > h2 { margin: 1.15rem 0 .35rem; color: #686174; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; }
.chat-nav a {
  display: flex; align-items: center; gap: .55rem; min-height: 2.45rem; padding: .35rem .5rem;
  border-radius: .65rem; color: #444b5e; text-decoration: none; overflow-wrap: anywhere;
}
.chat-nav a:hover { background: #e9e6f1; }
.chat-nav a[aria-current="page"] { background: #f2dfe5; color: #7e394b; font-weight: 700; }
.chat-nav .chat-directory-link { justify-content: center; border: 1px solid #ddcbd9; background: #fff; font-weight: 700; }
.chat-nav .chat-avatar { width: 1.65rem; height: 1.65rem; font-size: .7rem; }
.chat-row-indicator { flex: none; width: .48rem; height: .48rem; margin-inline-start: auto; border-radius: 50%; background: #bd5063; }
.chat-main { display: flex; min-height: 0; min-width: 0; flex-direction: column; }
.chat-conversation-header {
  display: flex; align-items: center; gap: .65rem; padding: .7rem 1.1rem;
  border-bottom: 1px solid #e9e7ef; background: #fcfcffb8;
}
.chat-conversation-header h2 { min-width: 0; margin: 0; font-size: clamp(1rem, 2.7vw, 1.45rem); overflow-wrap: anywhere; }
.chat-connection { margin-left: auto; font-size: .72rem; white-space: nowrap; color: #6b5d70; }
#chat-nav-toggle, #chat-nav-close { display: none; min-height: 2rem; padding: .3rem .55rem; }
.chat-feedback { color: #923e50; margin: .55rem 1.1rem 0; font-size: .87rem; }
.chat-feedback:empty { display: none; }
.chat-conversation { min-height: 0; flex: 1; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.chat-history { min-height: 0; overflow: auto; overflow-anchor: none; overscroll-behavior: contain; padding: clamp(.6rem, 2vw, 1.3rem); }
.chat-history ol { margin: 0; padding: 0; list-style: none; }
.chat-history-more { display: block; margin: 0 auto .55rem; }
.chat-history > p { color: #6c7283; text-align: center; }
.chat-message { display: flex; align-items: flex-start; gap: .65rem; padding: .47rem 0; }
.chat-message .chat-avatar { margin-top: .15rem; }
.chat-message-content { min-width: 0; max-width: min(100%, 49rem); }
.chat-message-meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: .15rem .45rem; }
.chat-message-meta strong { min-width: 0; overflow-wrap: anywhere; }
.chat-message-meta time, .chat-message-meta .chat-person-caption { font-size: .72rem; color: #687081; }
.chat-message-content p {
  margin: .22rem 0 0; padding: .37rem .65rem; width: fit-content; white-space: pre-wrap; overflow-wrap: anywhere;
  border-radius: .2rem .8rem .8rem .8rem; background: #edeef5; line-height: 1.45;
}
.chat-message.is-own .chat-message-content p { background: #f6e5ea; }
.chat-composer {
  display: flex; gap: .6rem; align-items: flex-end; border-top: 1px solid #e9e7ef; padding: .75rem 1rem; background: #fdfdffad;
}
.chat-composer textarea, .chat-directory input {
  min-width: 0; width: 100%; padding: .65rem; border: 1px solid #c9cbd9; border-radius: .78rem; color: #34394a; font: inherit; background: #fff;
}
.chat-composer textarea { min-height: 2.65rem; max-height: 7rem; resize: vertical; }
.chat-directory { overflow: auto; padding: 1rem; }
.chat-directory label { display: block; margin-bottom: .4rem; font-weight: 700; }
#chat-people { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: .6rem; margin-top: .75rem; }
.chat-person {
  display: flex; align-items: center; gap: .55rem; padding: .65rem; border: 1px solid #e2dce8;
  border-radius: .85rem; background: #f9f7fb; color: #383e50; text-align: left; min-width: 0;
}
.chat-person:hover { background: #f5e7ed; }
.chat-person > span:nth-child(2) { min-width: 0; overflow-wrap: anywhere; }
.chat-person .emoji-display { margin-left: auto; }
.chat-person-dialog { width: min(37rem, calc(100% - 1.7rem)); }
.chat-person-dialog .panel-close { z-index: 2; }
.chat-person-identity { position: relative; display: flex; align-items: flex-start; gap: .7rem; padding-bottom: .75rem; }
.chat-person-identity .chat-avatar { width: 4rem; height: 4rem; margin-top: -1.2rem; border: 3px solid #fff; font-size: 1.4rem; }
.chat-person-identity h2 { margin: .55rem 0 .24rem; overflow-wrap: anywhere; }
.chat-person-identity p { color: #62697a; overflow-wrap: anywhere; }
.chat-person-identity .emoji-display { margin-left: auto; margin-top: .6rem; font-size: 1.5rem; }
@keyframes chat-rise { from { opacity: 0; translate: 0 8px; } to { opacity: 1; translate: 0 0; } }

@media (max-width: 650px) {
  .chat-workspace { grid-template-columns: minmax(0, 1fr); }
  .chat-nav { display: none; }
  .chat-workspace.is-navigating { grid-template-rows: minmax(0, 1fr); }
  .chat-workspace.is-navigating .chat-nav { display: block; }
  .chat-workspace.is-navigating .chat-main { display: none; }
  #chat-nav-toggle, #chat-nav-close { display: inline-flex; }
  #chat-nav-close { margin-bottom: .45rem; }
  .chat-composer, .chat-conversation-header { padding-inline: .55rem; }
  .chat-connection { font-size: .66rem; }
}
@media (prefers-reduced-motion: reduce) { .chat-notifications { animation: none !important; } }

/* Chat workspace proportions and materials follow the supplied reference. */
.chat-app {
  --chat-red: #D64C4C;
  --chat-line: #d9d7e1;
  color: #171929;
  gap: clamp(.65rem, 1.7vh, 1rem);
  padding: clamp(.45rem, 1vh, .8rem) 1rem clamp(.7rem, 2.2vh, 1.35rem);
  background-image: radial-gradient(circle, #a8a5bf54 .9px, transparent 1.35px),
    linear-gradient(118deg, #f6f1f6, #eeebf1 53%, #f8f3f7);
  background-size: 18px 18px, auto;
}
.chat-app .chat-top, .chat-app .chat-workspace { width: min(100%, max(71rem, 86vw)); }
.chat-app .chat-top {
  min-height: clamp(3.65rem, 9.1vh, 5.1rem);
  padding-inline: clamp(1rem, 2.25vw, 2.6rem);
  border: 3px solid #ffffffba;
  border-radius: 999px;
  background: radial-gradient(ellipse at 90% 125%, transparent 31%, #a5a0b532 31.4%, transparent 32%, transparent 35%, #a5a0b527 35.5%, transparent 36%),
    linear-gradient(95deg,#fcfcfd,#f5f2f8 70%,#f7ebef);
  box-shadow: 0 6px 24px #51435d30;
}
.chat-top > a:first-child { font-size: clamp(1rem, 1.45vw, 1.65rem); color: #191a2b; letter-spacing: -.025em; }
.chat-top > a:first-child span { background: #D64C4C; color: #fff; border-radius: .45em; }
.chat-top h1 { font-size: clamp(1rem, 1.45vw, 1.65rem); border-color: #cac6d5; padding-inline-start: 1.15em; }
.chat-header-bell { background: #fff; color: #37364b; box-shadow: 0 3px 8px #38304821; }
.chat-unread-dot, .chat-row-indicator { background: #D64C4C; }
#chat-self .chat-avatar { width: 2.7rem; height: 2.7rem; }
.chat-app .chat-workspace {
  grid-template-columns: minmax(11rem, 20.5%) minmax(0, 1fr) minmax(10.75rem, 18%);
  gap: clamp(.4rem, .62vw, .7rem);
  border: 0; border-radius: 0; background: transparent; box-shadow: none;
  overflow: visible;
}
.chat-nav, .chat-main, .chat-online {
  min-height: 0; border: 3px solid #ffffffbf; border-radius: clamp(.9rem, 1.52vw, 1.65rem);
  background-color: #f9f7fb; box-shadow: 0 7px 24px #51435d23; overflow: hidden;
}
.chat-nav, .chat-online {
  overflow: auto;
  background-image: linear-gradient(150deg, #fcf9fdc8, #eeeaf177), url("./architecture.svg");
  background-position: center, left bottom;
  background-size: cover, auto 38%;
  background-repeat: no-repeat;
}
.chat-online { background-position: center, left bottom; }
.chat-nav { padding: clamp(.65rem, 1vw, 1.16rem); padding-block-start: clamp(1rem, 2.8vh, 1.75rem); }
.chat-nav .chat-directory-link, .chat-composer .profile-primary, .chat-person-dialog .profile-primary {
  color: #fff; border: 1px solid #d64c4c; background: linear-gradient(180deg, #D64C4C 10%, #b53036);
  box-shadow: 0 5px 13px #d64c4c30; font-weight: 700;
}
.chat-nav .chat-directory-link { min-height: 2.95rem; border-radius: 1rem; }
.chat-nav a[data-chat-route]:not(.chat-directory-link)::before { content: "#"; font-size: 1.65rem; line-height: .9; color: #777789; }
.chat-nav a[aria-current="page"] { color: #221923; border-inline-start: .32rem solid #D64C4C; background: #d64c4c38; }
.chat-nav > h2 { margin: 1.5rem 0 .55rem; }
.chat-nav > h2:last-of-type { margin-top: 1.9rem; padding-bottom: .55rem; border-bottom: 1px solid var(--chat-line); }
.chat-nav #chat-dms a { min-height: 2.85rem; }
.chat-nav #chat-dms .chat-avatar { width: 2.15rem; height: 2.15rem; }
.chat-main {
  background-image: linear-gradient(144deg, transparent 63%, #e2dfeba6 63.15%, transparent 87%),
    linear-gradient(154deg, transparent 65%, #d64c4c42 65.1%, transparent 65.45%), radial-gradient(circle, #a0a4bb31 .7px, transparent 1.2px);
  background-size: auto, auto, 18px 18px;
}
.chat-conversation-header { min-height: 4.55rem; padding-inline: clamp(.65rem, 1.68vw, 1.8rem); border-color: var(--chat-line); }
.chat-title-block { min-width: 0; }
.chat-title-block h2 { color: #191a2a; }
#chat-description { margin: .14rem 0 0; color: #58596f; font-size: .88rem; }
.chat-conversation { grid-template-rows: minmax(0, 1fr) auto auto; }
.chat-history { padding: clamp(.8rem, 1.6vw, 1.8rem); }
.chat-message { gap: clamp(.65rem, 1.1vw, 1.22rem); padding: clamp(.42rem, 1.18vh, .68rem) 0; margin-bottom: clamp(.38rem, 1vh, .58rem); }
.chat-message .chat-avatar { width: clamp(2.15rem, 3.02vw, 3.35rem); height: clamp(2.15rem, 3.02vw, 3.35rem); }
.chat-portrait, .chat-message-name { border: 0; padding: 0; background: none; color: inherit; }
.chat-portrait { border-radius: 50%; }
.chat-message-name { font: 700 1.03rem Arial, sans-serif; overflow-wrap: anywhere; text-align: left; }
.chat-message-name:hover { text-decoration: underline; }
.chat-message-content p, .chat-message.is-own .chat-message-content p { padding: 0; margin: .15rem 0 0; background: transparent; }
.chat-message-meta time { margin-inline-start: .35rem; }
.chat-composer { align-items: center; padding: .75rem .9rem .4rem; border-color: var(--chat-line); }
.chat-composer textarea { min-height: 2.6rem; height: 2.6rem; border-radius: 1.3rem; padding: .64rem 1.15rem; resize: none; box-shadow: 0 3px 9px #50465e13; }
.chat-composer .profile-primary { width: 3.85rem; border-radius: 999px; }
.chat-composer .profile-primary:hover, .chat-nav .chat-directory-link:hover { filter: brightness(.94); }
.chat-composer button svg { width: 1.3rem; }
.chat-typing { min-height: 1.8rem; margin: 0; padding: .18rem 1rem .5rem; background: #f7f3f8bd; color: #57576c; font-size: .8rem; }
.chat-typing span:first-child { margin-right: .42rem; color: #D64C4C; letter-spacing: .08em; animation: typing-glow 1.1s ease-in-out infinite alternate; }
.chat-typing:has(#chat-typing-text:empty) span:first-child { visibility: hidden; }
@keyframes typing-glow { from { opacity: .35; } to { opacity: 1; } }
.chat-online { padding: clamp(.7rem, 1.1vw, 1.25rem); }
.chat-online h2 { margin: .9rem 0 .55rem; padding-left: .55rem; border-left: 3px solid #D64C4C; font-size: 1rem; }
.chat-online header { border-bottom: 1px solid var(--chat-line); }
.chat-online-user { width: 100%; display: flex; align-items: center; gap: .68rem; border: 0; border-radius: .66rem; padding: .45rem .14rem; background: transparent; color: inherit; text-align: left; }
.chat-online-user:hover { background: #eee8f2; }
.chat-online-user strong, .chat-online-user small { display: block; overflow-wrap: anywhere; }
.chat-online-user small { color: #616377; }
.chat-online-avatar { position: relative; overflow: visible; width: clamp(2rem, 2.55vw, 2.85rem); height: clamp(2rem, 2.55vw, 2.85rem); }
.chat-online-avatar img { border-radius: 50%; }
.chat-online-avatar::after { content: ""; position: absolute; width: .68rem; height: .68rem; right: -.08rem; bottom: -.04rem; border: 2px solid #fff; background: #36a754; border-radius: 50%; }
#chat-online-toggle, #chat-online-close { display: none; }
.chat-person-stats { margin-bottom: .9rem; padding: .75rem; background: #f5edf3; border: 1px solid #e5d8e0; border-radius: .75rem; }
.chat-person-stats h3 { margin: 0 0 .4rem; font-size: .8rem; color: #615c6c; }
.chat-person-stats p { font-size: .82rem; }
@media (max-width: 940px) {
  .chat-app .chat-workspace { grid-template-columns: minmax(10rem, 25%) minmax(0, 1fr); }
  .chat-online { display: none; }
  #chat-online-toggle, #chat-online-close { display: inline-flex; }
  .chat-workspace.is-online { grid-template-columns: minmax(0, 1fr); }
  .chat-workspace.is-online .chat-online { display: block; }
  .chat-workspace.is-online :is(.chat-main, .chat-nav) { display: none; }
  .chat-connection { display: none; }
  #chat-online-toggle { margin-left: auto; }
}
@media (max-width: 650px) {
  .chat-app { padding: .45rem; }
  .chat-app .chat-workspace { grid-template-columns: minmax(0, 1fr); }
  .chat-app .chat-top { gap: .48rem; padding-inline: .75rem; }
  .chat-conversation-header { min-height: 3.8rem; }
  .chat-online { grid-column: 1; }
  #chat-self .chat-avatar { width: 2.05rem; height: 2.05rem; }
  .chat-header-bell { width: 2.15rem; height: 2.15rem; }
}
@media (prefers-reduced-motion: reduce) { .chat-typing span { animation: none !important; } }

.chat-compose-area { position: relative; min-width: 0; }
.chat-message { position: relative; padding-inline-end: 3.65rem; }
.chat-message-controls { position: absolute; right: .15rem; top: 0; display: flex; gap: .2rem; opacity: 0; }
.chat-message:hover .chat-message-controls, .chat-message:focus-within .chat-message-controls { opacity: 1; }
.chat-message-controls button, .chat-reactions button, .chat-reply-preview button {
  border: 1px solid #e1d9e1; border-radius: .5rem; padding: .22rem .36rem; background: #fbf8fa; color: #554658;
}
.chat-message-controls button:hover, .chat-reactions button:hover { border-color: #D64C4C; }
.chat-reaction-picker, .chat-mention-menu {
  position: absolute; z-index: 3; border: 1px solid #dfd6df; background: #fff;
  border-radius: .8rem; box-shadow: 0 6px 22px #473b5530; padding: .35rem;
}
.chat-reaction-picker { right: 0; top: 100%; width: 13.2rem; display: grid; grid-template-columns: repeat(6, 1fr); gap: .15rem; }
.chat-reaction-picker.is-above { top: auto; bottom: 100%; }
.chat-reaction-picker button { padding: .27rem .15rem; }
.chat-reactions { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .36rem; }
.chat-reactions button[aria-pressed="true"] { border-color: #D64C4C; background: #d64c4c24; }
.chat-reference { display: block; max-width: 100%; color: #676071; background: #eee9f1; border: 0; border-left: 2px solid #D64C4C; border-radius: .35rem; padding: .2rem .4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; margin-bottom: .28rem; }
.chat-reference:disabled { cursor: default; opacity: .75; }
.chat-highlight { background: #d64c4c30; border-radius: .65rem; }
.chat-reply-preview { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .35rem .9rem; background: #f1e7ef; font-size: .8rem; }
.chat-reply-preview span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-mention-menu { bottom: calc(100% - .15rem); left: .9rem; width: min(18rem, calc(100% - 1.8rem)); max-height: 13rem; overflow: auto; }
.chat-mention-menu button { display: flex; align-items: center; gap: .55rem; text-align: left; width: 100%; padding: .28rem; border: 0; background: none; color: inherit; border-radius: .45rem; }
.chat-mention-menu button[aria-selected="true"], .chat-mention-menu button:hover { background: #d64c4c24; }
.chat-mention { display: inline; padding: .04rem .2rem; border: 0; border-radius: .27rem; background: #D64C4C26; color: #872c36; }
.chat-mention:disabled { color: #665b68; cursor: default; }
@media (hover: none) { .chat-message-controls { opacity: 1; } }
.chat-link { color: #1459a1; text-decoration: underline; text-underline-offset: .12em; overflow-wrap: anywhere; }
.chat-link:hover { color: #0d3a70; }
.chat-edited { color: #6c6575; font-size: .73rem; }
.chat-image-preview { margin-top: .42rem; font-size: .83rem; color: #68596a; }
.chat-image-preview img { display: block; max-width: min(100%, 22rem); max-height: 14rem; border-radius: .65rem; object-fit: contain; }
.chat-image-preview button { border: 1px solid #d9d4df; background: #f9f7fb; border-radius: .5rem; padding: .25rem .45rem; color: #1459a1; }
.chat-message.is-own:hover .chat-message-controls, .chat-message.is-own:focus-within .chat-message-controls { background: #f8f4fa; border-radius: .5rem; }
@media (hover: none) { .chat-message.is-own { padding-top: 1.45rem; padding-inline-end: .2rem; } }
