﻿:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --surface-3: #f2f5f8;
  --ink: #111827;
  --text-2: #243244;
  --muted: #667085;
  --muted-2: #98a2b3;
  --line: #e2e8f0;
  --line-soft: #edf2f7;
  --nav: #07111e;
  --nav-active: #111f34;
  --primary: #2563eb;
  --primary-2: #0f5fd7;
  --primary-soft: #eaf1ff;
  --green: #168a4a;
  --green-soft: #eaf7ef;
  --amber: #a76213;
  --amber-soft: #fff4df;
  --red: #b42318;
  --red-soft: #fff0ef;
  --cyan: #087f99;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-card: 0 8px 24px rgba(15, 23, 42, .05);
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 12px;
  --rail-width: 184px;
  --pane-width: 292px;
}

/* Student registration profile: always show the complete server snapshot. */
.student-profile-sync {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid #bfd5ff;
  border-radius: 10px;
  background: #eef5ff;
}

.student-profile-sync > div {
  display: grid;
  gap: 3px;
}

.student-profile-sync span,
.student-score-summary-head span {
  color: var(--muted);
  font-size: 12px;
}

.student-score-summary > .student-score-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 0;
}

.student-score-summary > .student-score-detail-table {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid #d7e3f8;
  border-radius: 10px;
  background: #fff;
}

.student-score-detail-row {
  display: grid;
  grid-template-columns: minmax(90px, 1.2fr) repeat(3, minmax(92px, 1fr));
  gap: 12px;
  align-items: center;
  min-height: 42px;
  padding: 9px 12px;
  border-top: 1px solid #e7edf7;
}

.student-score-detail-row:first-child {
  border-top: 0;
}

.student-score-detail-row > strong,
.student-score-detail-row > span {
  display: block;
  min-width: 0;
}

.student-score-detail-row > strong {
  color: var(--ink);
}

.student-score-detail-header {
  min-height: 38px;
  color: var(--muted);
  font-size: 12px;
  background: #f4f7fc;
}

.student-score-detail-header > strong {
  color: var(--muted);
}

@media (max-width: 700px) {
  .student-profile-sync {
    align-items: stretch;
    flex-direction: column;
  }

  .student-profile-sync .line-btn {
    width: 100%;
  }

  .student-score-summary > .student-score-summary-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .student-score-detail-row {
    grid-template-columns: minmax(72px, 1.1fr) repeat(3, minmax(58px, 1fr));
    gap: 7px;
    padding: 8px;
    font-size: 12px;
  }
}

/* Production meeting workspace */
.chat-meeting-overlay {
  padding: 18px;
  background: rgba(4, 10, 19, .82);
}

.chat-meeting-dialog {
  width: min(1420px, 100%);
  height: min(900px, calc(100dvh - 36px));
  max-height: none;
  grid-template-rows: auto minmax(0, 1fr);
  border-color: #2b3b55;
  background: #081321;
}

.chat-meeting-head {
  min-height: 82px;
  padding: 14px 20px;
}

.meeting-title-block,
.meeting-window-actions,
.meeting-floating-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.meeting-camera-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid #4266a8;
  border-radius: 8px;
  color: #cfe0ff;
  background: #173264;
}

.meeting-live-dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  margin-right: 6px;
  border-radius: 50%;
  background: #27c58a;
}

.meeting-floating-actions {
  display: none;
}

.chat-meeting-stage {
  height: auto;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto auto;
  gap: 12px;
  padding: 14px;
  overflow: hidden;
  background: #081321;
}

.meeting-workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 12px;
}

.meeting-video-area,
.meeting-side-panel {
  min-height: 0;
  overflow: hidden;
  border: 1px solid #263950;
  border-radius: 8px;
  background: #0b1727;
}

.meeting-video-area {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.meeting-stage-head {
  padding: 12px 14px;
  border-bottom: 1px solid #22334a;
}

.meeting-stage-head strong {
  font-size: 15px;
}

.meeting-stage-head p {
  margin: 3px 0 0;
  color: #8ea0b9;
  font-size: 12px;
}

.chat-meeting-overlay .classroom-video-grid {
  min-height: 0;
  max-height: none !important;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  grid-auto-rows: minmax(190px, 1fr);
  align-content: center;
  gap: 10px;
  margin: 0;
  padding: 12px;
  overflow: auto;
}

.chat-meeting-overlay .remote-video-grid {
  display: contents;
}

.chat-meeting-overlay .video-tile {
  position: relative;
  min-width: 0;
  min-height: 190px;
  overflow: hidden;
  border: 1px solid #29415f;
  border-radius: 8px;
  background: #101c2b;
}

.chat-meeting-overlay .video-tile > div[id],
.chat-meeting-overlay .video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-meeting-overlay .video-tile.camera-off > div[id] {
  visibility: hidden;
}

.meeting-avatar {
  display: none;
}

.video-tile.camera-off .meeting-avatar {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  translate: -50% -55%;
  border: 1px solid #3f7ad3;
  border-radius: 50%;
  color: #fff;
  background: #2458a7;
  font-size: 28px;
  font-weight: 700;
}

.meeting-member-meta {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 8px;
  padding: 30px 12px 10px;
  color: #fff;
  background: linear-gradient(transparent, rgba(1, 6, 13, .86));
}

.meeting-member-meta strong {
  font-size: 14px;
}

.meeting-member-meta span {
  color: #c4d0df;
  font-size: 11px;
}

.video-empty {
  min-height: 190px;
  display: grid;
  place-content: center;
  gap: 6px;
  color: #a9b8cb;
  text-align: center;
}

.video-empty strong {
  color: #e8eef7;
  font-size: 18px;
}

.meeting-side-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.meeting-side-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 8px;
  border-bottom: 1px solid #263950;
}

.meeting-side-tabs button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  color: #91a3bb;
  background: transparent;
  cursor: pointer;
}

.meeting-side-tabs button.active {
  color: #fff;
  background: #1c3c76;
}

.meeting-side-view {
  min-height: 0;
  display: none;
}

.meeting-side-view.active {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
}

.meeting-chat-messages {
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
}

.meeting-chat-messages article {
  margin-bottom: 13px;
}

.meeting-chat-messages article > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #8ea0b9;
  font-size: 11px;
}

.meeting-chat-messages article strong {
  color: #eaf0f8;
  font-size: 12px;
}

.meeting-chat-messages article p {
  width: fit-content;
  max-width: 92%;
  margin: 5px 0 0;
  padding: 8px 10px;
  border-radius: 6px;
  color: #dde7f4;
  background: #17263a;
  line-height: 1.55;
}

.meeting-chat-messages article.mine p {
  margin-left: auto;
  background: #2357a5;
}

.meeting-chat-empty,
.meeting-ai-empty,
.meeting-ai-intro {
  align-self: center;
  padding: 22px;
  color: #8ea0b9;
  text-align: center;
}

.meeting-chat-empty strong,
.meeting-ai-intro strong {
  color: #eef4fc;
}

.meeting-chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #263950;
}

.meeting-chat-composer input {
  min-width: 0;
  border-color: #334962;
  color: #fff;
  background: #101d2f;
}

.meeting-chat-privacy {
  margin: 0;
  padding: 0 10px 9px;
  color: #71839b;
  font-size: 10px;
}

.meeting-analysis {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 14px;
}

.meeting-ai-empty {
  display: grid;
  place-items: center;
}

.meeting-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border-color: #2a3e58;
  background: #0d1a2b;
}

.meeting-controls button {
  min-width: 94px;
}

.meeting-controls .danger-btn {
  margin-left: 10px;
  background: #dc3f50;
}

.meeting-background-select {
  min-height: 40px;
  border: 1px solid #40516b;
  border-radius: 6px;
  color: #e9f0f9;
  background: #172338;
}

.meeting-permission-toggle {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.meeting-permission-toggle input {
  width: 20px;
  height: 20px;
}

.meeting-permission-toggle small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.chat-meeting-overlay.meeting-floating {
  pointer-events: none;
  background: transparent;
}

.meeting-floating .chat-meeting-dialog {
  position: fixed;
  right: 20px;
  bottom: 20px;
  left: auto;
  top: auto;
  width: min(540px, calc(100vw - 32px));
  height: 350px;
  pointer-events: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .42);
}

.meeting-floating .chat-meeting-head {
  min-height: 54px;
  padding: 8px 10px;
  cursor: move;
}

.meeting-floating .meeting-camera-mark,
.meeting-floating .chat-meeting-head .eyebrow,
.meeting-floating .chat-meeting-head p,
.meeting-floating .meeting-window-actions,
.meeting-floating .meeting-side-panel,
.meeting-floating .meeting-stage-head,
.meeting-floating .classroom-status,
.meeting-floating .meeting-lesson-picker,
.meeting-floating .meeting-controls {
  display: none;
}

.meeting-floating .meeting-floating-actions {
  display: flex;
}

.meeting-floating .meeting-floating-actions button {
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid #3b4e68;
  border-radius: 5px;
  color: #eaf1fa;
  background: #17263a;
  font-size: 12px;
  cursor: pointer;
}

.meeting-floating .chat-meeting-stage,
.meeting-floating .meeting-workspace,
.meeting-floating .meeting-video-area {
  display: block;
  height: 100%;
  border: 0;
}

.meeting-floating .classroom-video-grid {
  height: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  padding: 8px;
}

.meeting-floating .video-tile,
.meeting-floating .video-empty {
  min-height: 0;
}

.meeting-members-collapsed .remote-video-grid {
  display: none;
}

.meeting-members-collapsed .classroom-video-grid {
  grid-template-columns: 1fr;
}

.meeting-floating-compact .chat-meeting-dialog {
  width: min(320px, calc(100vw - 24px));
  height: 58px;
}

.meeting-floating-compact .chat-meeting-stage,
.meeting-floating-compact [data-chat-meeting-action="collapse-members"],
.meeting-floating-compact [data-chat-meeting-action="collapse-all"] {
  display: none;
}

@media (max-width: 900px) {
  .meeting-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .meeting-side-panel {
    min-height: 220px;
  }

  .chat-meeting-dialog {
    height: 100dvh;
  }

  .chat-meeting-overlay .classroom-video-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Communication IM */
.mobile-menu-overlay {
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.mobile-menu-overlay.open {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}

body[data-page="messages"] .app-view {
  grid-template-columns: 72px minmax(0, 1fr);
}

body[data-page="messages"] .contact-pane {
  display: none;
}

body[data-page="messages"] .main {
  min-width: 0;
}

.communication-shell {
  height: calc(100dvh - 124px);
  min-height: 560px;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.im-conversation-pane {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--surface-2);
}

.im-conversation-tools {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.im-search {
  min-height: 38px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.im-search span {
  width: 13px;
  height: 13px;
  border: 1.8px solid var(--muted);
  border-radius: 50%;
  position: relative;
}

.im-search span::after {
  content: "";
  width: 6px;
  height: 1.8px;
  position: absolute;
  right: -5px;
  bottom: -2px;
  transform: rotate(45deg);
  background: var(--muted);
}

.im-search input {
  min-width: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
  font-size: 13px;
}

.im-filters {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: #edf1f6;
}

.im-filters button {
  min-height: 30px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.im-filters button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(15, 23, 42, .08);
}

.im-conversation-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.im-conversation {
  width: 100%;
  min-height: 68px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--text);
  text-align: left;
}

.im-conversation:hover,
.im-conversation.active {
  background: #edf4ff;
}

.im-conversation.active {
  box-shadow: inset 3px 0 0 var(--primary);
}

.im-conversation > b {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: #e8effd;
  color: var(--primary);
  font-size: 13px;
}

.im-conversation > span {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.im-conversation strong,
.im-conversation small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.im-conversation strong {
  font-size: 13px;
}

.im-conversation small,
.im-conversation time {
  color: var(--muted);
  font-size: 12px;
}

.im-conversation time {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
}

.im-unread-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e5484d;
  color: #fff;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

.im-conversation.has-unread small {
  color: #243b64;
  font-weight: 600;
}

.meeting-lesson-picker {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr);
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  color: #d8e4f8;
  font-size: 13px;
}

.meeting-lesson-picker select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #39506f;
  border-radius: 9px;
  background: #132238;
  color: #fff;
  padding: 0 10px;
}

.im-chat-host {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  overflow: hidden;
}

.im-chat-window {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--surface);
}

.im-chat-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.im-conversation-toggle,
.im-conversation-backdrop {
  display: none;
}

.im-chat-header h2 {
  margin: 0;
  font-size: 16px;
}

.im-chat-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.im-message-list {
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px;
  background: #f7f8fa;
  overscroll-behavior: contain;
  overflow-anchor: none;
}

.im-load-older,
.im-load-more {
  min-height: 34px;
  margin: 0 auto 12px;
  display: block;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.im-message .message-body {
  max-width: 100%;
}

.im-message .message-body > p {
  white-space: normal;
  overflow-wrap: anywhere;
}

.im-system-notice,
.im-message-system {
  width: fit-content;
  max-width: 82%;
  margin: 12px auto;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.im-file-card,
.im-business-card {
  width: min(340px, 100%);
  min-height: 66px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 8px 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  text-decoration: none;
}

.im-file-card > span,
.im-business-card > span {
  grid-row: 1 / span 2;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
}

.im-file-card small,
.im-business-card small {
  color: var(--muted);
  font-size: 12px;
}

.im-image-card {
  max-width: min(360px, 70vw);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.im-image-card img {
  width: 100%;
  max-height: 360px;
  display: block;
  object-fit: contain;
}

.im-voice-card {
  min-width: 210px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.im-voice-play {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  position: relative;
}

.im-voice-play::after {
  content: "";
  position: absolute;
  top: 10px;
  left: 13px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid #fff;
}

.im-voice-play.playing::after {
  width: 8px;
  height: 12px;
  top: 10px;
  left: 12px;
  border: 0;
  border-right: 3px solid #fff;
  border-left: 3px solid #fff;
}

.im-voice-transcribe {
  padding: 5px 7px;
  border-radius: 6px;
  background: #edf2f7;
  color: var(--muted);
  font-size: 12px;
}

.message-composer {
  position: relative;
  z-index: 5;
  min-height: 70px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 40px 72px;
  align-items: end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.message-composer.is-direct {
  grid-template-columns: minmax(0, 1fr) 72px;
}

.message-composer textarea {
  min-height: 40px;
  max-height: 112px;
  padding: 9px 11px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
  line-height: 1.55;
}

.composer-attach,
.composer-mic {
  width: 38px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #f3f6f9;
  color: var(--text-2);
  cursor: pointer;
}

.composer-mic {
  width: 40px;
}

.composer-mic.recording {
  border-color: #f2b8b5;
  background: var(--red-soft);
  color: var(--red);
}

.message-composer .primary-btn {
  min-height: 40px;
}

.composer-status {
  grid-column: 2 / -1;
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
}

.message-composer.is-direct .composer-status {
  grid-column: 1 / -1;
}

.message-mention-menu {
  position: absolute;
  left: 60px;
  bottom: calc(100% - 10px);
  z-index: 20;
  width: min(320px, calc(100% - 150px));
  max-height: 260px;
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 14px 34px rgba(15, 23, 42, .16);
}

.message-mention-menu[hidden] {
  display: none;
  pointer-events: none;
}

.message-mention-menu button {
  width: 100%;
  min-height: 46px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.message-mention-menu button:hover,
.message-mention-menu button.active {
  background: var(--primary-soft);
}

.message-mention-menu button > b {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #edf3ff;
  color: var(--primary);
  font-size: 13px;
}

.message-mention-menu button span,
.message-mention-menu button strong,
.message-mention-menu button small {
  min-width: 0;
  display: block;
}

.message-mention-menu button small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.im-business-context {
  min-width: 0;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--surface-2);
}

.im-business-context > header {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.im-business-context > header div {
  display: grid;
  gap: 3px;
}

.im-business-context > header span {
  color: var(--muted);
  font-size: 12px;
}

.im-business-context > header button {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: #edf2f7;
}

.im-business-context > nav {
  display: flex;
  gap: 4px;
  padding: 10px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.im-business-context > nav button {
  min-width: max-content;
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.im-business-context > nav button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(15, 23, 42, .08);
}

.im-context-members {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(37, 99, 235, .04), rgba(255, 255, 255, 0));
}

.im-context-members-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 13px;
}

.im-context-members-head span {
  color: var(--muted);
  font-size: 12px;
}

.im-context-member-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 2px;
}

.im-context-member-list article {
  min-width: 0;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.im-context-member-list b {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
}

.im-context-member-list span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.im-context-member-list strong,
.im-context-member-list small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.im-context-member-list small {
  color: var(--muted);
  font-size: 12px;
}

.im-context-member-list .ai-member b {
  background: #07111e;
  color: #fff;
}

.full-width {
  width: 100%;
}

.archived-group-list {
  margin-bottom: 14px;
}

.archived-group-card .row {
  align-items: flex-start;
}

.archived-group-preview {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding: 10px;
  border-radius: 12px;
  background: #f8fafc;
}

.archived-group-preview p {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.archived-group-preview span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resource-edit-card {
  display: grid;
  gap: 10px;
}

.resource-edit-form.compact-form {
  gap: 10px;
}

.resource-file-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}

.resource-file-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.invite-card.disabled {
  opacity: .72;
  background: #f8fafc;
}

.invite-card.disabled .invite-qr {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed var(--line);
  background: #fff;
}

#businessContextContent {
  padding: 14px;
}

.im-summary-list {
  margin: 0;
  display: grid;
  gap: 8px;
}

.im-summary-list > div,
.im-context-stack article {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.im-summary-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.im-summary-list dt {
  color: var(--muted);
  font-size: 12px;
}

.im-summary-list dd {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

.im-context-stack {
  display: grid;
  gap: 8px;
}

.im-context-stack p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.im-more-actions {
  position: relative;
}

.im-more-actions > summary {
  list-style: none;
}

.im-more-actions > summary::-webkit-details-marker {
  display: none;
}

.im-more-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 7px);
  right: 0;
  width: 170px;
  display: grid;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 16px 38px rgba(15, 23, 42, .14);
}

.im-more-menu button {
  min-height: 36px;
  padding: 7px 9px;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.im-more-menu button:hover {
  background: var(--surface-2);
}

.im-chat-loading,
.im-chat-empty,
.im-load-error,
.im-list-empty,
.im-context-loading,
.im-context-empty {
  min-height: 120px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1240px) {
  .im-chat-host {
    grid-template-columns: minmax(0, 1fr);
    position: relative;
  }

  .im-business-context {
    width: min(340px, calc(100vw - 24px));
    position: absolute;
    z-index: 30;
    top: 0;
    right: 0;
    bottom: 0;
    transform: translateX(102%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform .18s ease, opacity .18s ease, visibility .18s ease;
    box-shadow: -14px 0 34px rgba(15, 23, 42, .12);
  }

  .communication-shell.context-open .im-business-context {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .im-business-context > header button {
    display: grid;
    place-items: center;
  }
}

@media (max-width: 760px) {
  body[data-page="messages"] .app-view {
    grid-template-columns: minmax(0, 1fr);
  }

  .communication-shell {
    height: calc(100dvh - 132px);
    min-height: 520px;
    grid-template-columns: minmax(0, 1fr);
    position: relative;
    border-radius: 0;
  }

  .im-conversation-pane {
    width: min(300px, 86vw);
    position: absolute;
    z-index: 36;
    inset: 0 auto 0 0;
    transform: translateX(-102%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform .18s ease, opacity .18s ease, visibility .18s ease;
    box-shadow: 14px 0 34px rgba(15, 23, 42, .16);
  }

  .communication-shell.conversations-open .im-conversation-pane {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .im-conversation-backdrop {
    position: absolute;
    z-index: 35;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    background: rgba(15, 23, 42, .24);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  .communication-shell.conversations-open .im-conversation-backdrop {
    display: block;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .im-conversation-tools {
    padding: 12px;
  }

  .im-search {
    grid-template-columns: 18px minmax(0, 1fr);
  }

  .im-conversation {
    min-height: 66px;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    padding: 9px 10px;
  }

  .im-conversation > b {
    width: 36px;
    height: 36px;
  }

  .im-conversation time {
    align-self: start;
    margin-top: 3px;
  }

  .im-chat-header {
    min-height: 58px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: 8px 10px;
  }

  .im-conversation-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 6px 9px;
    font-size: 12px;
  }

  .im-chat-header > div:first-of-type {
    min-width: 0;
  }

  .im-chat-header h2 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .im-chat-header p {
    display: none;
  }

  .im-chat-header .line-btn {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 12px;
  }

  .im-message-list {
    padding: 12px 9px;
  }

  .im-message {
    max-width: 94%;
  }

  .message-composer {
    grid-template-columns: 36px minmax(0, 1fr) 38px 58px;
    gap: 6px;
    padding: 8px;
  }

  .message-composer.is-direct {
    grid-template-columns: minmax(0, 1fr) 58px;
  }

  .message-mention-menu {
    left: 8px;
    width: calc(100% - 16px);
  }

  .message-composer textarea {
    font-size: 14px;
  }

  .composer-status {
    grid-column: 1 / -1;
  }
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}

small {
  font-size: 12px;
}

button,
input,
select,
textarea {
  letter-spacing: 0;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(37, 99, 235, .38);
  outline-offset: 2px;
}

/* Login and public entry */
.login-view {
  min-height: 100dvh;
  grid-template-columns: minmax(340px, 520px) minmax(360px, 430px);
  gap: clamp(48px, 8vw, 120px);
  align-content: center;
  justify-content: center;
  padding: 32px;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, .78), transparent 30%),
    linear-gradient(135deg, #f7f4ed 0%, #eef3f8 58%, #f8f6f0 100%);
}

.login-brand-block {
  max-width: 520px;
}

.login-brand-block .product-mark {
  width: 52px;
  height: 52px;
  margin-bottom: 20px;
  border: 0;
  border-radius: var(--radius-lg);
  background: #07111e;
  box-shadow: 0 18px 44px rgba(15, 23, 42, .16);
}

.login-brand-block h1 {
  margin: 10px 0 14px;
  font-size: clamp(42px, 6vw, 72px);
  line-height: .98;
  letter-spacing: 0;
}

.login-brand-block > p:not(.login-eyebrow) {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.login-eyebrow,
.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.login-status {
  margin-top: 26px;
  color: #0f1b2d;
  font-size: 13px;
  font-weight: 700;
}

.login-status span {
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 8px;
  border-radius: 999px;
  background: var(--green);
}

.login-panel {
  width: 100%;
  padding: 30px;
  gap: 16px;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 24px 70px rgba(15, 23, 42, .10);
  backdrop-filter: blur(18px);
}

.login-heading strong {
  font-size: 20px;
}

.login-form {
  gap: 8px;
}

.login-form input {
  min-height: 42px;
}

.login-form .primary-btn {
  min-height: 42px;
  margin-top: 8px;
}

.login-actions-row {
  gap: 12px;
}

.login-help {
  display: none;
}

.powered-by {
  color: var(--primary);
  font-weight: 800;
}

.public-view {
  min-height: 100dvh;
  background: var(--bg);
}

.public-header {
  min-height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
}

.public-main {
  width: min(1040px, calc(100% - 40px));
  padding: 48px 0 64px;
}

.public-intro {
  max-width: 680px;
  margin-bottom: 24px;
}

.public-intro h1 {
  margin: 8px 0;
  font-size: 24px;
  letter-spacing: 0;
}

.onboarding-choice,
.onboarding-form,
.onboarding-result,
.existing-entry-band,
.join-head {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* Core shell */
.app-view {
  width: 100%;
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--rail-width) var(--pane-width) minmax(0, 1fr);
  overflow: hidden;
  background: var(--bg);
}

body[data-role="student"] .app-view,
body[data-role="parent"] .app-view {
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
}

.app-rail {
  position: relative;
  top: auto;
  width: auto;
  height: 100dvh;
  min-width: 0;
  padding: 16px 12px;
  gap: 16px;
  border-right: 1px solid rgba(255, 255, 255, .08);
  background: var(--nav);
  color: #fff;
}

.rail-brand {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  height: 44px;
  margin: 0;
  padding: 0 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .05);
  color: #fff;
  font-size: 14px;
  line-height: 42px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-nav {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 4px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
}

.rail-nav::-webkit-scrollbar {
  display: none;
}

.nav-btn {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  height: 42px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  justify-items: stretch;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgba(255, 255, 255, .68);
  text-align: left;
  transition: background-color .16s ease, color .16s ease, border-color .16s ease;
}

.nav-btn:hover {
  border-color: rgba(255, 255, 255, .07);
  background: rgba(255, 255, 255, .06);
  color: #fff;
}

.nav-btn.active {
  border-color: rgba(64, 124, 255, .22);
  background: var(--nav-active);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--primary);
}

.nav-btn span {
  display: block;
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 650;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-icon {
  width: 18px;
  height: 18px;
  position: relative;
  display: block;
  color: currentColor;
}

.nav-icon::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1.4px solid currentColor;
  border-radius: 4px;
}

.nav-icon::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 6px;
  width: 6px;
  height: 6px;
  border: 1.3px solid currentColor;
  border-radius: 2px;
}

.nav-icon[data-icon="messages"]::before,
.nav-icon[data-icon="notices"]::before {
  inset: 3px 1px 4px;
  border-radius: 5px;
}

.nav-icon[data-icon="messages"]::after,
.nav-icon[data-icon="notices"]::after {
  left: 4px;
  top: auto;
  bottom: 1px;
  width: 5px;
  height: 5px;
  border-width: 0 0 1.4px 1.4px;
  border-radius: 0;
  transform: skew(-28deg);
}

.nav-icon[data-icon="classroom"]::before {
  inset: 2px 1px 5px;
  border-radius: 3px;
}

.nav-icon[data-icon="classroom"]::after {
  left: 4px;
  top: auto;
  bottom: 2px;
  width: 10px;
  height: 1px;
  border: 0;
  background: currentColor;
}

.nav-icon[data-icon="profile"]::before {
  inset: 1px 5px 9px;
  border-radius: 50%;
}

.nav-icon[data-icon="profile"]::after {
  left: 2px;
  top: 10px;
  width: 14px;
  height: 6px;
  border-radius: 8px 8px 3px 3px;
}

.nav-icon[data-icon="risks"]::before {
  inset: 1px 3px 2px;
  border-radius: 50% 50% 4px 4px;
}

.nav-icon[data-icon="risks"]::after {
  content: "!";
  inset: 0;
  width: auto;
  height: auto;
  border: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.rail-logout {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .04);
  color: rgba(255, 255, 255, .62);
  font-size: 13px;
  text-align: left;
}

.rail-logout:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.contact-pane {
  position: relative;
  top: auto;
  width: auto;
  height: 100dvh;
  min-width: 0;
  grid-template-rows: 72px minmax(0, 1fr);
  border-right: 1px solid var(--line);
  background: var(--surface-2);
}

.pane-header {
  min-height: 72px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
}

.pane-header h2 {
  font-size: 16px;
  line-height: 1.25;
}

.pane-header p {
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-panel {
  padding: 14px;
  scrollbar-width: none;
}

.contact-panel::-webkit-scrollbar {
  display: none;
}

.contact-search {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 14px;
}

.contact-search input {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.quick-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 7px;
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.quick-card .primary-btn,
.quick-card .line-btn {
  width: 100%;
  margin-top: 2px;
}

.quick-card strong {
  font-size: 14px;
}

.quick-card span,
.quick-card p {
  font-size: 12px;
  line-height: 1.55;
}

.contact-section-title {
  margin: 18px 4px 8px;
  color: var(--muted);
  font-size: 12px;
}

.contact-item,
.message-contact-card {
  min-height: 62px;
  gap: 10px;
  padding: 11px;
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.contact-item:hover,
.contact-item.active,
.message-contact-card:hover,
.message-contact-card.active {
  border-color: var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.contact-avatar,
.message-contact-card > span:first-child {
  border-radius: var(--radius-sm);
}

/* Main workspace */
.main {
  width: auto;
  max-width: none;
  height: 100dvh;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 20px 24px 32px;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--bg);
  scrollbar-width: thin;
}

#content {
  width: 100%;
  min-width: 0;
  max-width: 1680px;
  margin: 0 auto;
}

.topbar {
  width: 100%;
  max-width: 1680px;
  min-height: 68px;
  margin: 0 auto 16px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow);
}

.topbar h1 {
  font-size: 20px;
  line-height: 1.2;
}

.topbar p {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.45;
}

.userbox {
  min-width: 0;
  max-width: 360px;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.userbox span,
.userbox strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workbench-head,
.portal-welcome,
.page-lead,
.tenant-hero,
.enterprise-head,
.profile-head,
.join-head {
  min-height: 92px;
  margin-bottom: 14px;
  padding: 18px 20px;
  gap: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.portal-welcome,
.page-lead,
.student-welcome,
.teacher-welcome {
  border-top: 1px solid var(--line);
}

.workbench-head h2,
.portal-welcome h2,
.page-lead h2,
.tenant-hero h2,
.enterprise-head h2,
.profile-head h2 {
  margin: 4px 0;
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: 0;
}

.workbench-head p,
.portal-welcome p,
.page-lead p,
.tenant-hero p,
.enterprise-head p,
.profile-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.workbench-actions,
.portal-actions,
.tenant-actions,
.enterprise-actions,
.page-actions {
  gap: 8px;
}

.announcement-band {
  min-height: 44px;
  margin-bottom: 14px;
  padding: 10px 14px;
  gap: 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

/* Buttons */
.primary-btn,
.line-btn,
.ghost-btn,
.danger-btn,
.tool-btn,
.admin-tabs button,
.platform-tabs button,
.tab,
.segmented button {
  min-height: 36px;
  height: auto;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  box-shadow: none;
}

.primary-btn {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
}

.primary-btn:hover {
  border-color: var(--primary-2);
  background: var(--primary-2);
}

.line-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
}

.line-btn:hover,
.ghost-btn:hover,
.tool-btn:hover {
  border-color: #c7d2e2;
  background: var(--surface-3);
  color: var(--ink);
}

.ghost-btn,
.tool-btn {
  border: 1px solid transparent;
  background: var(--surface-3);
  color: #475467;
}

.danger-btn {
  border: 1px solid #fecaca;
  background: var(--red-soft);
  color: var(--red);
}

.tool-btn {
  min-width: 36px;
  padding: 8px 11px;
}

.primary-btn:disabled,
.line-btn:disabled,
.ghost-btn:disabled,
.danger-btn:disabled {
  cursor: not-allowed;
  opacity: .52;
}

/* Cards and content containers */
.grid {
  gap: 14px;
}

.metrics {
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.enterprise-clean-head + .metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card,
.panel,
.item-card,
.form-card,
.module-open-card,
.service-group-admin-card,
.resource-compact-card,
.invite-card,
.application-card,
.role-card,
.training-card,
.approval-card,
.knowledge-card,
.suggestion-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  min-width: 0;
  min-height: 98px;
  padding: 15px 16px;
}

.metric-card span,
.metric-card small {
  font-size: 12px;
}

.metric-card strong {
  margin: 7px 0 4px;
  overflow-wrap: anywhere;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.section-head,
.card-head {
  min-height: 52px;
  padding: 13px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.section-head h2,
.side-title h2,
.card-head h3 {
  font-size: 16px;
  line-height: 1.3;
}

.section-head p,
.card-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-body {
  padding: 16px;
}

.compact-settings {
  min-width: 0;
  margin-top: 14px;
}

.account-create-panel {
  min-width: 0;
  margin-top: 14px;
  overflow: visible;
  position: relative;
  z-index: 2;
}

.compact-settings summary,
.enterprise-settings summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  color: var(--text-2);
  cursor: pointer;
  list-style: none;
}

.account-create-toggle {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.account-create-panel .account-create-toggle {
  cursor: default;
}

.stable-select {
  position: relative;
  z-index: 3;
}

.account-create-toggle > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.form-rule {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.form-feedback {
  grid-column: 1 / -1;
  padding: 12px 14px;
  border: 1px solid rgba(148, 163, 184, 0.36);
  border-radius: 14px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.65;
}

.form-feedback[hidden] {
  display: none;
}

.form-feedback.success {
  border-color: rgba(34, 197, 94, 0.28);
  background: rgba(34, 197, 94, 0.08);
  color: #047857;
}

.form-feedback.warning {
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.1);
  color: #92400e;
}

.form-feedback.error {
  border-color: rgba(239, 68, 68, 0.28);
  background: rgba(239, 68, 68, 0.08);
  color: #b91c1c;
}

.compact-settings summary::-webkit-details-marker,
.enterprise-settings summary::-webkit-details-marker {
  display: none;
}

.compact-settings summary > span:last-child,
.enterprise-settings summary > span:last-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.compact-settings[open] > summary,
.enterprise-settings[open] > summary {
  border-bottom: 1px solid var(--line);
}

.item-card,
.form-card,
.module-open-card,
.service-group-admin-card,
.resource-compact-card,
.invite-card,
.application-card,
.role-card {
  padding: 15px;
  gap: 10px;
}

.item-card:hover,
.module-open-card:hover,
.resource-compact-card:hover,
.contact-item:hover {
  border-color: #cbd5e1;
}

.two-col {
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr);
}

.three-col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.enterprise-clean-grid,
.compact-workspace,
.delivery-clean-grid,
.profile-layout,
.integration-grid,
.admin-account-layout,
.role-editor-layout {
  gap: 14px;
}

.service-group-admin-grid {
  min-width: 0;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
}

.clean-flow {
  gap: 0;
}

.clean-flow button {
  min-height: 62px;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.clean-flow button:hover {
  background: var(--surface-3);
}

.system-status-list article,
.compact-row,
.schedule-row,
.overview-row {
  min-height: 52px;
  padding: 11px 12px;
  gap: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.compact-row:hover,
button.compact-row:hover,
.schedule-row:hover {
  border-color: var(--line);
  background: var(--surface-3);
}

.empty-state,
.action-empty,
.pane-empty {
  min-height: 108px;
  padding: 24px;
  border: 1px dashed #d3dce8;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
}

.empty-state.compact,
.action-empty.compact {
  min-height: 72px;
  padding: 18px;
}

.pill,
.chips span,
.policy-badges span {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
}

.pill {
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: #475467;
}

.pill.green {
  border-color: #ccebd8;
  background: var(--green-soft);
  color: var(--green);
}

.pill.amber {
  border-color: #f4ddb0;
  background: var(--amber-soft);
  color: var(--amber);
}

.pill.red {
  border-color: #f5c7c3;
  background: var(--red-soft);
  color: var(--red);
}

.pill.cyan {
  border-color: #cde8ed;
  background: #edf9fb;
  color: var(--cyan);
}

/* Forms and tables */
.form-grid {
  gap: 14px;
}

.field {
  min-width: 0;
  gap: 7px;
}

.field label {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
}

input:focus,
select:focus,
textarea:focus {
  border-color: #7aa7fa;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .10);
  outline: none;
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  min-height: 16px;
  padding: 0;
  accent-color: var(--primary);
}

.table-wrap,
.data-table-wrap,
.table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 13px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

td {
  color: var(--text-2);
}

/* Tabs and switches */
.admin-tabs,
.platform-tabs,
.tabs,
.segmented {
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-3);
}

.admin-tabs button,
.platform-tabs button,
.tab,
.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.admin-tabs button.active,
.platform-tabs button.active,
.tab.active,
.segmented button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.simple-switch {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

/* Messaging */
.wechat-workspace,
.message-workspace {
  height: calc(100dvh - 124px);
  min-height: 560px;
  grid-template-columns: minmax(0, 1fr) 320px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.message-workspace {
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  box-shadow: none;
}

.message-contact-card {
  min-width: 0;
  height: 100%;
  align-self: stretch;
  padding: 14px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface-2);
  box-shadow: none;
  scrollbar-width: none;
}

.message-contact-card::-webkit-scrollbar {
  display: none;
}

.direct-chat-main {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  overflow: hidden;
}

.direct-chat-timeline {
  min-height: 0;
}

.chat-main,
.direct-chat-main {
  min-width: 0;
  border-right: 1px solid var(--line);
}

.chat-header {
  min-height: 68px;
  padding: 12px 18px;
}

.chat-header h2 {
  font-size: 16px;
}

.chat-header p {
  font-size: 12px;
}

.chat-timeline,
.direct-chat-timeline {
  padding: 20px 22px;
  background: #f7f8fa;
  overscroll-behavior: contain;
}

.wechat-message {
  max-width: min(76%, 680px);
  gap: 9px;
}

.message-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
}

.message-body {
  min-width: 0;
}

.message-body > p,
.message-file-card {
  padding: 10px 12px;
  border-radius: var(--radius);
  line-height: 1.65;
}

.message-kind-badge {
  width: max-content;
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin: 0 0 6px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.lesson-feedback-message .message-body > p {
  border: 1px solid rgba(37, 99, 235, .16);
  background: #fbfdff;
  white-space: pre-wrap;
}

.ai-message .message-avatar {
  background: #07111e;
  color: #fff;
}

.chat-compose {
  min-height: 166px;
  grid-template-rows: auto minmax(72px, 1fr) auto;
}

.compose-tools,
.compose-send {
  min-height: 48px;
  padding: 8px 14px;
  gap: 8px;
}

.compose-tools {
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
}

.chat-compose textarea {
  min-height: 72px;
  padding: 12px 16px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  resize: none;
}

.compose-send {
  border-top: 1px solid var(--line-soft);
}

.profile-drawer,
.message-drawer {
  min-width: 0;
  padding: 16px;
  background: var(--surface-2);
}

.drawer-section {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.group-member-strip,
.drawer-members {
  gap: 8px;
}

.toast {
  z-index: 1000;
  max-width: min(520px, calc(100vw - 32px));
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius-sm);
  background: #101827;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .20);
  font-size: 13px;
  line-height: 1.55;
  text-align: left;
}

.modern-compose {
  position: relative;
  z-index: 6;
  min-height: 74px;
  grid-template-columns: 38px minmax(0, 1fr) 40px 72px;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.modern-compose .compose-icon-btn {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: #f3f6f9;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.modern-compose .voice-record-btn {
  width: 40px;
  padding: 0;
}

.modern-compose .voice-record-btn.recording {
  border-color: rgba(180, 35, 24, .22);
  background: var(--red-soft);
  color: var(--red);
}

.modern-compose textarea {
  position: relative;
  z-index: 1;
  pointer-events: auto;
  user-select: text;
  min-height: 40px;
  max-height: 96px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
  line-height: 1.5;
}

.modern-compose .compose-submit-btn {
  min-height: 40px;
  padding: 0 16px;
}

.voice-record-status {
  grid-column: 1 / -1;
  min-height: 18px;
  color: var(--red);
  font-size: 12px;
}

.mic-icon {
  width: 14px;
  height: 20px;
  display: inline-block;
  position: relative;
}

.mic-icon::before {
  content: "";
  position: absolute;
  top: 0;
  left: 3px;
  width: 8px;
  height: 13px;
  border: 2px solid currentColor;
  border-radius: 7px;
}

.mic-icon::after {
  content: "";
  position: absolute;
  left: 1px;
  bottom: 0;
  width: 12px;
  height: 9px;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid transparent;
  border-right: 2px solid transparent;
  box-shadow: 5px 3px 0 -3px currentColor;
}

.group-side-panel {
  min-width: 0;
  height: auto;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 0;
  overflow: visible;
  background: var(--surface-2);
}

.chat-group-menu {
  position: relative;
}

.chat-group-menu > summary {
  list-style: none;
}

.chat-group-menu > summary::-webkit-details-marker {
  display: none;
}

.chat-group-menu-panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  right: 0;
  width: min(340px, calc(100vw - 40px));
  max-height: min(620px, calc(100dvh - 150px));
  padding: 12px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  box-shadow: 0 16px 40px rgba(15, 23, 42, .14);
}

.group-side-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.group-side-card summary {
  cursor: pointer;
  font-weight: 800;
}

.group-member-list {
  display: grid;
  gap: 8px;
}

.group-member-list article {
  min-width: 0;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.group-member-list b {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: #e9eef8;
  color: var(--primary);
  font-size: 13px;
}

.group-member-list span,
.group-member-list strong,
.group-member-list small {
  min-width: 0;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-member-list small {
  color: var(--muted);
}

.group-member-list .ai-member b {
  background: #07111e;
  color: #fff;
}

.group-announcement {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #f6f8fb;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.65;
}

.group-settings-card form {
  margin-top: 12px;
}

.switch-field {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 700;
}

.voice-bubble {
  min-width: 230px;
  max-width: 360px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.voice-play-dot {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  position: relative;
}

.voice-play-dot::after {
  content: "";
  position: absolute;
  top: 10px;
  left: 13px;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 10px solid #fff;
}

.voice-bubble audio {
  width: 100%;
  height: 34px;
}

.voice-bubble span,
.voice-bubble small {
  grid-column: 2;
}

.voice-bubble small {
  color: var(--muted);
}

.feedback-ai-studio {
  overflow: hidden;
}

.feedback-studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: stretch;
}

.feedback-form-block {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: #fbfcfe;
}

.feedback-studio-side {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #07111e;
  color: #fff;
}

.feedback-studio-side strong {
  font-size: 16px;
}

.feedback-studio-side p {
  margin: 0;
  color: rgba(255, 255, 255, .74);
  font-size: 13px;
  line-height: 1.75;
}

.feedback-studio-side .primary-btn {
  margin-top: 4px;
  background: var(--primary);
}

.feedback-list {
  display: grid;
  gap: 12px;
}

.feedback-record {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.feedback-record.draft {
  border-color: rgba(167, 98, 19, .28);
  background: #fffdf7;
}

.feedback-record header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.feedback-record header div,
.feedback-record header strong,
.feedback-record header span:not(.pill) {
  min-width: 0;
  display: block;
}

.feedback-record header span:not(.pill) {
  color: var(--muted);
  font-size: 12px;
}

.feedback-record > p {
  margin: 0;
  color: var(--text-2);
  line-height: 1.75;
  white-space: pre-wrap;
}

.feedback-draft-editor {
  display: grid;
  gap: 8px;
}

.feedback-draft-editor span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.feedback-draft-editor textarea {
  min-height: 150px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  line-height: 1.7;
  resize: vertical;
}

.feedback-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

/* Classroom */
.classroom-stage {
  min-height: 280px;
  padding: 24px;
  border: 1px solid #26364c;
  border-radius: var(--radius-lg);
  background: #0b1422;
}

.classroom-stage strong {
  font-size: 20px;
}

.video-placeholder,
.classroom-video-tile {
  border-radius: var(--radius);
}

/* Medium desktop */
@media (max-width: 1320px) {
  :root {
    --rail-width: 166px;
    --pane-width: 262px;
  }

  .main {
    padding: 18px 18px 28px;
  }

  .two-col,
  .enterprise-clean-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .three-col,
  .module-grid,
  .org-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wechat-workspace,
  .message-workspace {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .message-workspace.has-group-panel {
    grid-template-columns: 236px minmax(360px, 1fr) 280px;
  }

  .wechat-workspace {
    grid-template-columns: minmax(0, 1fr) 284px;
  }
}

/* Tablet: stable horizontal navigation, no text squeezing */
@media (max-width: 920px) {
  body {
    overflow: auto;
  }

  .app-view,
  body[data-role="student"] .app-view,
  body[data-role="parent"] .app-view {
    height: auto;
    min-height: 100dvh;
    display: block;
    overflow: visible;
  }

  .app-rail {
    position: sticky;
    z-index: 20;
    top: 0;
    width: 100%;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    overflow: hidden;
  }

  .rail-brand {
    width: 108px;
    min-width: 108px;
    height: 42px;
    text-align: center;
  }

  .rail-nav {
    flex: 1;
    min-width: 0;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .rail-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-btn {
    width: auto;
    min-width: max-content;
    grid-template-columns: 18px auto;
    padding: 0 12px;
  }

  .nav-btn.active {
    box-shadow: inset 0 -3px 0 var(--primary);
  }

  .rail-logout {
    width: auto;
    min-width: max-content;
    height: 40px;
    padding: 0 12px;
    text-align: center;
  }

  .contact-pane {
    position: static;
    width: 100%;
    height: auto;
    max-height: 300px;
    display: grid;
    grid-template-rows: 64px minmax(0, 1fr);
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  body[data-role="student"] .contact-pane,
  body[data-role="parent"] .contact-pane {
    display: none;
  }

  .main,
  body[data-role="student"] .main,
  body[data-role="parent"] .main {
    width: 100%;
    height: auto;
    min-height: calc(100dvh - 64px);
    padding: 16px;
    overflow: visible;
  }

  .workbench-head,
  .portal-welcome,
  .page-lead,
  .tenant-hero,
  .enterprise-head,
  .profile-head {
    align-items: flex-start;
  }

  .form-grid,
  .feedback-studio-grid,
  .delivery-shell,
  .compact-workspace,
  .enterprise-module-layout,
  .admin-account-layout,
  .role-editor-layout,
  .profile-layout,
  .integration-grid,
  .delivery-clean-grid,
  .subject-readonly-grid,
  .member-permission-grid,
  .module-check-grid,
  .module-switch-grid,
  .role-summary-grid,
  .workflow-grid,
  .clean-flow,
  .training-steps,
  .classroom-video-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .wechat-workspace,
  .message-workspace {
    height: auto;
    min-height: 680px;
    grid-template-columns: minmax(0, 1fr);
  }

  .message-workspace.has-group-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .message-contact-card {
    max-height: 240px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .chat-main,
  .direct-chat-main {
    min-height: 620px;
    border-right: 0;
  }

  .profile-drawer,
  .message-drawer,
  .group-side-panel {
    border-top: 1px solid var(--line);
  }

  .group-side-panel {
    height: auto;
  }
}

/* Phone */
@media (max-width: 640px) {
  .login-view {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 20px 14px;
  }

  .login-brand-block {
    text-align: left;
  }

  .login-brand-block .product-mark {
    margin: 0 0 14px;
  }

  .login-brand-block h1 {
    font-size: clamp(38px, 13vw, 54px);
  }

  .login-panel {
    padding: 20px;
  }

  .public-header {
    padding: 12px 14px;
  }

  .public-main {
    width: calc(100% - 28px);
    padding: 30px 0 44px;
  }

  .rail-brand {
    width: 72px;
    min-width: 72px;
    padding: 0 8px;
  }

  .nav-btn {
    width: auto;
    min-width: max-content;
    grid-template-columns: 16px auto;
    gap: 7px;
    padding: 0 10px;
  }

  .nav-icon {
    width: 16px;
    height: 16px;
  }

  .rail-logout {
    display: none;
  }

  .contact-pane {
    max-height: 260px;
  }

  .main {
    padding: 12px;
  }

  .topbar,
  .workbench-head,
  .portal-welcome,
  .page-lead,
  .tenant-hero,
  .enterprise-head,
  .profile-head,
  .announcement-band {
    display: grid;
    align-items: stretch;
  }

  .topbar {
    gap: 10px;
  }

  .userbox {
    max-width: 100%;
    justify-content: space-between;
  }

  .workbench-head,
  .portal-welcome,
  .page-lead,
  .tenant-hero,
  .enterprise-head,
  .profile-head {
    padding: 16px;
  }

  .workbench-actions,
  .portal-actions,
  .tenant-actions,
  .enterprise-actions,
  .page-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .workbench-actions button,
  .portal-actions button,
  .tenant-actions button,
  .enterprise-actions button,
  .page-actions button {
    width: 100%;
  }

  .metrics,
  .enterprise-clean-head + .metrics,
  .three-col,
  .module-grid,
  .org-board,
  .onboarding-choice-grid,
  .join-form-grid,
  .member-permission-grid,
  .application-info {
    grid-template-columns: minmax(0, 1fr);
  }

  .section-head,
  .card-head,
  .row {
    align-items: flex-start;
  }

  .section-head {
    flex-wrap: wrap;
  }

  .admin-tabs,
  .platform-tabs,
  .tabs {
    overflow-x: auto;
  }

  .admin-tabs button,
  .platform-tabs button,
  .tab {
    min-width: max-content;
  }

  .wechat-message {
    max-width: 92%;
  }

  .chat-timeline,
  .direct-chat-timeline {
    padding: 16px 12px;
  }

  .compose-tools,
  .compose-send {
    padding: 8px 10px;
  }

  .modern-compose {
    grid-template-columns: 36px minmax(0, 1fr) 40px 68px;
    grid-template-rows: auto auto;
  }

  .modern-compose .compose-submit-btn {
    grid-column: auto;
    width: auto;
  }

  .feedback-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .toast {
    bottom: 14px;
    max-width: calc(100vw - 24px);
  }
}

/* Fully collapsed meeting: a single-line, draggable control bar. */
body .meeting-floating-compact .chat-meeting-dialog {
  width: min(400px, calc(100vw - 24px));
  height: 56px;
  min-height: 56px;
}

body .meeting-floating-compact .chat-meeting-head {
  width: 100%;
  min-height: 56px;
  padding: 8px 10px 8px 12px;
  gap: 10px;
}

body .meeting-floating-compact .meeting-title-block {
  min-width: 0;
  flex: 1 1 auto;
}

body .meeting-floating-compact .meeting-title-block > div {
  min-width: 0;
  width: 100%;
}

body .meeting-floating-compact .chat-meeting-head h2 {
  display: block;
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  color: #f4f7fb;
  font-size: 14px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body .meeting-floating-compact .meeting-floating-actions {
  flex: 0 0 auto;
  gap: 6px;
}

body .meeting-floating-compact .meeting-floating-actions button {
  width: auto;
  min-width: 0;
  min-height: 34px;
  padding: 0 10px;
  line-height: 1;
  white-space: nowrap;
}

body .meeting-floating-compact [data-chat-meeting-action="restore"] {
  border-color: #416aaa;
  background: #1a3768;
}

@media (max-width: 440px) {
  body .meeting-floating-compact .chat-meeting-dialog {
    width: calc(100vw - 20px);
  }

  body .meeting-floating-compact .chat-meeting-head h2 {
    font-size: 13px;
  }
}

body .chat-meeting-overlay .video-tile .meeting-avatar {
  width: 74px !important;
  height: 74px !important;
}

body .chat-meeting-overlay .video-tile .meeting-member-meta {
  width: auto !important;
  height: auto !important;
  pointer-events: none;
}

body .chat-meeting-overlay #classroomMeetingStage .remote-video-grid.has-focus {
  display: contents;
  min-height: 0;
}

body .chat-meeting-overlay #classroomMeetingStage .video-tile.focus {
  min-height: 260px;
}

body .chat-meeting-dialog:fullscreen,
body .chat-meeting-dialog:-webkit-full-screen,
body .chat-meeting-dialog.meeting-fullscreen-dialog {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  border: 0;
  border-radius: 0;
}

/* Meeting action approvals are scoped to the live room and disappear when it ends. */
.meeting-action-requests:empty {
  display: none;
}

.meeting-action-requests {
  display: grid;
  gap: 6px;
  padding: 8px 10px 0;
}

.meeting-action-requests article {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  border: 1px solid #38527a;
  border-radius: 6px;
  color: #dce8f8;
  background: #142743;
  font-size: 12px;
}

.meeting-action-requests article > span:last-child {
  display: flex;
  gap: 5px;
}

.meeting-action-requests button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid #5276ad;
  border-radius: 5px;
  color: #fff;
  background: #2458a7;
  cursor: pointer;
}

.meeting-action-requests button:last-child {
  border-color: #78505a;
  background: #4b2932;
}

.meeting-side-view.active {
  grid-template-rows: minmax(0, 1fr) auto auto;
}

.meeting-side-view.active:has(.meeting-action-requests:not(:empty)) {
  grid-template-rows: auto minmax(0, 1fr) auto auto;
}

/* Mobile portrait: the video owns the canvas and chat fades over its lower edge. */
@media (max-width: 700px) and (orientation: portrait) {
  body .chat-meeting-overlay:not(.meeting-floating) {
    padding: 0;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .chat-meeting-dialog {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .chat-meeting-head {
    min-height: 64px;
    padding: max(8px, env(safe-area-inset-top, 0px)) 10px 8px;
    gap: 8px;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-camera-mark,
  body .chat-meeting-overlay:not(.meeting-floating) .meeting-title-block .eyebrow,
  body .chat-meeting-overlay:not(.meeting-floating) .chat-meeting-head p {
    display: none;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-title-block {
    min-width: 0;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .chat-meeting-head h2 {
    max-width: 43vw;
    overflow: hidden;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-window-actions {
    flex: 0 0 auto;
    gap: 5px;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-window-actions .line-btn {
    min-width: 0;
    min-height: 36px;
    padding: 0 9px;
    font-size: 12px;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .chat-meeting-stage {
    position: relative;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto auto;
    gap: 8px;
    padding: 0 8px max(8px, env(safe-area-inset-bottom, 0px));
    overflow: hidden;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-workspace {
    position: relative;
    display: block;
    min-height: 0;
    overflow: hidden;
    border-radius: 8px;
    background: #030912;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-video-area {
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 0;
    border-radius: 0;
    background: #030912;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-stage-head {
    display: none;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .classroom-video-grid {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none !important;
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(0, 1fr);
    gap: 6px;
    padding: 0;
    overflow: hidden;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .video-tile,
  body .chat-meeting-overlay:not(.meeting-floating) .video-empty {
    min-height: 0;
    border: 0;
    border-radius: 0;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .video-tile > div[id],
  body .chat-meeting-overlay:not(.meeting-floating) .video-tile video {
    object-fit: contain !important;
    background: #030912;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .classroom-video-grid.has-focus {
    min-height: 0;
    grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
    grid-template-rows: minmax(0, 1fr) 72px;
    grid-auto-rows: 72px;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: #365376 transparent;
  }

  body .chat-meeting-overlay:not(.meeting-floating) #classroomMeetingStage .classroom-video-grid.has-focus .video-tile.focus {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
  }

  body .chat-meeting-overlay:not(.meeting-floating) #classroomMeetingStage .classroom-video-grid.has-focus .video-tile:not(.focus) {
    height: 72px;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-side-panel {
    position: absolute;
    z-index: 8;
    right: 0;
    bottom: 0;
    left: 0;
    height: min(36%, 228px);
    min-height: 150px;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: linear-gradient(to top, rgba(4, 10, 18, .94) 0%, rgba(4, 10, 18, .66) 62%, rgba(4, 10, 18, 0) 100%);
    backdrop-filter: blur(4px);
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-side-tabs {
    justify-self: end;
    width: 150px;
    margin-left: auto;
    padding: 4px 6px;
    border: 0;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-side-tabs button {
    min-height: 32px;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-chat-messages {
    padding: 4px 10px;
    scrollbar-width: thin;
    scrollbar-color: #365376 transparent;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-chat-messages::-webkit-scrollbar {
    width: 4px;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-chat-messages::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background: #365376;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-chat-composer {
    padding: 6px 8px;
    border-top-color: rgba(255, 255, 255, .08);
    background: rgba(4, 10, 18, .55);
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-chat-privacy {
    display: none;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .classroom-status {
    min-height: 18px;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-lesson-picker {
    display: none;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-controls {
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 6px;
    margin: 0;
    padding: 7px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-controls::-webkit-scrollbar {
    display: none;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-controls button,
  body .chat-meeting-overlay:not(.meeting-floating) .meeting-controls select {
    min-width: 82px;
    min-height: 44px;
    flex: 0 0 auto;
    margin: 0;
    padding-inline: 9px;
    font-size: 12px;
  }
}

/* Mobile landscape: main picture on the left, conversation and controls on the right. */
@media (max-width: 950px) and (max-height: 600px) and (orientation: landscape) {
  body .chat-meeting-overlay:not(.meeting-floating) {
    padding: 0;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .chat-meeting-dialog {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .chat-meeting-head {
    min-height: 48px;
    padding: max(5px, env(safe-area-inset-top, 0px)) 10px 5px;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-camera-mark,
  body .chat-meeting-overlay:not(.meeting-floating) .meeting-title-block .eyebrow,
  body .chat-meeting-overlay:not(.meeting-floating) .chat-meeting-head p {
    display: none;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .chat-meeting-head h2 {
    max-width: 48vw;
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-window-actions .line-btn {
    min-width: 0;
    min-height: 34px;
    padding: 0 9px;
    font-size: 11px;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .chat-meeting-stage {
    position: relative;
    display: block;
    padding: 8px;
    overflow: hidden;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-workspace {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(250px, 31vw);
    gap: 8px;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-video-area,
  body .chat-meeting-overlay:not(.meeting-floating) .meeting-side-panel {
    height: 100%;
    min-height: 0;
    margin: 0;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-stage-head,
  body .chat-meeting-overlay:not(.meeting-floating) .classroom-status,
  body .chat-meeting-overlay:not(.meeting-floating) .meeting-lesson-picker {
    display: none;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-video-area {
    display: block;
    position: relative;
    background: #030912;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .classroom-video-grid {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none !important;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    grid-auto-rows: minmax(0, 1fr);
    padding: 0;
    overflow: hidden;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .video-tile,
  body .chat-meeting-overlay:not(.meeting-floating) .video-empty {
    min-height: 0;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .video-tile > div[id],
  body .chat-meeting-overlay:not(.meeting-floating) .video-tile video {
    object-fit: contain !important;
    background: #030912;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .classroom-video-grid.has-focus {
    position: relative;
    min-height: 0;
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
    grid-template-rows: minmax(0, 1fr) 76px;
    grid-auto-rows: 76px;
    gap: 6px;
  }

  body .chat-meeting-overlay:not(.meeting-floating) #classroomMeetingStage .classroom-video-grid.has-focus .video-tile.focus {
    width: 100%;
    height: 100%;
    aspect-ratio: 16 / 9;
  }

  body .chat-meeting-overlay:not(.meeting-floating) #classroomMeetingStage .classroom-video-grid.has-focus .video-tile:not(.focus) {
    height: 76px;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .classroom-video-grid.has-focus #meetingLocalTile:not(.focus):not(.camera-off) {
    position: absolute;
    z-index: 9;
    top: 10px;
    right: 10px;
    width: min(168px, 24%);
    height: auto;
    min-height: 0;
    aspect-ratio: 16 / 9;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .42);
  }

  body .chat-meeting-overlay:not(.meeting-floating) .classroom-video-grid.has-focus #meetingLocalTile.camera-off:not(.focus) {
    display: none;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-side-panel {
    padding-bottom: 122px;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-side-tabs {
    padding: 5px;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-side-tabs button {
    min-height: 31px;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-chat-messages {
    padding: 7px;
    scrollbar-width: thin;
    scrollbar-color: #365376 transparent;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-chat-composer {
    padding: 6px;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-chat-privacy {
    display: none;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-controls {
    position: absolute;
    z-index: 12;
    right: 8px;
    bottom: 8px;
    width: min(31vw, 300px);
    min-width: 250px;
    max-height: 116px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    margin: 0;
    padding: 6px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #365376 transparent;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-controls button,
  body .chat-meeting-overlay:not(.meeting-floating) .meeting-controls select {
    min-width: 0;
    min-height: 35px;
    margin: 0;
    padding: 0 5px;
    font-size: 10px;
  }
}

/* Mobile application shell */
.mobile-more-btn,
.mobile-menu-overlay,
.mobile-more-sheet,
.mobile-comm-overview {
  display: none;
}

@media (max-width: 920px) {
  :root {
    --mobile-nav-height: calc(68px + env(safe-area-inset-bottom, 0px));
  }

  body {
    background: var(--bg);
  }

  body.mobile-menu-open {
    overflow: hidden;
  }

  .app-view,
  body[data-role="student"] .app-view,
  body[data-role="parent"] .app-view {
    min-height: 100dvh;
    padding-bottom: var(--mobile-nav-height);
  }

  .app-rail {
    position: fixed;
    z-index: 50;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--mobile-nav-height);
    min-height: var(--mobile-nav-height);
    display: block;
    padding: 7px 10px calc(7px + env(safe-area-inset-bottom, 0px));
    overflow: hidden;
    border-top: 1px solid var(--line);
    border-right: 0;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 -8px 24px rgba(15, 23, 42, .06);
    backdrop-filter: blur(18px);
  }

  .rail-brand,
  .rail-logout {
    display: none;
  }

  .rail-nav {
    width: 100%;
    height: 54px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    overflow: visible;
  }

  .nav-btn {
    display: none;
  }

  .nav-btn.mobile-primary,
  .nav-btn.mobile-more-btn {
    width: 100%;
    min-width: 0;
    height: 54px;
    min-height: 54px;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 22px 16px;
    place-items: center;
    align-content: center;
    gap: 3px;
    padding: 5px 4px;
    border: 0;
    border-radius: var(--radius);
    color: var(--muted);
    text-align: center;
  }

  .nav-btn.mobile-primary:hover,
  .nav-btn.mobile-more-btn:hover {
    border: 0;
    background: var(--surface-3);
    color: var(--ink);
  }

  .nav-btn.mobile-primary.active,
  .nav-btn.mobile-more-btn.active {
    background: var(--nav);
    color: #fff;
    box-shadow: none;
  }

  .nav-btn.mobile-primary span,
  .nav-btn.mobile-more-btn span {
    width: 100%;
    overflow: hidden;
    font-size: 12px;
    font-weight: 750;
    line-height: 16px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-btn.mobile-primary .nav-icon,
  .nav-btn.mobile-more-btn .nav-icon {
    width: 20px;
    height: 20px;
  }

  .mobile-more-icon::before,
  .mobile-more-icon::after {
    content: "";
    position: absolute;
    left: 3px;
    right: 3px;
    width: auto;
    height: 1.5px;
    border: 0;
    border-radius: 99px;
    background: currentColor;
  }

  .mobile-more-icon::before {
    top: 5px;
    box-shadow: 0 5px 0 currentColor, 0 10px 0 currentColor;
  }

  .mobile-more-icon::after {
    display: none;
  }

  .contact-pane,
  body[data-role="student"] .contact-pane,
  body[data-role="parent"] .contact-pane {
    display: none;
  }

  .main,
  body[data-role="student"] .main,
  body[data-role="parent"] .main {
    min-height: calc(100dvh - var(--mobile-nav-height));
    padding: 10px 12px 22px;
  }

  .topbar {
    position: sticky;
    z-index: 16;
    top: 0;
    min-height: 66px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(16px);
  }

  .topbar > div:first-child {
    min-width: 0;
  }

  .topbar h1 {
    overflow: hidden;
    font-size: 20px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar p,
  .userbox span {
    display: none;
  }

  .userbox {
    width: auto;
    max-width: 132px;
    min-height: 36px;
    margin-left: auto;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
  }

  .userbox strong {
    display: block;
    max-width: 108px;
    font-size: 12px;
  }

  .workbench-head,
  .portal-welcome,
  .page-lead,
  .tenant-hero,
  .enterprise-head,
  .profile-head {
    min-height: 0;
    padding: 16px;
  }

  .workbench-head h2,
  .portal-welcome h2,
  .page-lead h2,
  .tenant-hero h2,
  .enterprise-head h2,
  .profile-head h2 {
    font-size: 20px;
  }

  .metrics,
  .enterprise-clean-head + .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .metric-card {
    min-height: 96px;
    padding: 13px;
  }

  .metric-card strong {
    font-size: 24px;
  }

  .clean-flow {
    display: flex;
    gap: 8px;
    padding: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .clean-flow::-webkit-scrollbar {
    display: none;
  }

  .clean-flow button {
    flex: 0 0 118px;
    min-height: 98px;
    display: grid;
    align-content: space-between;
    gap: 7px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    scroll-snap-align: start;
  }

  .mobile-menu-overlay {
    position: fixed;
    z-index: 70;
    inset: 0;
    display: block;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    background: rgba(7, 17, 30, .36);
    transition: opacity .2s ease;
  }

  .mobile-menu-overlay.open {
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
  }

  .mobile-more-sheet {
    position: fixed;
    z-index: 71;
    right: 0;
    bottom: 0;
    left: 0;
    max-height: min(76dvh, 720px);
    display: flex;
    flex-direction: column;
    padding: 8px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    overflow: hidden;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 -12px 36px rgba(15, 23, 42, .16);
    transform: translateY(104%);
    transition: transform .22s ease;
  }

  .mobile-more-sheet.open {
    transform: translateY(0);
  }

  .mobile-sheet-handle {
    width: 40px;
    height: 4px;
    margin: 3px auto 12px;
    border-radius: 99px;
    background: #d0d5dd;
  }

  .mobile-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
  }

  .mobile-sheet-head strong,
  .mobile-sheet-head span {
    display: block;
  }

  .mobile-sheet-head strong {
    font-size: 20px;
  }

  .mobile-sheet-head span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
  }

  .mobile-sheet-close {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    color: var(--ink);
    font-size: 20px;
  }

  .mobile-more-grid {
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    overflow-y: auto;
    scrollbar-width: none;
  }

  .mobile-more-grid::-webkit-scrollbar {
    display: none;
  }

  .mobile-more-card {
    min-width: 0;
    min-height: 92px;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--ink);
    text-align: left;
  }

  .mobile-more-card.active {
    border-color: #9bbcff;
    background: var(--primary-soft);
  }

  .mobile-more-card .nav-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    color: var(--primary);
  }

  .mobile-more-card .nav-icon::before {
    inset: 8px;
  }

  .mobile-more-card .nav-icon::after {
    left: 13px;
    top: 13px;
  }

  .mobile-more-card strong,
  .mobile-more-card small {
    display: block;
    min-width: 0;
  }

  .mobile-more-card strong {
    font-size: 13px;
  }

  .mobile-more-card small {
    margin-top: 5px;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .mobile-menu-empty {
    grid-column: 1 / -1;
    padding: 24px;
    color: var(--muted);
    text-align: center;
  }

  .mobile-comm-overview {
    display: block;
    margin-bottom: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .mobile-comm-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 12px;
  }

  .mobile-comm-head h2 {
    margin: 4px 0;
    font-size: 20px;
  }

  .mobile-comm-head p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
  }

  .mobile-service-status {
    min-height: 26px;
    padding: 5px 8px;
    border-radius: 999px;
    background: var(--amber-soft);
    color: var(--amber);
    font-size: 12px;
    font-weight: 750;
    white-space: nowrap;
  }

  .mobile-service-status.ready {
    background: var(--green-soft);
    color: var(--green);
  }

  .mobile-comm-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 14px;
  }

  .mobile-comm-actions button {
    min-width: 0;
    min-height: 94px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface-2);
    color: var(--ink);
    text-align: left;
  }

  .mobile-comm-actions .nav-icon {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    color: var(--primary);
  }

  .mobile-comm-actions .nav-icon::before {
    inset: 7px;
  }

  .mobile-comm-actions .nav-icon::after {
    left: 11px;
    top: 11px;
  }

  .mobile-comm-actions strong,
  .mobile-comm-actions small {
    display: block;
  }

  .mobile-comm-actions strong {
    font-size: 12px;
  }

  .mobile-comm-actions small {
    margin-top: 2px;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body[data-page="classroom"] .profile-drawer {
    order: -1;
    display: grid;
    gap: 0;
  }

  body[data-page="classroom"] #drawerClassroom {
    order: -10;
  }
}

@media (max-width: 359px) {
  .metrics,
  .enterprise-clean-head + .metrics,
  .mobile-comm-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .mobile-more-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Communication and video meeting */
.voice-message {
  width: min(300px, 100%);
  display: grid;
  gap: 7px;
  margin-top: 8px;
}

.voice-message span,
.voice-record-status {
  color: var(--muted);
  font-size: 12px;
}

.voice-message audio {
  width: 100%;
  height: 36px;
  accent-color: var(--primary);
}

.voice-record-btn.recording {
  border-color: #f2aaa5;
  background: var(--red-soft);
  color: var(--red);
}

.voice-record-status:not(:empty) {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  color: var(--red);
  font-weight: 700;
}

.meeting-stage {
  min-height: 420px;
  display: grid;
  grid-template-rows: auto minmax(240px, 1fr) auto auto;
  place-items: stretch;
  gap: 14px;
  color: #f7f9fc;
  text-align: left;
}

.meeting-stage-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.meeting-stage-head strong,
.meeting-stage-head p {
  display: block;
  margin: 0;
}

.meeting-stage-head strong {
  font-size: 20px;
}

.meeting-stage-head p {
  margin-top: 4px;
  color: #aebbd0;
  font-size: 13px;
}

.meeting-fullscreen-btn {
  flex: 0 0 auto;
  border-color: #40516b;
  background: #172338;
  color: #f7f9fc;
}

.meeting-stage .classroom-video-grid {
  min-height: 240px;
  margin: 0;
}

.meeting-stage .classroom-status {
  margin: 0;
  text-align: center;
}

.meeting-controls {
  position: relative;
  z-index: 5;
  justify-content: center;
  padding: 12px;
  border: 1px solid #26364c;
  border-radius: var(--radius);
  background: #101b2c;
}

/* A focused screen-share tile can be taller than the modal video row. Keep
   the picture inside its row so it never covers the microphone/camera/share
   controls. The native fullscreen rules below intentionally remove this
   non-fullscreen cap. */
.chat-meeting-overlay .meeting-stage:not(:fullscreen):not(.meeting-fullscreen-fallback) .classroom-video-grid {
  max-height: min(56vh, 540px);
  overflow: auto;
  overscroll-behavior: contain;
}

.meeting-stage .video-tile video {
  pointer-events: none;
}

.meeting-controls button {
  min-width: 106px;
}

.meeting-controls .line-btn.active,
.chat-header-actions [data-class-action].active {
  border-color: #7ca4ff;
  background: #173770;
  color: #fff;
}

.meeting-stage:fullscreen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  padding: 20px;
  border: 0;
  border-radius: 0;
  background: #07111e;
}

.meeting-stage:-webkit-full-screen,
.meeting-stage.meeting-fullscreen-fallback {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px;
  border: 0;
  border-radius: 0;
  background: #07111e;
}

.meeting-stage.meeting-fullscreen-fallback {
  position: fixed;
  inset: 0;
  z-index: 1000;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
}

body.meeting-fullscreen-open {
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

.meeting-stage:fullscreen .classroom-video-grid,
.meeting-stage:-webkit-full-screen .classroom-video-grid,
.meeting-stage.meeting-fullscreen-fallback .classroom-video-grid {
  min-height: 0;
  height: 100%;
}

.meeting-stage:fullscreen .video-tile,
.meeting-stage:fullscreen .remote-video-grid,
.meeting-stage:-webkit-full-screen .video-tile,
.meeting-stage:-webkit-full-screen .remote-video-grid,
.meeting-stage.meeting-fullscreen-fallback .video-tile,
.meeting-stage.meeting-fullscreen-fallback .remote-video-grid {
  min-height: 0;
}

@media (max-width: 920px) {
  .rail-nav {
    grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
  }

  .compose-tools {
    gap: 7px;
  }

  .compose-tools .tool-btn {
    min-width: 36px;
    min-height: 36px;
    padding: 8px 10px;
  }

  .voice-record-status:not(:empty) {
    width: 100%;
  }

  .meeting-stage {
    min-height: 0;
    grid-template-rows: auto auto auto auto;
    gap: 10px;
    padding: 12px;
  }

  .meeting-stage-head strong {
    font-size: 16px;
  }

  .meeting-stage .classroom-video-grid {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

  .meeting-stage .video-tile,
  .meeting-stage .remote-video-grid {
    min-height: 0;
    aspect-ratio: 16 / 9;
  }

  .meeting-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
  }

  .meeting-controls button {
    width: 100%;
    min-width: 0;
    min-height: 40px;
  }

  .meeting-stage:fullscreen,
  .meeting-stage:-webkit-full-screen,
  .meeting-stage.meeting-fullscreen-fallback {
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    gap: 10px;
    padding: max(12px, env(safe-area-inset-top, 0px)) 12px max(12px, env(safe-area-inset-bottom, 0px));
  }

  .meeting-stage:fullscreen .classroom-video-grid,
  .meeting-stage:-webkit-full-screen .classroom-video-grid,
  .meeting-stage.meeting-fullscreen-fallback .classroom-video-grid {
    height: 100%;
    overflow-y: auto;
  }

  .meeting-stage:fullscreen .video-tile,
  .meeting-stage:fullscreen .remote-video-grid,
  .meeting-stage:-webkit-full-screen .video-tile,
  .meeting-stage:-webkit-full-screen .remote-video-grid,
  .meeting-stage.meeting-fullscreen-fallback .video-tile,
  .meeting-stage.meeting-fullscreen-fallback .remote-video-grid {
    aspect-ratio: auto;
    min-height: 150px;
  }
}

@media (max-width: 480px) {
  .mobile-comm-head {
    grid-template-columns: minmax(0, 1fr);
  }

  .mobile-service-status {
    width: max-content;
  }

  .mobile-more-grid {
    gap: 8px;
  }

  .mobile-more-card {
    min-height: 84px;
    padding: 12px;
  }
}

/* Stable tenant login layout */
body .login-view {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 48px minmax(0, 1fr) auto;
  gap: 0;
  padding: 28px 32px 22px;
  background: #f4f6f8;
}

.login-topbar {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: flex;
  align-items: center;
}

.login-platform-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.login-platform-brand .product-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  margin: 0;
  border: 0;
  border-radius: 10px;
  background: #08111f;
  color: #fff;
  box-shadow: 0 10px 24px rgba(8, 17, 31, .14);
  font-size: 16px;
  font-weight: 800;
}

.login-platform-brand > div:last-child {
  min-width: 0;
}

.login-platform-brand strong,
.login-platform-brand span {
  display: block;
}

.login-platform-brand strong {
  color: #5d6979;
  font-size: 13px;
  line-height: 1.1;
  letter-spacing: 0;
}

.login-platform-brand span {
  margin-top: 4px;
  color: #667085;
  font-size: 12px;
  line-height: 1.2;
}

.login-main {
  width: min(1120px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 410px;
  align-items: center;
  gap: 86px;
  padding: 24px 0 28px;
}

.login-brand-block {
  min-width: 0;
  max-width: 560px;
  align-self: center;
}

.login-brand-block h1 {
  margin: 0;
  color: #08111f;
  font-size: 64px;
  line-height: 1;
  letter-spacing: 0;
  font-weight: 800;
}

.login-brand-block > p:not(.login-powered) {
  max-width: 520px;
  margin: 20px 0 0;
  color: #667085;
  font-size: 16px;
  line-height: 1.75;
}

.login-brand-line {
  width: min(420px, 80%);
  height: 1px;
  margin-top: 36px;
  background: #cfd8e5;
}

.login-powered {
  margin: 16px 0 0;
  color: #667085;
  font-size: 13px;
  line-height: 1.6;
}

body .login-panel {
  width: 100%;
  display: block;
  padding: 30px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, .08);
  backdrop-filter: none;
}

.login-heading {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
}

.login-heading span {
  color: #667085;
  font-size: 13px;
}

.login-heading strong {
  color: #08111f;
  font-size: 24px;
  line-height: 1.2;
}

body .login-form {
  display: grid;
  gap: 10px;
}

body .login-form label {
  margin-top: 4px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

body .login-form input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid #dce4ec;
  border-radius: 10px;
  background: #fcfdff;
  color: #101828;
  font-size: 14px;
}

body .login-form input:focus {
  border-color: rgba(37, 99, 235, .52);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .08);
}

.login-form-note {
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #667085;
  font-size: 12px;
}

body .login-form .primary-btn {
  min-height: 50px;
  margin-top: 2px;
  border-radius: 10px;
}

body .login-actions-row {
  min-height: 56px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #edf2f7;
}

.login-actions-row .line-btn {
  min-height: 38px;
  padding: 0 14px;
}

.powered-by {
  color: #667085;
  font-size: 12px;
  font-weight: 400;
}

.login-corner {
  justify-self: end;
  color: #7b8797;
  font-size: 12px;
  line-height: 1.5;
  text-align: right;
}

.login-corner strong {
  color: #344054;
}

body .login-help {
  display: none;
}

/* In-message video meeting */
.chat-meeting-entry {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  white-space: nowrap;
}

.video-call-icon {
  width: 15px;
  height: 11px;
  display: inline-block;
  position: relative;
  border: 1.8px solid currentColor;
  border-radius: 3px;
}

.video-call-icon::after {
  content: "";
  position: absolute;
  top: 1px;
  right: -6px;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid currentColor;
}

.chat-meeting-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(7, 17, 30, .72);
}

.chat-meeting-dialog {
  width: min(1080px, 100%);
  max-height: calc(100dvh - 48px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid #26364c;
  border-radius: 12px;
  background: #07111e;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .32);
}

.chat-meeting-head {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 18px;
  border-bottom: 1px solid #26364c;
  background: #0d1828;
}

.chat-meeting-head h2,
.chat-meeting-head p {
  margin: 0;
}

.chat-meeting-head h2 {
  margin-top: 3px;
  color: #f8fafc;
  font-size: 20px;
}

.chat-meeting-head p {
  margin-top: 4px;
  color: #aebbd0;
  font-size: 12px;
}

.chat-meeting-head .line-btn {
  border-color: #40516b;
  background: #172338;
  color: #f7f9fc;
}

.chat-meeting-stage {
  min-height: 0;
  height: min(690px, calc(100dvh - 124px));
  padding: 18px;
  overflow-y: auto;
  border-radius: 0;
}

body.chat-meeting-open {
  overflow: hidden;
}

.im-meeting-card {
  border-color: rgba(37, 99, 235, .28);
  background: #f7faff;
}

.inline-upload-form {
  min-height: 52px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.inline-upload-form input[type="file"] {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.payment-history {
  display: grid;
  gap: 6px;
  padding-top: 4px;
}

.payment-history p {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 6px 10px;
  border-left: 2px solid var(--primary);
  background: #f8fafc;
  font-size: 12px;
}

.payment-history span {
  color: var(--muted);
  text-align: right;
}

@media (max-width: 980px) {
  body .login-view {
    padding: 22px;
  }

  .login-main {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
    padding: 36px 0;
  }

  .login-brand-block h1 {
    font-size: 52px;
  }

  body .login-panel {
    max-width: 460px;
  }
}

@media (max-width: 640px) {
  body .login-view {
    min-height: 100dvh;
    grid-template-rows: auto minmax(0, 1fr);
    padding: max(18px, env(safe-area-inset-top, 0px)) 18px max(18px, env(safe-area-inset-bottom, 0px));
  }

  .login-topbar {
    min-height: 44px;
  }

  .login-platform-brand span {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .login-main {
    align-content: start;
    gap: 26px;
    padding: 34px 0 22px;
  }

  .login-brand-block {
    text-align: left;
  }

  .login-brand-block h1 {
    font-size: 44px;
  }

  .login-brand-block > p:not(.login-powered) {
    display: block;
    margin-top: 14px;
    font-size: 14px;
    line-height: 1.65;
  }

  .login-brand-line {
    width: 72%;
    margin-top: 24px;
  }

  .login-powered {
    display: block;
    margin-top: 11px;
    font-size: 12px;
  }

  body .login-brand-block > #loginSubtitle,
  body .login-brand-block > #loginPowered {
    display: block;
  }

  body .login-panel {
    max-width: none;
    padding: 20px;
  }

  .login-heading {
    margin-bottom: 16px;
  }

  .login-heading strong {
    font-size: 20px;
  }

  body .login-form input,
  body .login-form .primary-btn {
    min-height: 48px;
  }

  body .login-actions-row {
    align-items: center;
  }

  .login-corner {
    display: none;
  }

  .chat-header-actions {
    gap: 6px;
  }

  .chat-meeting-entry {
    min-width: 42px;
    padding: 0 10px;
  }

  .chat-meeting-overlay {
    place-items: stretch;
    padding: 0;
  }

  .chat-meeting-dialog {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  .chat-meeting-head {
    padding: max(12px, env(safe-area-inset-top, 0px)) 14px 12px;
  }

  .chat-meeting-head h2 {
    font-size: 16px;
  }

  .chat-meeting-head p {
    display: none;
  }

  .chat-meeting-stage {
    height: auto;
    min-height: 0;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  }

  .inline-upload-form {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Meeting shell overrides stay last so legacy classroom styles cannot win. */
body .chat-meeting-overlay {
  padding: 18px;
  background: rgba(4, 10, 19, .82);
}

body .chat-meeting-dialog {
  width: min(1420px, 100%);
  height: min(900px, calc(100dvh - 36px));
  max-height: none;
  grid-template-rows: auto minmax(0, 1fr);
  background: #081321;
}

body .chat-meeting-stage {
  height: auto;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto auto;
  gap: 12px;
  padding: 14px;
  overflow: hidden;
}

body .chat-meeting-overlay .classroom-video-grid {
  min-height: 0;
  max-height: none;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  grid-auto-rows: minmax(190px, 1fr);
  gap: 10px;
  margin: 0;
  padding: 12px;
}

body .chat-meeting-overlay.meeting-floating {
  pointer-events: none;
  background: transparent;
}

body .meeting-floating .chat-meeting-dialog {
  position: fixed;
  right: 20px;
  bottom: 20px;
  left: auto;
  top: auto;
  width: min(540px, calc(100vw - 32px));
  height: 350px;
  pointer-events: auto;
}

body .meeting-floating .chat-meeting-stage {
  display: block;
  height: 100%;
  padding: 0;
}

body .meeting-floating .classroom-video-grid {
  height: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  padding: 8px;
}

body .meeting-floating-compact .chat-meeting-dialog {
  width: min(320px, calc(100vw - 24px));
  height: 58px;
}

/* Cloud classroom acceptance: keep the live meeting conversation visible
   while the lesson is fullscreen. These rules intentionally stay at the end
   of the meeting shell so older mobile fallbacks cannot turn the workspace
   into a long page that requires leaving fullscreen to reach chat. */
body .chat-meeting-dialog:fullscreen .meeting-workspace,
body .chat-meeting-dialog:-webkit-full-screen .meeting-workspace,
body .chat-meeting-dialog.meeting-fullscreen-dialog .meeting-workspace {
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) clamp(280px, 28vw, 380px);
}

body .chat-meeting-dialog:fullscreen .meeting-side-panel,
body .chat-meeting-dialog:-webkit-full-screen .meeting-side-panel,
body .chat-meeting-dialog.meeting-fullscreen-dialog .meeting-side-panel {
  display: grid;
  min-height: 0;
}

@media (max-width: 700px) and (orientation: portrait) {
  body .chat-meeting-overlay:not(.meeting-floating) .chat-meeting-stage {
    position: relative;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto auto;
    gap: 8px;
    padding: 0 8px max(8px, env(safe-area-inset-bottom, 0px));
    overflow: hidden;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-workspace,
  body .chat-meeting-dialog:fullscreen .meeting-workspace,
  body .chat-meeting-dialog:-webkit-full-screen .meeting-workspace,
  body .chat-meeting-dialog.meeting-fullscreen-dialog .meeting-workspace {
    position: relative;
    display: block;
    min-height: 0;
    overflow: hidden;
    border-radius: 8px;
    background: #030912;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-video-area {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-side-panel,
  body .chat-meeting-dialog:fullscreen .meeting-side-panel,
  body .chat-meeting-dialog:-webkit-full-screen .meeting-side-panel,
  body .chat-meeting-dialog.meeting-fullscreen-dialog .meeting-side-panel {
    position: absolute;
    z-index: 12;
    right: 0;
    bottom: 0;
    left: 0;
    height: min(40%, 260px);
    min-height: 168px;
    margin: 0;
    display: grid;
    border: 0;
    border-radius: 0;
    background: linear-gradient(to top, rgba(4, 10, 18, .98) 0%, rgba(4, 10, 18, .84) 78%, rgba(4, 10, 18, .5) 100%);
    backdrop-filter: blur(5px);
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-stage-head,
  body .chat-meeting-overlay:not(.meeting-floating) .meeting-chat-privacy {
    display: none;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .classroom-video-grid {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none !important;
    padding: 0;
    overflow: hidden;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-chat-messages {
    min-height: 0;
    padding: 6px 10px;
    overflow-y: auto;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-chat-composer {
    padding: 7px 8px;
    background: rgba(4, 10, 18, .88);
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-controls {
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 6px;
    margin: 0;
    padding: 7px;
    overflow-x: auto;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-controls button,
  body .chat-meeting-overlay:not(.meeting-floating) .meeting-controls select {
    min-width: 82px;
    min-height: 44px;
    flex: 0 0 auto;
    margin: 0;
  }
}

@media (max-width: 950px) and (max-height: 600px) and (orientation: landscape) {
  body .chat-meeting-overlay:not(.meeting-floating) .chat-meeting-stage {
    position: relative;
    display: block;
    padding: 8px;
    overflow: hidden;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-workspace,
  body .chat-meeting-dialog:fullscreen .meeting-workspace,
  body .chat-meeting-dialog:-webkit-full-screen .meeting-workspace,
  body .chat-meeting-dialog.meeting-fullscreen-dialog .meeting-workspace {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(250px, 34vw);
    gap: 8px;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-side-panel,
  body .chat-meeting-dialog:fullscreen .meeting-side-panel,
  body .chat-meeting-dialog:-webkit-full-screen .meeting-side-panel,
  body .chat-meeting-dialog.meeting-fullscreen-dialog .meeting-side-panel {
    position: static;
    height: 100%;
    min-height: 0;
    margin: 0;
    display: grid;
  }
}

@media (max-width: 640px) {
  body .chat-meeting-overlay {
    padding: 0;
  }

  body .chat-meeting-dialog {
    width: 100%;
    height: 100dvh;
  }

  body .meeting-floating .chat-meeting-dialog {
    right: 10px;
    bottom: 10px;
    width: min(420px, calc(100vw - 20px));
    height: 290px;
  }

  body .chat-meeting-stage {
    display: block;
    overflow-y: auto;
  }

  body .meeting-workspace {
    display: block;
  }

  body .meeting-video-area {
    min-height: 330px;
  }

  body .meeting-side-panel {
    min-height: 300px;
    margin-top: 12px;
  }

  body .chat-meeting-overlay .classroom-video-grid {
    min-height: 260px;
  }

  body .chat-meeting-overlay .video-tile,
  body .chat-meeting-overlay .video-empty {
    min-height: 220px;
  }

  body .meeting-controls {
    margin-top: 12px;
  }
}

/* Focus mode: one complete main picture with switchable thumbnails below. */
body .chat-meeting-overlay:not(.meeting-floating) .classroom-video-grid.has-focus {
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  grid-template-rows: minmax(300px, 1fr) 108px;
  grid-auto-rows: 108px;
  align-content: stretch;
  overflow: hidden;
}

body .chat-meeting-overlay:not(.meeting-floating) #classroomMeetingStage .classroom-video-grid.has-focus .video-tile.focus {
  grid-column: 1 / -1;
  grid-row: 1;
  width: auto;
  max-width: 100%;
  min-height: 0;
  height: 100%;
  aspect-ratio: 16 / 9;
  justify-self: center;
  z-index: 2;
}

body .chat-meeting-overlay:not(.meeting-floating) #classroomMeetingStage .classroom-video-grid.has-focus .video-tile:not(.focus) {
  grid-row: 2;
  min-height: 0;
  height: 108px;
  aspect-ratio: 16 / 9;
  z-index: 1;
}

body .chat-meeting-overlay:not(.meeting-floating) .classroom-video-grid.has-focus .video-tile.focus > div[id],
body .chat-meeting-overlay:not(.meeting-floating) .classroom-video-grid.has-focus .video-tile.focus video {
  object-fit: cover !important;
  background: #030912;
}

body .chat-meeting-overlay:not(.meeting-floating) .classroom-video-grid.has-focus .video-tile.focus[data-stream-type="screen"] > div[id],
body .chat-meeting-overlay:not(.meeting-floating) .classroom-video-grid.has-focus .video-tile.focus[data-stream-type="screen"] video {
  object-fit: contain !important;
}

body .chat-meeting-overlay:not(.meeting-floating) .classroom-video-grid.has-focus .video-tile:not(.focus) .meeting-member-meta {
  padding: 18px 8px 6px;
}

body .chat-meeting-overlay:not(.meeting-floating) .classroom-video-grid.has-focus .video-tile:not(.focus) .meeting-member-meta span {
  display: none;
}

body .chat-meeting-overlay:not(.meeting-floating) .classroom-video-grid.has-focus .video-tile:not(.focus) .meeting-avatar {
  width: 44px !important;
  height: 44px !important;
  font-size: 18px;
}

body .meeting-floating #classroomMeetingStage .video-tile {
  cursor: default;
}

@media (max-width: 640px) {
  body .chat-meeting-overlay:not(.meeting-floating) .classroom-video-grid.has-focus {
    grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
    grid-template-rows: 300px 82px;
    grid-auto-rows: 82px;
    min-height: 410px;
    overflow-x: auto;
  }

  body .chat-meeting-overlay:not(.meeting-floating) #classroomMeetingStage .classroom-video-grid.has-focus .video-tile:not(.focus) {
    height: 82px;
  }
}

/* Final compact-bar sizing override. */
body .meeting-floating-compact .chat-meeting-dialog {
  width: min(400px, calc(100vw - 24px));
  height: 56px;
  min-height: 56px;
}

body .meeting-floating-compact .chat-meeting-head {
  width: 100%;
  min-height: 56px;
  padding: 8px 10px 8px 12px;
}

body .meeting-floating-compact .meeting-title-block,
body .meeting-floating-compact .meeting-title-block > div {
  min-width: 0;
}

body .meeting-floating-compact .chat-meeting-head h2 {
  max-width: 100%;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body .meeting-floating-compact .meeting-floating-actions {
  flex: 0 0 auto;
  gap: 6px;
}

body .meeting-floating-compact .meeting-floating-actions button {
  width: auto;
  min-width: 0;
  padding: 0 10px;
  white-space: nowrap;
}

/* Final mobile cloud-classroom precedence. */
@media (max-width: 700px) and (orientation: portrait) {
  body .chat-meeting-overlay:not(.meeting-floating) .chat-meeting-stage {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto auto;
    overflow: hidden;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-workspace,
  body .chat-meeting-dialog:fullscreen .meeting-workspace,
  body .chat-meeting-dialog:-webkit-full-screen .meeting-workspace,
  body .chat-meeting-dialog.meeting-fullscreen-dialog .meeting-workspace {
    position: relative;
    display: block;
    min-height: 0;
    overflow: hidden;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-video-area {
    height: 100%;
    min-height: 0;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-side-panel,
  body .chat-meeting-dialog:fullscreen .meeting-side-panel,
  body .chat-meeting-dialog:-webkit-full-screen .meeting-side-panel,
  body .chat-meeting-dialog.meeting-fullscreen-dialog .meeting-side-panel {
    position: absolute;
    z-index: 12;
    right: 0;
    bottom: 0;
    left: 0;
    height: min(40%, 260px);
    min-height: 168px;
    margin: 0;
    display: grid;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .classroom-video-grid {
    height: 100%;
    min-height: 0;
    max-height: none !important;
  }
}

@media (max-width: 950px) and (max-height: 600px) and (orientation: landscape) {
  body .chat-meeting-overlay:not(.meeting-floating) .meeting-workspace,
  body .chat-meeting-dialog:fullscreen .meeting-workspace,
  body .chat-meeting-dialog:-webkit-full-screen .meeting-workspace,
  body .chat-meeting-dialog.meeting-fullscreen-dialog .meeting-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(250px, 34vw);
    min-height: 0;
  }

  body .chat-meeting-overlay:not(.meeting-floating) .meeting-side-panel,
  body .chat-meeting-dialog:fullscreen .meeting-side-panel,
  body .chat-meeting-dialog:-webkit-full-screen .meeting-side-panel,
  body .chat-meeting-dialog.meeting-fullscreen-dialog .meeting-side-panel {
    position: static;
    height: 100%;
    min-height: 0;
    margin: 0;
    display: grid;
  }
}

