/* Larger classmate results while preserving the shared StudentHub language. */
.cm-screen[data-screen="results"] .cm-student-list article { min-height: 68px; padding: 9px 2px; gap: 12px; }
.cm-screen[data-screen="results"] .cm-avatar { width: 48px; height: 48px; font-size: 2.1rem; }
.cm-screen[data-screen="results"] .cm-student-list b { font-size: .84rem; }
.cm-screen[data-screen="results"] .cm-student-list small { font-size: .68rem; }
.cm-screen[data-screen="results"] .cm-result-head { margin-top: 18px; font-size: .78rem; }

/* Opaque chat workspace: keep every message readable on desktop and mobile. */
.cm-chat-screen { overflow: hidden; border: 1px solid #eaf0fa !important; border-radius: 20px; padding: 0 18px 5px !important; background: #fff !important; box-shadow: 0 14px 32px rgba(35,69,132,.06); }
.cm-chat-head, .cm-bubbles, .cm-composer { background: #fff !important; }
.cm-bubbles { padding: 15px 0 !important; }
.cm-bubbles p { border: 1px solid #edf1f7; color: #243a62 !important; background: #f7f9fc !important; box-shadow: 0 5px 12px rgba(33,54,94,.04); font-weight: 600; }
.cm-bubbles p.mine { border: 0; color: #fff !important; background: linear-gradient(135deg,#4385fb,#2868e9) !important; box-shadow: 0 8px 18px rgba(38,99,230,.19); }
.cm-composer { padding: 10px 0 2px !important; }
.cm-composer input { border-color: #dfe8f5 !important; background: #fff !important; }

@media (max-width: 520px) {
  .cm-chat-screen { border-right: 0 !important; border-left: 0 !important; border-radius: 0; box-shadow: none; }
}

/* Premium gender-aware 3D student portraits. */
.cm-avatar { overflow: visible !important; background: #edf5ff !important; color: transparent !important; }
.cm-avatar-art { display:block; width:100%; height:100%; overflow:hidden; border-radius:50%; background:url('./assets/classmate-avatars-3d.png') 0 center/200% 100% no-repeat; }
.cm-avatar--female .cm-avatar-art { background-position:100% center; }

/* A user photo must never change the size or shape of a classmate row. */
.cm-avatar > img {
  position: absolute !important;
  inset: 0 !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  aspect-ratio: 1 / 1;
  border-radius: 50% !important;
  object-fit: cover !important;
  object-position: center !important;
}
.cm-avatar > i { z-index: 1; }

/* Simple, unambiguous navigation in the classmates flow. */
.cm-icon-button {
  width: auto;
  min-width: 44px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #c7dcff !important;
  border-radius: 13px;
  color: #1d68e9 !important;
  background: linear-gradient(145deg, #fff, #edf5ff) !important;
  box-shadow: 0 8px 18px rgba(35, 103, 232, .16);
}

.cm-icon-button:hover { background: #e4f0ff !important; }

/* Keep the classmate header brand consistent with the main Uniar logo. */
.cm-brand { gap: 9px; font-size: 1.08rem; }
.cm-brand span { width: 34px; height: 34px; transform: none; background: #f7fbff; box-shadow: 0 7px 16px rgba(30, 92, 198, .12); }
.cm-brand .site-logo { width: 25px; height: 25px; object-fit: contain; }
.cm-brand b { font-weight: 900; letter-spacing: -.02em; }
.cm-brand b em { color: #2876ef; font-size: 1.17em; font-style: normal; }

.cm-choice-list button {
  grid-template-columns: 30px 1fr;
}

@media (max-width: 899px) {
  .cm-footer {
    display: block;
    padding: 12px 22px 16px;
  }

  .cm-footer .cm-home-button {
    width: 100%;
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(135deg, #4387ff, #2468e9);
    box-shadow: 0 10px 20px rgba(36, 104, 233, .24);
    font-size: .78rem;
    font-weight: 800;
  }

  .cm-footer .cm-home-button span { font-size: .78rem; }
  .cm-footer .cm-home-button svg { width: 18px; height: 18px; }
}

/* Direct classmate chat uses the same polished card language as anonymous chat. */
.cm-screen.cm-chat-screen {
  min-height: 100%;
  margin: 4px 0 8px;
  border: 1px solid #e2ecfb !important;
  border-radius: 26px !important;
  padding: 0 20px 14px !important;
  background: linear-gradient(145deg, #ffffff 0%, #fbfdff 100%) !important;
  box-shadow: 0 20px 42px rgba(43, 91, 172, .11) !important;
}

.cm-chat-screen .cm-chat-head {
  grid-template-columns: 38px 48px 1fr 38px;
  min-height: 76px;
  gap: 10px;
  border-bottom-color: #e6edf8;
}

.cm-chat-screen .cm-chat-head > button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid #cee0fc;
  border-radius: 13px;
  color: #2871ed;
  background: linear-gradient(145deg, #fff, #edf5ff);
  box-shadow: 0 7px 15px rgba(37, 103, 232, .11);
}

.cm-chat-screen .cm-chat-head > button:last-child {
  color: #405779;
  border-color: #e4eaf4;
  background: #fff;
  box-shadow: none;
}

.cm-chat-screen .cm-bubbles {
  min-height: 270px;
  padding: 18px 1px !important;
  gap: 13px;
}

.cm-chat-screen .cm-bubbles p {
  max-width: 74%;
  border-radius: 16px 16px 5px 16px;
  padding: 10px 12px 8px;
}

.cm-chat-screen .cm-bubbles p.mine {
  border-radius: 16px 16px 16px 5px;
}

.cm-chat-screen .cm-composer {
  grid-template-columns: 42px 1fr 42px;
  gap: 8px;
  margin-top: auto;
  border: 1px solid #dce8f9;
  border-radius: 23px;
  padding: 6px 7px !important;
  background: #fff !important;
  box-shadow: 0 8px 20px rgba(47, 96, 180, .07);
}

.cm-chat-screen .cm-composer input {
  height: 38px;
  border: 0 !important;
  background: transparent !important;
}

.cm-chat-screen .cm-composer button {
  width: 40px;
  height: 40px;
}

@media (max-width: 520px) {
  .classmates__content { padding: 8px 12px 16px; }
  /* The floating people glyph crowds the compact mobile illustration. */
  .cm-mobile-hero > i { display: none; }
  /* Keep the first "find classmates" step balanced like the anonymous-chat entry screen. */
  .cm-screen[data-screen="university"] { align-items: center; text-align: center; padding-top: 6px; }
  .cm-screen[data-screen="university"] .cm-mobile-hero { margin: 4px auto 10px; }
  .cm-screen[data-screen="university"] .cm-mobile-cap::after { opacity: .24; }
  .cm-screen[data-screen="university"] h1 { width: 100%; margin: 0 0 4px; text-align: center; }
  .cm-screen[data-screen="university"] h1,
  .cm-screen[data-screen="university"] .cm-lead { position: relative; z-index: 1; }
  .cm-screen[data-screen="university"] .cm-lead { max-width: 345px; margin-inline: auto; text-align: center; }
  .cm-screen[data-screen="university"] h2 { width: 100%; margin-top: 18px; text-align: center; }
  .cm-screen[data-screen="university"] .cm-search,
  .cm-screen[data-screen="university"] .cm-choice-list,
  .cm-screen[data-screen="university"] .cm-primary { width: 100%; box-sizing: border-box; }
  .cm-screen[data-screen="university"] .cm-choice-list { text-align: right; }
  .cm-screen.cm-chat-screen {
    margin: 0 0 8px;
    min-height: calc(100vh - 158px);
    border-right: 1px solid #e2ecfb !important;
    border-left: 1px solid #e2ecfb !important;
    border-radius: 24px !important;
    padding: 0 14px 11px !important;
    box-shadow: 0 14px 30px rgba(43, 91, 172, .09) !important;
  }
  .cm-chat-screen .cm-chat-head { min-height: 68px; }
  .cm-chat-screen .cm-bubbles { min-height: 235px; }
}

/* Direct chat follows the mobile visual viewport when the keyboard is open. */
@media (max-width:520px) {
  html:has(.classmates.is-open), body:has(.classmates.is-open) { height:100%; overflow:hidden; overscroll-behavior:none; }
  .classmates.is-open { position:fixed !important; inset:0 !important; height:var(--cm-visual-height,100dvh) !important; min-height:0 !important; }
  .classmates.is-open .classmates__shell { height:100% !important; min-height:0 !important; max-height:none !important; grid-template-rows:auto minmax(0,1fr) auto !important; }
  .classmates.is-open .classmates__content { min-height:0 !important; overflow:hidden !important; padding:8px 12px !important; }
  .classmates.is-open.is-chatting .classmates__content { display:flex !important; flex-direction:column !important; }
  .classmates.is-open.is-chatting .cm-screen.cm-chat-screen.is-active { display:flex !important; flex:1 1 auto !important; flex-direction:column !important; height:auto !important; min-height:0 !important; margin:0 !important; padding:0 14px 8px !important; }
  .classmates.is-open.is-chatting .cm-chat-screen .cm-bubbles { flex:1 1 0 !important; min-height:0 !important; height:auto !important; overflow-y:auto !important; -webkit-overflow-scrolling:touch; margin:0 !important; padding:12px 1px !important; }
  .classmates.is-open.is-chatting .cm-chat-screen .cm-composer { flex:0 0 auto !important; margin:0 !important; padding:6px 7px max(8px,env(safe-area-inset-bottom)) !important; }
}

/* Apply the same visual-viewport contract on phones and small tablets. */
@media (max-width:767px) {
  .classmates.is-open { position:fixed !important; top:var(--cm-visual-top,0px) !important; right:0 !important; bottom:auto !important; left:0 !important; width:100% !important; height:var(--cm-visual-height,100dvh) !important; min-height:0 !important; overflow:hidden !important; }
  .classmates.is-open.is-chatting .classmates__shell,
  .classmates.is-open.is-chatting .classmates__content,
  .classmates.is-open.is-chatting .cm-screen.cm-chat-screen.is-active { min-height:0 !important; }
  .classmates.is-open.is-chatting .classmates__content,
  .classmates.is-open.is-chatting .cm-screen.cm-chat-screen.is-active { overflow:hidden !important; }
  .classmates.is-open.is-chatting .cm-chat-screen .cm-bubbles { flex:1 1 0 !important; min-height:0 !important; overflow-y:auto !important; }
  .classmates.is-open.is-chatting .cm-chat-screen .cm-composer { flex:0 0 auto !important; position:relative !important; z-index:3 !important; }
  .classmates.is-open.keyboard-open .classmates__header { min-height:54px !important; padding-top:6px !important; padding-bottom:6px !important; }
  .classmates.is-open.keyboard-open .cm-chat-screen .cm-chat-head { min-height:54px !important; }
}
