/* styles.css — 一对一教室（重设计 v2）
   全部色彩/间距/圆角/动效走 design-tokens.css 的 CSS 变量；组件内零裸色值（P0-B3）。
   布局：A 顶栏 / B 主舞台 / C 课件控制条 / D 聊天 / E 老师工作台。师生同骨架，差异仅角色门控。 */

/* ===== Reset & base ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--fg);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
.hidden { display: none !important; }

/* ===== 通用按钮（token 化） ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  border: 1px solid transparent; border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-base); font-weight: var(--font-weight-medium);
  transition: background var(--motion-base) var(--motion-ease), border-color var(--motion-base) var(--motion-ease), color var(--motion-base) var(--motion-ease);
  min-height: 40px;
}
.btn i { width: 20px; height: 20px; }
.btn-sm { padding: var(--space-1) var(--space-3); min-height: 32px; font-size: var(--font-size-sm); }
.btn-sm i { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: var(--accent-on); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-active); }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--border); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #B91C1C; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent); }

/* ===== A. 顶栏 ===== */
.topbar {
  height: 56px; flex: 0 0 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-4);
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.brand-mark {
  width: 32px; height: 32px; border-radius: var(--radius-md);
  background: var(--accent); color: var(--accent-on);
  display: flex; align-items: center; justify-content: center;
}
.brand-mark i { width: 20px; height: 20px; }
.brand-mark .brand-logo-img { height: 32px; width: auto; border-radius: var(--radius-sm); display: block; }
.brand-name { font-weight: var(--font-weight-bold); font-size: var(--font-size-md); }
.class-title { color: var(--fg-2); font-size: var(--font-size-base); font-weight: var(--font-weight-medium);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw; }
.topbar-right { display: flex; align-items: center; gap: var(--space-3); }
.conn { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--font-size-sm); color: var(--muted); }
.conn i { width: 16px; height: 16px; }
.conn.online { color: var(--success); }
.conn.offline { color: var(--danger); }
.conn-text { font-size: var(--font-size-sm); }
.role-badge {
  font-size: var(--font-size-xs); font-weight: var(--font-weight-medium);
  padding: 2px var(--space-2); border-radius: var(--radius-full);
  background: var(--accent-soft); color: var(--accent); letter-spacing: var(--font-tracking-caps);
}
.btn-exit { color: var(--fg-2); border-color: var(--border); background: var(--surface); }
.btn-exit:hover { color: var(--danger); border-color: var(--danger); background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }

/* ===== 开课提醒条 ===== */
.reminder-banner {
  flex: 0 0 auto; padding: var(--space-2) var(--space-4);
  background: var(--accent-2-soft); color: var(--accent-2);
  font-size: var(--font-size-sm); text-align: center;
}

/* ===== 主体两列 ===== */
.workbench { flex: 1 1 auto; display: flex; min-height: 0; }
.stage-col { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* ===== B. 主舞台 ===== */
.stage { position: relative; flex: 1 1 auto; min-height: 0; background: var(--stage-bg); overflow: hidden; }
.stage-courseware, .stage-remote, .stage-placeholder {
  position: absolute; inset: 0; width: 100%; height: 100%;
}
.stage-courseware { display: flex; align-items: center; justify-content: center; background: var(--stage-bg); }
.content-image, .content-video { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: relative; }
.content-display-img, .content-display-video { max-width: 100%; max-height: 100%; object-fit: contain; }
/* 学生视频操控按钮：浮动在视频右上角 */
.video-overlay-btn {
  position: absolute; z-index: 10;
  width: 32px; height: 32px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.55); color: #fff;
  font-size: 20px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s;
}
.video-close-btn { top: 8px; right: 8px; }
.video-fullscreen-btn { top: 8px; right: 46px; }
.content-video:hover .video-overlay-btn,
.video-overlay-btn:focus-visible { opacity: 1; }
.content-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2); color: var(--stage-fg); opacity: .7; text-align: center; padding: var(--space-4); }
.content-placeholder-icon i { width: 48px; height: 48px; }
.content-placeholder-title { font-size: var(--font-size-md); font-weight: var(--font-weight-medium); }
.content-placeholder-sub { font-size: var(--font-size-sm); opacity: .8; }

/* 对方实时画面：默认铺满；推课件时收为 PiP（右上角） */
.stage-remote { object-fit: cover; background: var(--stage-bg); }
.stage-remote.pip-mode {
  inset: auto; top: var(--space-3); right: var(--space-3); left: auto; bottom: auto;
  width: 28%; height: 28%; max-width: 240px; max-height: 160px;
  object-fit: cover; border-radius: var(--radius-md);
  border: 1px solid var(--stage-border); box-shadow: var(--shadow-raised);
}

/* 占位（对方未开摄像头 / 未进房） */
.stage-placeholder { display: flex; align-items: center; justify-content: center; background: var(--stage-bg); }
.stage-preset-img { width: 100%; height: 100%; object-fit: contain; }
.stage-fallback { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); color: var(--stage-fg); }
.stage-fallback-av {
  width: 72px; height: 72px; border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--font-size-2xl); font-weight: var(--font-weight-bold); color: #fff; background: var(--accent);
}
.stage-fallback-name { font-size: var(--font-size-md); font-weight: var(--font-weight-medium); }
.stage-fallback-sub { font-size: var(--font-size-sm); opacity: .8; }

/* 本人自视图 PiP（右上角） */
.self-pip {
  position: absolute; right: var(--space-3); top: var(--space-3); bottom: auto;
  width: 28%; height: 28%; max-width: 240px; max-height: 160px;
  border-radius: var(--radius-md); overflow: hidden;
  border: 1px solid var(--stage-border); box-shadow: var(--shadow-raised); background: #000;
}
/* 推课件 + 双方摄像头都开：远端(对方)在上，自视图在下，避免重叠 */
.stage.dual-pip .self-pip {
  top: calc(var(--space-3) + 28% + var(--space-2));
}
.stage-self { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.pip-label {
  position: absolute; left: var(--space-2); bottom: var(--space-1);
  font-size: var(--font-size-xs); color: var(--stage-fg);
  background: rgba(0,0,0,.45); padding: 1px var(--space-2); border-radius: var(--radius-full);
}
/* 悬浮倒计时：画面左上，类似 PiP 浮层，老师推送后双方可见 */
.float-timer[hidden] { display: none !important; }
.float-timer {
  position: absolute; left: var(--space-3); top: var(--space-3);
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  background: rgba(17,24,39,.82); color: #fff;
  box-shadow: var(--shadow-raised); z-index: 20;
  font-variant-numeric: tabular-nums;
}
.float-timer i { width: 18px; height: 18px; opacity: .85; }
.float-timer-time { font-size: var(--font-size-lg); font-weight: 700; letter-spacing: .5px; }
.float-timer-close { display: none; border: none; background: transparent; color: #fff; cursor: pointer; padding: 2px; border-radius: 50%; }
.float-timer-close:hover { background: rgba(255,255,255,.18); }
.float-timer-close[data-teacher] { display: inline-flex; }

/* 学生举手 FAB */
.raise-hand-fab { position: absolute; left: 50%; bottom: var(--space-4); transform: translateX(-50%); }
.raise-hand-fab .btn.active { background: var(--accent-2); }

/* ===== C. 课件控制条 ===== */
.courseware-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-3) var(--space-4); background: var(--surface); border-top: 1px solid var(--border);
}
.cw-switch { display: inline-flex; gap: var(--space-1); background: var(--surface-2); padding: 3px; border-radius: var(--radius-md); }
.cs-btn {
  display: inline-flex; align-items: center; gap: var(--space-1);
  border: none; background: transparent; color: var(--fg-2);
  padding: var(--space-1) var(--space-3); border-radius: var(--radius-sm);
  font-size: var(--font-size-sm); font-weight: var(--font-weight-medium);
  transition: background var(--motion-base) var(--motion-ease), color var(--motion-base) var(--motion-ease);
}
.cs-btn i { width: 16px; height: 16px; }
.cs-btn.cs-active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-raised); }
.cw-hint { font-size: var(--font-size-sm); color: var(--muted); }
.cw-url { display: inline-flex; gap: var(--space-2); flex: 1 1 240px; min-width: 200px; }
.cw-url-input {
  flex: 1 1 auto; min-width: 0; padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface);
  font-size: var(--font-size-sm); color: var(--fg);
}
.cw-url-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.video-pause-bar { display: inline-flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; width: 100%; }
.vp-current { font-family: var(--font-family-mono); font-size: var(--font-size-sm); color: var(--fg-2); }
.vp-list { display: inline-flex; gap: var(--space-1); flex-wrap: wrap; }
.vp-chip {
  display: inline-flex; align-items: center; gap: 2px;
  font-family: var(--font-family-mono); font-size: var(--font-size-xs);
  background: var(--accent-2-soft); color: var(--accent-2);
  padding: 2px var(--space-2); border-radius: var(--radius-full);
}
.vp-chip.active { background: var(--accent-2); color: #fff; }
.vp-chip button { border: none; background: transparent; color: inherit; display: inline-flex; padding: 0; }
.vp-chip button i { width: 12px; height: 12px; }

/* ===== 右列：E + D ===== */
.side-col { flex: 0 0 360px; width: 360px; display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--border); }

/* E. 老师工作台 */
.teacher-tools { flex: 0 0 auto; padding: var(--space-3); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.tt-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); }
.tt-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-1);
  padding: var(--space-2) var(--space-1); border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); color: var(--fg-2); font-size: var(--font-size-xs); font-weight: var(--font-weight-medium);
  transition: background var(--motion-base) var(--motion-ease), color var(--motion-base) var(--motion-ease), border-color var(--motion-base) var(--motion-ease);
}
.tt-btn i { width: 24px; height: 24px; }
.tt-btn:hover { background: var(--accent-soft); color: var(--accent); }
.tt-btn.active { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }
.tt-btn.ghost-soft { color: var(--muted); }
.av-status { text-align: center; font-size: var(--font-size-xs); color: var(--muted); margin-top: var(--space-2); min-height: 18px; }
.timer-panel { margin-top: var(--space-3); padding: var(--space-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
.sw-display { font-family: var(--font-family-mono); font-size: var(--font-size-2xl); text-align: center; color: var(--fg); margin-bottom: var(--space-2); }
.sw-buttons { display: flex; gap: var(--space-2); justify-content: center; margin-bottom: var(--space-3); }
.reminder-box { display: flex; flex-direction: column; gap: var(--space-2); }
.reminder-title { font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); color: var(--fg-2); }
.reminder-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); font-size: var(--font-size-sm); color: var(--fg-2); }
.reminder-row input { width: 72px; padding: var(--space-1) var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.rem-status { font-size: var(--font-size-xs); color: var(--muted); }
.countdown-box { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--border); }
.cd-buttons { display: flex; gap: var(--space-2); }

/* D. 聊天 */
.chat { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.chat-header-row { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.chat-title { font-size: var(--font-size-base); font-weight: var(--font-weight-medium); }
.chat-sub { font-size: var(--font-size-xs); color: var(--muted); display: inline-flex; align-items: center; gap: var(--space-1); }
.drawer-handle { display: none; margin-left: auto; border: none; background: transparent; color: var(--fg-2); }
.drawer-handle i { width: 20px; height: 20px; }
.chat-messages { flex: 1 1 auto; overflow-y: auto; padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.chat-msg { display: flex; gap: var(--space-2); max-width: 85%; }
/* 左右只看"是不是我发的"：我发的靠右，对方靠左（不随角色变） */
.chat-msg.chat-mine { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg.chat-other { align-self: flex-start; }
.chat-avatar { flex: 0 0 auto; width: 32px; height: 32px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; font-size: var(--font-size-sm); font-weight: var(--font-weight-bold); color: #fff; }
.chat-avatar.teacher { background: var(--accent); }
.chat-avatar.student { background: var(--accent-2); }
.chat-body { display: flex; flex-direction: column; gap: 2px; }
.chat-meta { display: flex; gap: var(--space-2); font-size: var(--font-size-xs); color: var(--muted); }
.chat-mine .chat-meta { flex-direction: row-reverse; }
.chat-text { background: var(--surface-2); padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); font-size: var(--font-size-sm); line-height: 1.5; color: var(--fg); word-break: break-word; }
/* 气泡配色按角色（与左右无关） */
.chat-role-teacher .chat-text { background: var(--accent-soft); }
.chat-role-student .chat-text { background: var(--accent-2-soft); }
.chat-system { align-self: center; max-width: 90%; }
.chat-system .chat-text { background: transparent; color: var(--muted); font-size: var(--font-size-xs); text-align: center; }
.chat-input-row { display: flex; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); position: relative; }
.chat-input { flex: 1 1 auto; min-width: 0; padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg); font-size: var(--font-size-sm); color: var(--fg); }
.chat-tool { flex: 0 0 auto; width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); color: var(--muted); cursor: pointer; transition: background var(--motion-ease) var(--motion-dur), color var(--motion-ease) var(--motion-dur); }
.chat-tool:hover { background: var(--surface-2); color: var(--accent); }
.chat-tool i { width: 18px; height: 18px; }
/* 表情面板 */
.emoji-pop[hidden] { display: none !important; }
.emoji-pop { position: absolute; right: var(--space-3); bottom: calc(100% + 6px); width: 264px; max-height: 200px; overflow-y: auto; display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; padding: var(--space-2); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-raised); z-index: 30; }
.emoji-item { border: none; background: transparent; font-size: 20px; line-height: 1; padding: 4px 0; cursor: pointer; border-radius: var(--radius-sm); }
.emoji-item:hover { background: var(--surface-2); }
/* 聊天图片气泡 */
.chat-img { display: block; max-width: 200px; max-height: 200px; width: auto; height: auto; border-radius: var(--radius-md); border: 1px solid var(--border); cursor: zoom-in; object-fit: cover; background: var(--surface-2); }
.chat-img-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.82); display: flex; align-items: center; justify-content: center; z-index: 60; padding: var(--space-4); cursor: zoom-out; }
.chat-img-lightbox img { max-width: 92vw; max-height: 88vh; border-radius: var(--radius-md); box-shadow: var(--shadow-raised); }
/* 课后聊天记录弹窗 */
.history-modal { max-width: 480px; width: 92vw; display: flex; flex-direction: column; }
.history-sub { color: var(--muted); font-size: var(--font-size-xs); margin: 2px 0 10px; }
.history-messages { max-height: 62vh; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-2) 2px; }
.history-messages .empty-sub { padding: 24px 0; text-align: center; }
.chat-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.chat-send { padding: var(--space-2); }
.chat-send i { width: 20px; height: 20px; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: var(--space-6); transform: translateX(-50%) translateY(8px);
  background: var(--fg); color: var(--surface); padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md); font-size: var(--font-size-sm); box-shadow: var(--shadow-raised);
  opacity: 0; transition: opacity var(--motion-base) var(--motion-ease), transform var(--motion-base) var(--motion-ease); z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 头像调色板（兼容 auth.js 既有类名） ===== */
.avatar-indigo { background: #4F46E5; } .avatar-amber { background: #D97706; }
.avatar-violet { background: #7C3AED; } .avatar-rose { background: #E11D48; }
.avatar-emerald { background: #059669; } .avatar-sky { background: #0284C7; }
.avatar-teal { background: #0D9488; } .avatar-fuchsia { background: #C026D3; }
.avatar { color: #fff; }

/* 连接状态点 */
.online-dot { width: 8px; height: 8px; border-radius: var(--radius-full); background: var(--success); display: inline-block; }
.rec-dot { width: 8px; height: 8px; border-radius: var(--radius-full); background: var(--danger); display: inline-block; }

/* ===== 响应式：三档断点（DESIGN §5） =====
   desktop >=1024：双列工作台（默认）
   tablet 640-1023 / phone <640：单列纵向栈，聊天收为底部抽屉 */
@media (max-width: 1023px) {
  .workbench { flex-direction: column; }
  .side-col { flex: 0 0 auto; width: 100%; border-left: none; border-top: 1px solid var(--border); max-height: 45vh; }
  .class-title { max-width: 30vw; }
  /* 聊天默认收为抽屉（仅 peek），展开后显示 */
  .drawer-handle { display: inline-flex; }
  .chat:not(.drawer-open) .chat-messages,
  .chat:not(.drawer-open) .chat-input-row { display: none; }
  .chat:not(.drawer-open) { flex: 0 0 auto; }
  /* 老师工作台在窄屏横向滚动，避免挤占 */
  .teacher-tools { overflow-x: auto; }
  .tt-grid { min-width: 320px; }
  .stage-remote.pip-mode, .self-pip { width: 36%; height: 26%; }
}
@media (max-width: 639px) {
  .topbar { padding: 0 var(--space-3); }
  .brand-name { display: none; }
  .conn-text { display: none; }
  .class-title { max-width: 40vw; font-size: var(--font-size-sm); }
  .btn-exit span { display: none; }
  .courseware-bar { gap: var(--space-2); padding: var(--space-2) var(--space-3); }
  .cw-hint { display: none; }
  .side-col { max-height: 55vh; }
  .tt-grid { grid-template-columns: repeat(4, 1fr); }
  .raise-hand-fab { bottom: var(--space-3); }
}

/* 触屏：放大可点击区域 */
@media (pointer: coarse) {
  .tt-btn { min-height: 48px; }
  .btn { min-height: 44px; }
}

/* ===== 学生操作条（仅学生，desktop 在左列底部 / mobile 吸底） ===== */
.student-bar {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-around; gap: var(--space-2);
  padding: var(--space-2) var(--space-4); background: var(--surface); border-top: 1px solid var(--border);
}
.sb-btn {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface);
  color: var(--fg-2); font-size: var(--font-size-xs); font-weight: var(--font-weight-medium);
  padding: var(--space-2) var(--space-3); min-width: 64px;
  transition: background var(--motion-base) var(--motion-ease), color var(--motion-base) var(--motion-ease), border-color var(--motion-base) var(--motion-ease);
}
.sb-btn i { width: 22px; height: 22px; }
.sb-btn.active { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }
.sb-hand.active { background: var(--accent-2); border-color: var(--accent-2); }
.sb-chat { color: var(--accent); }

/* ===== 通用补充（auth/me/admin 页面依赖） ===== */
.btn-block { width: 100%; }
.select-input {
  width: 100%; padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); font-size: var(--font-size-base); color: var(--fg);
  font-family: inherit; min-height: 40px;
}
.select-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }

/* 表单字段（登录 / 弹窗 共用） */
.form-field { margin-bottom: var(--space-3); }
.form-label { display: block; font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); color: var(--fg-2); margin-bottom: var(--space-1); }
.input-wrap { position: relative; display: flex; align-items: center; }
.form-input {
  width: 100%; padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); font-size: var(--font-size-base); color: var(--fg);
  font-family: inherit; min-height: 40px; transition: border-color var(--motion-base) var(--motion-ease);
}
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.form-input.is-error { border-color: var(--danger); }
.input-wrap.has-lead .form-input { padding-left: 38px; }
.lead-icon { position: absolute; left: 10px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.icon-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--muted);
  width: 32px; height: 32px; border-radius: var(--radius-sm); cursor: pointer;
}
.icon-btn:hover { color: var(--fg); background: var(--surface-2); }
.inline-error { font-size: var(--font-size-xs); color: var(--danger); margin-top: var(--space-1); }
.auth-error {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); margin-bottom: var(--space-3);
  background: var(--color-danger-soft, #fef2f2); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: var(--radius-md); font-size: var(--font-size-sm); color: var(--danger);
}
.check-row { display: flex; align-items: center; gap: var(--space-2); font-size: var(--font-size-sm); color: var(--fg-2); cursor: pointer; }
.check-row input { width: 16px; height: 16px; }
.loader {
  display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spin-on { animation: spin 0.8s linear infinite; }

/* ===== 登录页 ===== */
.auth-page { display: flex; min-height: 100vh; }
.auth-brand {
  flex: 0 0 40%; background: var(--color-bg-inverse); color: var(--color-text-inverse);
  display: flex; flex-direction: column; justify-content: center; padding: var(--space-8, 48px);
}
.auth-brand .brand-mark { width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; margin-bottom: var(--space-4); }
.auth-brand .brand-mark i { width: 24px; height: 24px; }
.auth-brand-title { font-size: 24px; font-weight: 700; margin-top: var(--space-3); }
.auth-brand-sub { font-size: var(--font-size-base); opacity: .7; margin-top: var(--space-1); }
.auth-value-list { list-style: none; padding: 0; margin: var(--space-6) 0 0; display: flex; flex-direction: column; gap: var(--space-3); }
.auth-value-list li { display: flex; align-items: center; gap: var(--space-2); font-size: var(--font-size-sm); opacity: .8; }
.v-ic { width: 18px; height: 18px; flex-shrink: 0; opacity: .7; }
.auth-form-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: var(--space-6); }
.auth-card { width: 100%; max-width: 380px; }
.auth-heading { font-size: 24px; font-weight: 700; margin: 0 0 var(--space-1); }
.auth-sub { font-size: var(--font-size-sm); color: var(--muted); margin: 0 0 var(--space-5); }
.auth-deeplink { font-size: var(--font-size-sm); color: var(--muted); text-align: center; margin-top: var(--space-4); }
.auth-deeplink strong { color: var(--accent); }

@media (max-width: 768px) {
  .auth-brand { display: none; }
  .auth-form-wrap { padding: var(--space-4); }
}

/* ===== 通用页头（me 页） ===== */
.app-header {
  display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-4);
  height: 56px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.app-header .brand-mark { width: 32px; height: 32px; }
.app-header .brand-name { font-size: var(--font-size-md); font-weight: 700; }
.spacer { flex: 1; }
.greet { font-size: var(--font-size-sm); color: var(--fg-2); }
.avatar-chip {
  width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--font-size-sm); font-weight: 700; color: #fff; flex-shrink: 0;
}

/* ===== me 页布局 ===== */
.page { flex: 1; overflow-y: auto; }
.page-body { max-width: 960px; margin: 0 auto; padding: var(--space-5) var(--space-4); }
.page-title-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 700; margin: 0; }
.title-actions { display: flex; align-items: center; gap: var(--space-2); }
.filter-row { margin-bottom: var(--space-4); }
.seg { display: inline-flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: var(--radius-md); }
.seg-btn {
  border: none; background: transparent; color: var(--fg-2);
  padding: var(--space-1) var(--space-3); border-radius: var(--radius-sm);
  font-size: var(--font-size-sm); font-weight: 500; cursor: pointer;
  transition: background var(--motion-base) var(--motion-ease), color var(--motion-base) var(--motion-ease);
}
.seg-btn.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-3); }
.session-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-2);
  transition: box-shadow var(--motion-base) var(--motion-ease);
}
.session-card:hover { box-shadow: 0 4px 12px rgba(15,23,42,.08); }
.session-card.is-canceled { opacity: .55; }
.session-title { font-size: var(--font-size-md); font-weight: 600; }
.session-meta { display: flex; align-items: center; gap: var(--space-1); font-size: var(--font-size-sm); color: var(--muted); }
.session-meta i { width: 14px; height: 14px; }
.session-foot { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; margin-top: var(--space-1); }
.enter-btn { display: inline-flex; align-items: center; gap: var(--space-1); }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px var(--space-2); border-radius: var(--radius-full);
  font-size: var(--font-size-xs); font-weight: 500;
}
.badge-live { background: var(--color-success-soft, #ecfdf5); color: var(--success); }
.badge-scheduled { background: var(--accent-soft); color: var(--accent); }
.badge-ended { background: var(--surface-2); color: var(--muted); }
.badge-canceled { background: var(--color-danger-soft, #fef2f2); color: var(--danger); }
.badge-role { background: var(--accent-soft); color: var(--accent); }
.badge-active { background: var(--color-success-soft, #ecfdf5); color: var(--success); }
.badge-disabled { background: var(--color-danger-soft, #fef2f2); color: var(--danger); }
/* 角色标签分级（用户管理）：超管实色最突出，管理员次色，老师主色，学生灰 */
.badge-super { background: var(--accent); color: var(--accent-on); font-weight: 600; }
.badge-admin { background: var(--accent-2-soft); color: var(--accent-2); }
.badge-head { background: #ede9fe; color: #7c3aed; }
.badge-academic { background: #ecfeff; color: #0e7490; }
.badge-inspector { background: var(--accent-2-soft); color: var(--accent-2); }
.badge-assistant { background: #fff7ed; color: #c2410c; }
.badge-teacher { background: var(--accent-soft); color: var(--accent); }
.badge-student { background: var(--surface-2); color: var(--muted); }
/* 用户搜索框 */
.search-box { position: relative; display: inline-flex; align-items: center; }
.search-ic { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search-input {
  padding: var(--space-2) var(--space-3) var(--space-2) 34px; min-width: 220px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); font-size: var(--font-size-sm); color: var(--fg);
}
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
/* 分页器 */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-4); flex-wrap: wrap; }
.pager-info { font-size: var(--font-size-sm); color: var(--muted); }
.pager-controls { display: inline-flex; gap: var(--space-1); flex-wrap: wrap; }
.pager-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--fg-2);
  padding: var(--space-1) var(--space-3); border-radius: var(--radius-sm);
  font-size: var(--font-size-sm); cursor: pointer; min-height: 32px;
}
.pager-btn:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.pager-btn:disabled { opacity: .5; cursor: not-allowed; }
.pager-btn.active { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }
.pager-ellipsis { color: var(--muted); padding: 0 var(--space-1); }
.pulse-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* 空状态 / 骨架屏 */
.empty-block { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-8, 48px) var(--space-4); text-align: center; }
.empty-block .ic { width: 56px; height: 56px; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.empty-block .ic i { width: 40px; height: 40px; }
.empty-title { font-size: var(--font-size-md); font-weight: 600; color: var(--fg-2); }
.empty-sub { font-size: var(--font-size-sm); color: var(--muted); }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ===== Modal（弹窗通用） ===== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: var(--color-scrim);
  display: flex; align-items: center; justify-content: center; padding: var(--space-4);
}
.modal-backdrop[hidden] { display: none !important; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg); padding: var(--space-5);
  width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(15,23,42,.3);
}
.modal-title { font-size: 18px; font-weight: 700; margin: 0 0 var(--space-4); }
.modal-text { font-size: var(--font-size-sm); color: var(--fg-2); line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-5); }

/* ===== Admin 页布局 ===== */
.admin-shell { display: flex; height: 100vh; overflow: hidden; }
.admin-side {
  flex: 0 0 220px; background: var(--color-bg-inverse); color: var(--color-text-inverse);
  display: flex; flex-direction: column; padding: var(--space-4) 0;
}
.admin-brand { display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-4) var(--space-4); }
.admin-brand .brand-mark { width: 32px; height: 32px; }
.admin-brand-name { font-size: var(--font-size-md); font-weight: 700; }
.nav-list { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0 var(--space-2); }
.nav-item {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  font-size: var(--font-size-sm); color: rgba(255,255,255,.7); cursor: pointer;
  transition: background var(--motion-base) var(--motion-ease), color var(--motion-base) var(--motion-ease);
}
.nav-item:hover { background: var(--color-overlay-tint); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-ic { width: 18px; height: 18px; }
.admin-side-foot { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--color-overlay-tint); }
.admin-content { flex: 1; overflow-y: auto; padding: var(--space-5) var(--space-6); background: var(--bg); }
.admin-view-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.admin-view-title { font-size: 20px; font-weight: 700; margin: 0; }
.admin-view[hidden] { display: none !important; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-5); }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-4); }
.stat-num { font-size: 24px; font-weight: 700; }
.stat-label { font-size: var(--font-size-sm); color: var(--muted); margin-top: var(--space-1); }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius-md); overflow: hidden; }
.data-table th { text-align: left; padding: var(--space-2) var(--space-3); font-size: var(--font-size-sm); font-weight: 600; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.data-table td { padding: var(--space-2) var(--space-3); font-size: var(--font-size-sm); border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.cell-actions { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.cell-user { display: flex; align-items: center; gap: var(--space-2); }

@media (max-width: 768px) {
  .admin-side { flex: 0 0 64px; }
  .admin-brand-name, .nav-item span:not(.nav-ic) { display: none; }
  .admin-content { padding: var(--space-3); }
}

/* ===== 课件库（#28） ===== */
/* 类型徽标（me.html 与课堂页共用视觉） */
.cw-badge {
  display: inline-flex; align-items: center; flex: none;
  padding: 2px var(--space-2); border-radius: var(--radius-full);
  font-size: var(--font-size-xs); font-weight: 500;
}
.cw-badge-image { background: var(--accent-soft); color: var(--accent); }
.cw-badge-video { background: var(--accent-2-soft); color: var(--accent-2); }
.cw-badge-pdf { background: var(--color-danger-soft, #fef2f2); color: var(--danger); }
.cw-badge-ppt { background: var(--color-success-soft, #ecfdf5); color: var(--success); }
.cw-badge-other { background: var(--surface-2); color: var(--muted); }

/* 课堂页：推送课件渲染层 */
.courseware-pane {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: var(--stage-bg); padding: var(--space-3);
}
.courseware-pane[hidden] { display: none !important; }
.courseware-media { max-width: 100%; max-height: 100%; object-fit: contain; }
.courseware-frame { width: 100%; height: 100%; border: none; background: #fff; border-radius: var(--radius-md); }
.courseware-card {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--space-5); max-width: 360px; box-shadow: var(--shadow-raised);
}
.courseware-card-title { font-size: var(--font-size-md); font-weight: 600; color: var(--fg); text-align: center; }

/* 课堂页：课件库面板（老师） */
.courseware-panel {
  margin-top: var(--space-3); padding: var(--space-3);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  max-height: 320px; display: flex; flex-direction: column; min-height: 0;
}
.courseware-panel.hidden { display: none; }
.cp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-2); }
.cp-title { font-size: var(--font-size-sm); font-weight: 600; color: var(--fg-2); }
.cp-close { border: none; background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; padding: 4px; border-radius: var(--radius-sm); }
.cp-close:hover { background: var(--surface-2); color: var(--fg); }
.cp-list { overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-2); }
.cp-empty { color: var(--muted); font-size: var(--font-size-sm); padding: var(--space-3); text-align: center; }
.cp-item {
  display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
}
.cp-item-title { flex: 1 1 160px; min-width: 0; font-size: var(--font-size-sm); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-item-meta { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--font-size-xs); color: var(--muted); }
.cp-item-actions { margin-left: auto; }

/* me.html：课件库区块（仅老师） */
.cw-lib { margin-top: var(--space-5); }
.cw-lib-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.cw-lib-title { font-size: 18px; font-weight: 700; margin: 0; }
.cw-upload { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; margin-bottom: var(--space-3); }
.cw-upload-title { flex: 1 1 220px; min-width: 180px; }
.cw-upload-file { flex: 1 1 auto; min-width: 180px; }
.cw-error { margin-bottom: var(--space-3); }
.cw-error[hidden] { display: none !important; }
.cw-list { display: flex; flex-direction: column; gap: var(--space-2); }
.cw-empty {
  color: var(--muted); font-size: var(--font-size-sm); padding: var(--space-4); text-align: center;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius-md);
}
.cw-item {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-3);
}
.cw-item-title { font-size: var(--font-size-base); font-weight: 600; flex: 1 1 200px; min-width: 0; }
.cw-item-meta { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--font-size-xs); color: var(--muted); }
.cw-item-size { color: var(--fg-2); }
.cw-item-time { color: var(--muted); }
.cw-item-actions { display: inline-flex; gap: var(--space-2); margin-left: auto; }

/* 降低动画（无障碍） */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ===== me 页：视图切换 + 月历 ===== */
.view-row { display: flex; align-items: center; margin-bottom: var(--space-4); }
.cal-wrap { margin-bottom: var(--space-5); }
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.cal-title { font-size: var(--font-size-md); font-weight: 600; color: var(--fg); }
.cal-nav { display: inline-flex; align-items: center; gap: var(--space-1); }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
  background: var(--border); border: 1px solid var(--border);
  border-radius: var(--radius-md); overflow: hidden;
}
.cal-dow { background: var(--surface-2); padding: var(--space-2); text-align: center; font-size: var(--font-size-xs); color: var(--muted); font-weight: 500; }
.cal-cell {
  background: var(--surface); min-height: 96px; padding: var(--space-1) var(--space-2);
  display: flex; flex-direction: column; gap: 3px; cursor: pointer;
  transition: background var(--motion-base) var(--motion-ease);
}
.cal-cell:hover { background: var(--accent-soft); }
.cal-cell.is-out { background: var(--surface-2); }
.cal-cell.is-out .cal-daynum { color: var(--muted); opacity: .6; }
.cal-cell.is-today .cal-daynum { color: var(--accent); font-weight: 700; }
.cal-cell.is-selected { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-daynum { font-size: var(--font-size-sm); color: var(--fg-2); font-weight: 500; line-height: 1.4; }
.cal-event {
  font-size: var(--font-size-xs); line-height: 1.35; padding: 1px 5px;
  border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-event.is-canceled { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
.cal-more { font-size: var(--font-size-xs); color: var(--muted); padding-left: 5px; }
.cal-cell.is-teacher-empty::after {
  content: '+'; margin-top: auto; align-self: flex-end; color: var(--muted);
  opacity: 0; font-size: 16px; line-height: 1; transition: opacity var(--motion-base) var(--motion-ease);
}
.cal-cell.is-teacher-empty:hover::after { opacity: .7; }

.cal-detail { margin-top: var(--space-4); border-top: 1px solid var(--border); padding-top: var(--space-4); }
.cal-detail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.cal-detail-title { font-size: var(--font-size-md); font-weight: 600; }

/* 排课弹窗：冲突提示区 */
.conflict-box {
  padding: var(--space-2) var(--space-3); margin-bottom: var(--space-3);
  background: var(--color-danger-soft, #fef2f2);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: var(--radius-md); font-size: var(--font-size-sm); color: var(--danger);
}
.conflict-box .cb-title { font-weight: 600; display: flex; align-items: center; gap: var(--space-1); margin-bottom: var(--space-1); }
.conflict-list { margin: 0; padding-left: 18px; }
.conflict-list li { margin: 2px 0; }

@media (max-width: 560px) {
  .cal-cell { min-height: 64px; padding: 2px 4px; }
  .cal-event { font-size: 11px; padding: 0 3px; }
  .cal-daynum { font-size: var(--font-size-xs); }
  .cal-dow { padding: var(--space-1); }
}

/* ===== 课堂白板（共享 canvas 批注） ===== */
.whiteboard {
  position: absolute; inset: 0; width: 100%; height: 100%;
  cursor: crosshair; touch-action: none;
}
.whiteboard[hidden] { display: none !important; }
.wb-toolbar {
  position: absolute; top: var(--space-3); left: 50%; transform: translateX(-50%);
  z-index: 10; display: flex; align-items: center; gap: var(--space-1);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 4px 6px; box-shadow: 0 4px 12px rgba(15,23,42,.12);
}
.wb-toolbar[hidden] { display: none !important; }
.wb-tool {
  width: 32px; height: 32px; border: none; background: transparent; color: var(--fg-2);
  border-radius: var(--radius-sm); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.wb-tool:hover { background: var(--accent-soft); color: var(--accent); }
.wb-tool.wb-active { background: var(--accent-soft); color: var(--accent); }
.wb-tool.wb-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
.wb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }
.wb-colors { display: inline-flex; gap: 4px; align-items: center; }
.wb-color { width: 18px; height: 18px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.wb-color.wb-active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px currentColor; }

@media (max-width: 560px) {
  .wb-toolbar { gap: 2px; padding: 3px 4px; top: var(--space-2); }
  .wb-tool { width: 28px; height: 28px; }
  .wb-color { width: 16px; height: 16px; }
}

/* ===== 督导旁听（#29） ===== */
.monitor-badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px var(--space-2); border-radius: var(--radius-sm);
  background: var(--accent); color: #fff;
  font-size: var(--font-size-xs); font-weight: var(--font-weight-semibold);
  white-space: nowrap;
}
.monitor-badge[hidden] { display: none !important; }

.monitor-grid {
  position: absolute; inset: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2);
  padding: var(--space-2);
}
.monitor-grid[hidden] { display: none !important; }

.monitor-cell {
  position: relative; border-radius: var(--radius-md);
  overflow: hidden; background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.monitor-cell-teacher { grid-column: 1; }
.monitor-cell-student  { grid-column: 2; }

.monitor-video {
  width: 100%; height: 100%; object-fit: cover;
  background: var(--surface-2);
}

.monitor-label {
  position: absolute; bottom: var(--space-1); left: var(--space-1);
  padding: 2px var(--space-2); border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.55); color: #fff;
  font-size: var(--font-size-xs); font-weight: var(--font-weight-medium);
  pointer-events: none;
}

/* admin.html 活跃课堂列表 */
.rooms-list { display: flex; flex-direction: column; gap: var(--space-3); }
.rooms-empty { color: var(--muted); text-align: center; padding: var(--space-8) 0; }
.rooms-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface);
}
.rooms-info { display: flex; flex-direction: column; gap: 2px; }
.rooms-title { font-weight: var(--font-weight-semibold); color: var(--fg); }
.rooms-meta { font-size: var(--font-size-xs); color: var(--muted); }
.rooms-badge {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: var(--space-1); vertical-align: middle;
}
.rooms-badge-online { background: var(--success); }
.rooms-badge-offline { background: var(--muted); }
.rooms-actions { display: flex; gap: var(--space-2); }
.rooms-btn {
  padding: var(--space-1) var(--space-3); border-radius: var(--radius-sm);
  border: 1px solid var(--accent); color: var(--accent);
  background: transparent; font-size: var(--font-size-sm);
  cursor: pointer; transition: all var(--motion-base) var(--motion-ease);
}
.rooms-btn:hover { background: var(--accent); color: #fff; }
.rooms-refresh {
  margin-bottom: var(--space-3); padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--fg); font-size: var(--font-size-sm);
  cursor: pointer;
}

/* ===== 数据看板（#30） ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--fg);
}
.stat-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* Status bar */
.status-bar-wrap {
  margin-bottom: 24px;
}
.status-bar-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--fg);
}
.status-bar {
  display: flex;
  height: 24px;
  border-radius: 4px;
  overflow: hidden;
}
.status-bar-seg {
  min-width: 2px;
  transition: none;
}
.status-bar-legend {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.status-bar-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 4px;
}

/* Sessions table (dashboard) */
.sessions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.sessions-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
}
.sessions-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
}
.sessions-table tr:last-child td {
  border-bottom: none;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.status-badge-scheduled {
  background: var(--accent-soft);
  color: var(--accent);
}
.status-badge-live {
  background: #dcfce7;
  color: #16a34a;
}
.status-badge-ended {
  background: #f3f4f6;
  color: #6b7280;
}
.status-badge-canceled {
  background: #fef2f2;
  color: #ef4444;
}

/* CSV 导出按钮 */
.export-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--fg-2);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: background var(--motion-base) var(--motion-ease), color var(--motion-base) var(--motion-ease);
  min-height: 36px;
}
.export-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.export-btn i {
  width: 16px;
  height: 16px;
}

/* ===== 作业/测验（#32） ===== */
.quiz-panel[hidden] { display: none !important; }
.quiz-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 380px; max-width: 90vw;
  background: var(--surface); border-left: 1px solid var(--border);
  z-index: 100; display: flex; flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
}
.quiz-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.quiz-panel-header h3 { font-size: 16px; font-weight: 600; color: var(--fg); }
.quiz-close { font-size: 20px; color: var(--muted); padding: 4px; cursor: pointer; background: none; border: none; }
.quiz-close:hover { color: var(--fg); }
.quiz-panel-body { padding: 16px; overflow-y: auto; flex: 1; }
.quiz-type-select { display: flex; gap: 12px; margin-bottom: 12px; font-size: 13px; }
.quiz-type-select label { cursor: pointer; color: var(--fg-2); }
.quiz-type-select input[type="radio"] { margin-right: 4px; }
.quiz-input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; color: var(--fg);
  background: var(--bg); margin-bottom: 8px; resize: vertical;
  font-family: inherit;
}
.quiz-input:focus { outline: none; border-color: var(--accent); }
.quiz-option-row {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.quiz-opt-label {
  flex: 0 0 24px; text-align: center; font-weight: 600; font-size: 13px;
  color: var(--fg-2); background: var(--surface-2); border-radius: 4px; padding: 4px 0;
}
.quiz-option-input { flex: 1; }
.quiz-opt-correct {
  flex: 0 0 28px; height: 28px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--border); display: flex; align-items: center; justify-content: center;
  transition: all .15s ease; font-size: 12px; color: transparent;
}
.quiz-opt-correct:hover { border-color: var(--accent); background: var(--accent-soft); }
.quiz-opt-correct.selected { border-color: #16a34a; background: #dcfce7; color: #16a34a; }
.quiz-opt-correct.selected::after { content: '✓'; }
/* 出题图片 */
.quiz-img-row { margin-bottom: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.quiz-img-name { font-size: 12px; color: var(--muted); }
.quiz-img-preview { max-width: 200px; max-height: 120px; border-radius: 6px; border: 1px solid var(--border); object-fit: contain; }
.quiz-student-image { max-width: 100%; max-height: 200px; border-radius: 8px; margin-bottom: 12px; object-fit: contain; background: var(--surface-2); }
.quiz-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.quiz-overlay[hidden] { display: none !important; }
.quiz-panel-inner {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 24px; max-width: 480px; width: 90vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.24);
}
.quiz-question-text { font-size: 16px; font-weight: 600; color: var(--fg); margin-bottom: 16px; line-height: 1.5; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.quiz-option {
  padding: 10px 14px; border: 2px solid var(--border); border-radius: var(--radius-md);
  cursor: pointer; font-size: 14px; color: var(--fg); transition: none; text-align: left;
  background: var(--bg);
}
.quiz-option:hover { border-color: var(--accent); }
.quiz-option.selected { border-color: var(--accent); background: var(--accent-soft); }
.quiz-option.correct { border-color: #16a34a; background: #dcfce7; }
.quiz-option.wrong { border-color: #ef4444; background: #fef2f2; }
.quiz-result { margin-top: 12px; padding: 10px; border-radius: var(--radius-sm); font-size: 14px; }
.quiz-result-correct { background: #dcfce7; color: #16a34a; }
.quiz-result-wrong { background: #fef2f2; color: #ef4444; }
.quiz-status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 4px; }
.quiz-status-dot-correct { background: #16a34a; }
.quiz-status-dot-wrong { background: #ef4444; }
.quiz-answer-row { margin: 8px 0 12px; }
.quiz-answer-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
#quiz-answer-select { width: 100%; }
#quiz-answer-select:empty { color: var(--muted); }
.quiz-active-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.quiz-active-question { font-size: 15px; font-weight: 600; color: var(--fg); margin-bottom: 8px; line-height: 1.5; }
.quiz-active-meta { font-size: 13px; color: var(--fg-2); margin-bottom: 16px; }
.quiz-status-text { font-size: 13px; color: var(--fg-2); margin-bottom: 12px; }

/* 排课表单专题选择行 */
.topic-row { display: flex; gap: 8px; align-items: center; }
.topic-row select { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; background: var(--bg); color: var(--fg); }

/* 结束课堂按钮 */
#btn-end { color: var(--color-danger, #ef4444); border-color: var(--color-danger, #ef4444); }
#btn-end:hover { background: #fef2f2; }

/* ===== 手机模式（学生端 · 触屏窄屏） =====
   - 全屏舞台：content 填充整个设备宽度
   - FAB 浮动按钮：取代底部操作条
   - 聊天底板：底部上滑抽屉
   - 老师 PiP：更小更紧凑
   激活条件：触屏设备 (pointer:coarse) + 窄屏 (<768px) */
@media (pointer: coarse) and (max-width: 768px) {
  /* --- 全局 --- */
  .workbench { position: relative; overflow: hidden; }

  /* --- 顶栏精简 --- */
  .topbar { height: 44px; flex: 0 0 44px; padding: 0 10px; }
  .brand-name { display: none; }
  .conn-text { display: none; }
  .monitor-badge { font-size: 10px; padding: 1px 6px; }
  .btn-exit span { display: none; }
  .btn-exit { border: none; background: transparent; padding: 4px; min-height: 36px; }
  .btn-exit i { width: 20px; height: 20px; }
  #btn-start span, #btn-end span { display: none; }
  #btn-start, #btn-end { min-width: 36px; padding: var(--space-1); }

  /* --- 主舞台全屏 --- */
  .stage-col { flex: 1; min-height: 0; }
  .courseware-bar { padding: 4px 8px; gap: 4px; }
  .cw-hint { display: none; }
  .cw-url { display: none; } /* 学生不可编辑 */

  /* --- 学生 FAB 浮动按钮（取代 student-bar） --- */
  .student-bar {
    position: absolute; bottom: 20px; left: 0; right: 0; z-index: 10;
    background: transparent; border: none; padding: 0 16px;
    justify-content: center; gap: 16px;
    pointer-events: none;
    transition: opacity .3s ease, transform .3s ease;
  }
  .student-bar.fab-hidden { opacity: 0; transform: translateY(16px); pointer-events: none; }
  .student-bar .sb-btn {
    pointer-events: auto;
    width: 48px; height: 48px; border-radius: 50%; padding: 0;
    border: 0.5px solid rgba(255,255,255,.15);
    background: rgba(0,0,0,.45); color: #fff; font-size: 10px; min-width: 0;
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    flex-direction: row;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    transition: transform .12s ease, background .2s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .student-bar .sb-btn:active { transform: scale(.88); }
  .student-bar .sb-btn span { display: none; }
  .student-bar .sb-btn i { width: 22px; height: 22px; }
  .student-bar .sb-btn.active { background: var(--accent) !important; }
  .student-bar .sb-chat { background: rgba(99,102,241,.85) !important; }
  .student-bar .sb-btn.active.sb-chat { background: var(--accent) !important; }

  /* --- 聊天底板（side-col 变身底部抽屉） --- */
  .side-col {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    max-height: 55vh; width: 100%; border: none;
    border-top: 0.5px solid var(--border);
    border-radius: 16px 16px 0 0;
    background: var(--surface);
    box-shadow: 0 -4px 24px rgba(0,0,0,.12);
    transform: translateY(calc(100% - 46px)); /* 默认只露出头部 */
    transition: transform .3s cubic-bezier(.32,.72,0,1);
    overflow: hidden;
  }
  .side-col.chat-expanded { transform: translateY(0); }
  .side-col .teacher-tools { display: none; } /* 学生端隐藏 */
  .side-col .chat { min-height: 0; }
  .side-col .chat-header-row {
    cursor: pointer; padding: 8px 12px; min-height: 46px;
    -webkit-user-select: none; user-select: none;
  }
  .side-col .chat-title { font-size: 13px; }
  .side-col .drawer-handle { display: inline-flex; }
  .side-col .chat-messages { flex: 1; min-height: 120px; max-height: calc(55vh - 120px); }
  .side-col .chat-input-row { padding: 8px 12px; padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  .side-col .chat-sub { max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* 聊天底板拖拽条 */
  .side-col .chat-header-row {
    position: relative;
  }
  .side-col .chat-header-row::before {
    content: ''; position: absolute; top: 6px; left: 50%;
    transform: translateX(-50%);
    width: 32px; height: 3px; border-radius: 2px;
    background: var(--border);
  }

  /* --- 聊天底板遮罩（点击直接关闭） --- */
  .chat-backdrop {
    position: fixed; inset: 0; z-index: 39;
    background: rgba(0,0,0,.35); opacity: 0;
    pointer-events: none; transition: opacity .3s ease;
  }
  .chat-backdrop.show { opacity: 1; pointer-events: auto; }

  /* --- 老师 PiP（推送内容时收为右上角更小窗） --- */
  .stage-remote.pip-mode {
    width: 80px; height: 60px; max-width: 80px; max-height: 60px;
    top: 50px; right: 8px; border-radius: 8px;
  }

  /* --- 自视图 PiP（左上角，避开 FAB） --- */
  .self-pip {
    width: 64px; height: 48px; left: 8px; right: auto; bottom: auto; top: 52px;
    border-radius: 8px;
  }
  .self-pip video { border-radius: 8px; }
  .self-pip .pip-label { right: auto; left: 2px; }

  /* --- 聊天底板拖拽条（加大触摸区） --- */
  .side-col .chat-header-row {
    padding: 10px 12px 6px;
  }
  .side-col .chat-header-row::before {
    top: 14px; width: 36px; height: 4px;
  }

  /* --- 聊天预览未读红点 --- */
  .drawer-unread {
    margin-left: auto; background: #ef4444; color: #fff;
    border-radius: 50%; min-width: 18px; height: 18px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 600; padding: 0 4px;
  }

  /* --- FAB 键盘隐藏类 --- */
  .student-bar.fab-hidden { opacity: 0; transform: translateY(16px); pointer-events: none; }

  /* --- 覆盖倒计时位置 --- */
  .float-timer { top: 50px; right: 96px; }

  /* --- 课件面板(推送)适配 --- */
  .courseware-pane { max-height: 100%; }

  /* --- 白板工具条位置微调 --- */
  .wb-toolbar { bottom: 76px; }

  /* --- 底部安全区 --- */
  .student-bar { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
}

/* ===== 聊天底板 JS 控制（通过 JS 加类，不与现有 drawer-open 冲突） ===== */

/* ===== 开课 3-2-1 全屏倒计时 ===== */
.countdown-overlay {
  position: fixed; inset: 0; z-index: 999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.7);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: opacity .3s ease;
}
.countdown-number {
  font-size: 120px; font-weight: 700; color: #fff;
  text-shadow: 0 4px 24px rgba(0,0,0,.3);
  animation: countdown-pulse .8s ease-out;
}
@keyframes countdown-pulse {
  0% { transform: scale(1.6); opacity: .4; }
  50% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1); opacity: .8; }
}

