.chat-shell[hidden], .chat-scrim[hidden] { display: none !important; }
.portal-chat-trigger { position: relative; width: 2.75rem; height: 2.75rem; border: 1px solid var(--border); border-radius: 999px; background: var(--ink); color: var(--forest); cursor: pointer; }
.portal-chat-trigger__badge { position: absolute; inset: -.15rem -.15rem auto auto; min-width: 1.15rem; padding: .05rem .3rem; border: 2px solid var(--ink); border-radius: 999px; background: var(--terra); color: white; font-size: .7rem; }
.chat-scrim { position: fixed; inset: 0; z-index: 190; background: rgb(20 42 32 / .35); }
.chat-shell { position: fixed; z-index: 191; inset: 0 0 0 auto; width: min(930px, 92vw); height: 100vh; height: 100dvh; display: grid; grid-template-columns: 310px minmax(0, 1fr); background: var(--surface, #fbf8f2); box-shadow: -1rem 0 4rem rgb(20 42 32 / .18); }
.chat-rooms { min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--border); background: #f4ebdd; }
.chat-panel-heading { min-height: 5rem; display: flex; align-items: center; gap: var(--space-3); justify-content: space-between; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.chat-panel-heading h2, .chat-panel-heading p { margin: 0; }
.chat-panel-heading p { color: var(--muted); font-size: .8rem; }
.chat-thread-heading__copy { min-width: 0; }
.chat-online { display: flex; align-items: center; gap: .45rem; margin-left: auto; color: #527048; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.chat-online i { width: .5rem; height: .5rem; border-radius: 50%; background: #4e9b5d; box-shadow: 0 0 0 3px rgba(78,155,93,.13); }
.chat-icon-button { flex: none; width: 2.5rem; height: 2.5rem; border: 0; border-radius: 999px; background: rgb(36 81 63 / .08); color: var(--forest); font-size: 1.35rem; cursor: pointer; }
.chat-room-list { display: grid; align-content: start; gap: .35rem; overflow-y: auto; padding: var(--space-3); }
.chat-room { display: grid; grid-template-columns: 2.65rem minmax(0, 1fr) auto; gap: .7rem; align-items: center; width: 100%; padding: .75rem; border: 0; border-radius: var(--radius-md); background: transparent; color: inherit; text-align: left; cursor: pointer; }
.chat-room:hover, .chat-room[aria-current="true"] { background: var(--ink); }
.chat-room__icon { display: grid; place-items: center; width: 2.65rem; height: 2.65rem; border-radius: .75rem; background: #d9e0d3; color: var(--forest); font-weight: 700; }
.chat-room strong, .chat-room small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-room small { color: var(--muted); }
.chat-unread { min-width: 1.35rem; padding: .1rem .4rem; border-radius: 999px; background: var(--terra); color: white; text-align: center; font-size: .75rem; }
.chat-membership-note { margin: auto var(--space-4) var(--space-4); color: var(--muted); font-size: .8rem; }
.chat-thread { min-width: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.chat-back { display: none; }
.chat-messages { overflow-y: auto; padding: var(--space-4); }
.chat-expectation { display: flex; gap: .7rem; padding: var(--space-3); border: 1px solid rgb(166 83 62 / .18); border-radius: var(--radius-md); background: #fff7ea; font-size: .85rem; }
.chat-expectation svg { flex: none; width: 1.15rem; color: var(--chat-terra); }
.chat-day { margin: .25rem 0 1rem; color: #938578; font-size: .68rem; font-weight: 900; letter-spacing: .08em; text-align: center; text-transform: uppercase; }
.chat-message { display: grid; gap: .25rem; max-width: 78%; margin-block: var(--space-4); }
.chat-message--mine { margin-left: auto; }
.chat-message__bubble { padding: .75rem 1rem; border-radius: .35rem 1rem 1rem; background: white; box-shadow: 0 .2rem .8rem rgb(72 59 42 / .07); white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-message--mine .chat-message__bubble { border-radius: 1rem .35rem 1rem 1rem; background: var(--forest); color: white; }
.chat-message__meta { color: var(--muted); font-size: .72rem; }
.chat-message--mine .chat-message__meta { text-align: right; }
.chat-composer { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); background: white; }
.chat-composer > div { display: flex; align-items: end; gap: .5rem; padding: .45rem; border: 1px solid var(--border); border-radius: var(--radius-md); }
.chat-composer textarea { flex: 1; min-height: 2.6rem; max-height: 8rem; border: 0; background: transparent; resize: vertical; }
.chat-send { width: 2.6rem; height: 2.6rem; border: 0; border-radius: .7rem; background: var(--forest); color: white; cursor: pointer; }
.chat-composer small { display: block; margin-top: .35rem; color: var(--muted); }
.chat-send:disabled, .chat-composer textarea:disabled { cursor: wait; opacity: .55; }
.chat-state { display: grid; justify-items: center; gap: .75rem; margin: 1.5rem auto; max-width: 22rem; color: var(--muted); text-align: center; }
.chat-state p { margin: 0; }
.chat-state button { padding: .55rem .9rem; border: 1px solid rgba(36,81,63,.2); border-radius: 999px; background: white; color: var(--forest); font-weight: 800; cursor: pointer; }
.chat-typing { display: flex; align-items: center; gap: .3rem; margin: 0 0 .9rem 2.8rem; color: #7d7064; font-size: .7rem; }
.chat-typing i { width: .32rem; height: .32rem; border-radius: 50%; background: var(--sage); animation: chat-pulse 1.2s infinite; }
.chat-typing i:nth-child(2) { animation-delay: .15s; }
.chat-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-pulse { 50% { transform: translateY(-3px); background: var(--forest); } }
body.chat-open { overflow: hidden; }
@media (max-width: 760px) {
  .chat-shell { width: 100%; grid-template-columns: 1fr; }
  .chat-shell:not(.chat-shell--thread) .chat-thread { display: none; }
  .chat-shell.chat-shell--thread .chat-rooms { display: none; }
  .chat-back { display: inline-grid; place-items: center; }
  .chat-message { max-width: 88%; }
  .chat-panel-heading { min-height: 4.75rem; padding: .85rem 1rem; }
  .chat-thread-icon, .chat-online { display: none; }
  .chat-messages { padding: 1.25rem; overscroll-behavior: contain; }
  .chat-composer { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { .chat-shell, .chat-scrim { scroll-behavior: auto; } }

/* Approved student-portal chat visual system. */
.student-page { background: var(--sand); }
.student-page .portal-header { min-height: 4.75rem; border-color: var(--chat-line); background: rgba(251,248,242,.92); font-family: var(--font-chat-body); }
.student-page .site-main { padding-top: 4.75rem; }
.student-page .portal-brand { color: var(--forest); font-weight: 900; letter-spacing: .13em; }
.student-page .portal-brand img { width: 2.75rem; height: 2.75rem; object-fit: contain; }
.student-page .portal-brand strong { color: var(--forest); }
.student-page .portal-links { margin-left: 2.5rem; margin-right: auto; gap: 1rem; }
.student-page .portal-link { color: var(--chat-copy); }
.student-page .portal-link[aria-current="page"] { color: var(--forest); background: transparent; font-weight: 900; }
.portal-actions { display: flex; align-items: center; gap: .75rem; }
.student-page .mobile-menu-button { position: static; display: grid; place-items: center; min-width: 2.75rem; min-height: 2.75rem; padding: 0; border: 1px solid var(--chat-line); border-radius: 50%; background: white; color: var(--forest); font-size: 1.2rem; cursor: pointer; }
.portal-chat-trigger { background: white; color: var(--forest); }
.portal-chat-trigger svg { width: 1.25rem; margin: auto; }
.portal-avatar { width: 2.5rem; height: 2.5rem; display: grid; place-items: center; border: 1px solid var(--chat-line); border-radius: 50%; color: var(--forest); background: var(--gold); font: 900 .9rem var(--font-chat-body); }
.portal-chat-trigger__badge { width: .7rem; min-width: 0; height: .7rem; padding: 0; border-color: white; background: var(--chat-terra); font-size: 0; }
.chat-scrim { opacity: 0; background: rgba(25,40,32,.28); transition: opacity .25s; }
.chat-shell { color: var(--chat-copy); background: var(--cream); box-shadow: var(--chat-shadow); font-family: var(--font-chat-body); transform: translateX(102%); transition: transform .28s ease; }
body.chat-open .chat-scrim { opacity: 1; }
body.chat-open .chat-shell { transform: none; }
.chat-rooms { border-color: var(--chat-line); background: #f2eadf; }
.chat-panel-heading { min-height: 5.375rem; padding: 1.3rem 1.4rem; border-color: var(--chat-line); }
.chat-panel-heading h2 { color: var(--forest); font: 600 1.875rem var(--font-chat-display); }
.chat-thread .chat-panel-heading h2 { font: 700 1.1rem var(--font-chat-body); }
.chat-thread-icon { flex: none; }
.chat-icon-button { background: rgba(36,81,63,.08); color: var(--forest); }
.chat-room-list::before { content: "Your programs"; padding: .5rem .7rem .25rem; color: #827366; font-size: .68rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.chat-room { border-radius: .8rem; color: var(--chat-copy); }
.chat-room:hover, .chat-room[aria-current="true"] { background: white; box-shadow: 0 5px 18px rgba(66,54,38,.07); }
.chat-room__icon { background: #d9e0d3; color: var(--forest); }
.chat-membership-note { padding: .85rem; border-radius: .75rem; background: rgba(255,255,255,.65); }
.chat-thread { background: var(--cream); }
.chat-messages { padding: 1.75rem 1.875rem; }
.chat-expectation { margin: 0 auto 2rem; border-color: rgba(166,83,62,.16); background: #fff7ea; color: #795d48; }
.chat-message { grid-template-columns: 2.15rem minmax(0,1fr); column-gap: .65rem; }
.chat-message--mine { grid-template-columns: minmax(0,1fr); }
.chat-message__avatar { grid-column: 1; grid-row: 1 / span 2; width: 2.15rem; height: 2.15rem; display:grid; place-items:center; border-radius:50%; color:white; background:var(--chat-terra); font-size:.68rem; font-weight:900; }
.chat-message__bubble, .chat-message__meta { grid-column: 2; }
.chat-message--mine .chat-message__bubble, .chat-message--mine .chat-message__meta { grid-column: 1; }
.chat-message__bubble { background: white; }
.chat-message--mine .chat-message__bubble { background: var(--forest); }
.chat-composer { padding: 1rem 1.25rem 1.25rem; border-color: var(--chat-line); }
.chat-composer > div { border-color: rgba(36,81,63,.22); border-radius: .95rem; background: var(--cream); }
.chat-composer textarea { color: var(--chat-copy); outline: 0; }
.chat-send { background: var(--forest); }
@media (max-width: 720px) {
  .student-page .portal-header { min-height: 4rem; }
  .student-page .site-main { padding-top: 4rem; }
  .student-page .portal-brand img { width: 2.5rem; height: 2.5rem; }
  .student-page .portal-brand strong { display:none; }
  .student-page .portal-links--student { display:none; }
  .portal-actions { margin-left:auto; margin-right:0; gap:.5rem; }
  .portal-avatar { display:grid; }
  .student-page .mobile-menu-button { position:static; }
}
@media (prefers-reduced-motion: reduce) { .chat-shell, .chat-scrim { transition:none; } .chat-typing i { animation:none; } }
