/* A 版浅色毛玻璃学生端：零依赖、无外部字体。 */
:root {
  --ink: #1e2942;
  --ink-soft: #54617d;
  --ink-faint: #8490a8;
  --glass: rgba(255, 255, 255, .58);
  --glass-strong: rgba(255, 255, 255, .76);
  --glass-line: rgba(255, 255, 255, .82);
  --stroke: rgba(112, 130, 175, .16);
  --accent: #5b7cf0;
  --accent-2: #9a72e8;
  --accent-soft: rgba(91, 124, 240, .12);
  --mint: #3fb8a0;
  --danger: #d45f6b;
  --shadow: 0 18px 50px rgba(63, 84, 140, .14), 0 2px 10px rgba(63, 84, 140, .06);
  --radius: 24px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(135deg, #eaf1ff 0%, #f4eeff 46%, #e8f8f4 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea { font-family: var(--font); }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 背景与主容器 */
.ambient { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.orb { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; }
.orb-1 { width: 46vw; height: 46vw; min-width: 340px; min-height: 340px; top: -14vw; left: -8vw; background: radial-gradient(circle at 35% 35%, #a9c3ff, transparent 68%); }
.orb-2 { width: 42vw; height: 42vw; min-width: 320px; min-height: 320px; bottom: -16vw; right: -6vw; background: radial-gradient(circle at 60% 40%, #d6bcff, transparent 68%); }
.orb-3 { width: 32vw; height: 32vw; min-width: 260px; min-height: 260px; top: 38%; left: 46%; background: radial-gradient(circle at 50% 50%, #a9ecdc, transparent 70%); opacity: .38; }
@media (prefers-reduced-motion: no-preference) {
  .orb-1 { animation: drift1 22s ease-in-out infinite alternate; }
  .orb-2 { animation: drift2 26s ease-in-out infinite alternate; }
  .orb-3 { animation: drift1 30s ease-in-out infinite alternate-reverse; }
}
@keyframes drift1 { to { transform: translate3d(6vw, 5vh, 0) scale(1.12); } }
@keyframes drift2 { to { transform: translate3d(-7vw, -5vh, 0) scale(1.08); } }
.app-shell {
  position: relative;
  z-index: 1;
  width: min(940px, calc(100% - 32px));
  max-width: 100vw;
  height: min(900px, calc(100dvh - 36px));
  margin: 18px auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--glass-line);
  background: var(--glass);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  backdrop-filter: blur(26px) saturate(180%);
  box-shadow: var(--shadow);
}

/* 顶栏 */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--stroke);
  background: rgba(255, 255, 255, .34);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 20px rgba(91, 124, 240, .32);
}
.brand-mark svg { width: 23px; height: 23px; }
.brand-text { min-width: 0; }
.brand-text h1 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: .2px; }
.brand-text p { margin: 3px 0 0; font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, .55);
  white-space: nowrap;
}
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: #e0a44a; box-shadow: 0 0 0 3px rgba(224, 164, 74, .16); }
.badge.live .badge-dot { background: var(--mint); box-shadow: 0 0 0 3px rgba(63, 184, 160, .18); }
.network-banner {
  flex: none;
  padding: 8px 18px;
  color: #9b4d29;
  background: rgba(255, 237, 211, .88);
  border-bottom: 1px solid rgba(190, 124, 64, .16);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

/* 独立入班区与课堂区 */
.classroom-main { flex: 1; min-height: 0; min-width: 0; display: flex; }
.join-view { flex: 1; min-height: 0; overflow-y: auto; display: flex; padding: 22px; }
.join-view .welcome-card { margin: auto; }
.session-view { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.welcome-card {
  width: min(540px, 100%);
  padding: 30px 28px;
  text-align: center;
  border-radius: 22px;
  border: 1px solid var(--glass-line);
  background: rgba(255, 255, 255, .5);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(72, 92, 150, .09);
  overflow-wrap: anywhere;
}
.welcome-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 16px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
}
.welcome-icon svg { width: 29px; height: 29px; }
.welcome-card h2 { margin: 0 0 8px; font-size: 19px; font-weight: 650; }
.welcome-card > p { margin: 0; font-size: 13.5px; line-height: 1.7; color: var(--ink-soft); }
.welcome-note { margin-top: 16px !important; font-size: 12px !important; color: var(--ink-faint) !important; }
.join-form { margin-top: 22px; }
.join-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: left; }
.join-field { display: block; min-width: 0; }
.join-field > span { display: block; margin: 0 0 6px 3px; font-size: 12px; color: var(--ink-soft); }
.join-field input {
  width: 100%;
  min-height: 43px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, .82);
  color: var(--ink);
  font-size: 15px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.join-field input:focus { border-color: rgba(91, 124, 240, .5); box-shadow: 0 0 0 3px rgba(91, 124, 240, .1); }
.join-field input::placeholder { color: var(--ink-faint); }
.join-field input:disabled { opacity: .65; }
.primary-btn {
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 20px rgba(91, 124, 240, .26);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s, opacity .18s;
}
.primary-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 11px 24px rgba(91, 124, 240, .32); }
.primary-btn:disabled { opacity: .5; cursor: not-allowed; }
.join-submit { width: 100%; margin-top: 14px; }
.lesson-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 22px 0;
  padding: 11px 13px 11px 15px;
  border: 1px solid var(--glass-line);
  border-radius: 15px;
  background: rgba(255, 255, 255, .38);
}
.lesson-copy { min-width: 0; }
.lesson-copy h2 { margin: 0; font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-copy p { margin: 3px 0 0; color: var(--ink-faint); font-size: 11.5px; }

/* 消息区 */
.chat-log {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 22px 10px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 138, 180, .35) transparent;
}
.chat-log::-webkit-scrollbar { width: 8px; }
.chat-log::-webkit-scrollbar-thumb { background: rgba(120, 138, 180, .3); border-radius: 8px; }
.empty-state { margin: auto; max-width: 390px; padding: 28px 18px; text-align: center; color: var(--ink-soft); }
.empty-icon { width: 48px; height: 48px; margin: 0 auto 13px; display: grid; place-items: center; border-radius: 15px; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.empty-state h3 { margin: 0 0 7px; color: var(--ink); font-size: 16px; }
.empty-state p { margin: 0; font-size: 13px; line-height: 1.75; }
.msg { display: flex; gap: 10px; align-items: flex-end; animation: rise .28s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.me { flex-direction: row-reverse; }
.avatar {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 5px 12px rgba(91, 124, 240, .24);
}
.msg.me .avatar { background: linear-gradient(140deg, #7cc6b6, #4aa8c4); box-shadow: 0 5px 12px rgba(74, 168, 196, .22); }
.msg-body { max-width: min(78%, 620px); min-width: 0; }
.msg.me .msg-body { display: flex; flex-direction: column; align-items: flex-end; }
.bubble {
  padding: 12px 15px;
  border-radius: 18px 18px 18px 6px;
  background: var(--glass-strong);
  border: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 5px 18px rgba(72, 92, 150, .08);
  font-size: 14.5px;
  line-height: 1.75;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg.me .bubble {
  color: #fff;
  border-color: transparent;
  border-radius: 18px 18px 6px 18px;
  background: linear-gradient(140deg, #6486f5, #9878e8);
  box-shadow: 0 6px 18px rgba(91, 124, 240, .22);
}
.bubble-text { white-space: pre-wrap; }
.bubble.is-error { color: var(--danger); background: rgba(255, 241, 242, .9); border-color: rgba(212, 95, 107, .22); }
.msg-images { display: flex; margin-bottom: 8px; }
.msg-images:last-child { margin-bottom: 0; }
.msg-images img {
  width: 148px;
  max-width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .7);
  cursor: zoom-in;
  display: block;
  background: rgba(255, 255, 255, .5);
  transition: transform .18s, box-shadow .18s;
}
.msg-images img:hover { transform: scale(1.02); box-shadow: 0 6px 18px rgba(60, 80, 140, .18); }
.msg-time { margin: 5px 3px 0; font-size: 11px; color: var(--ink-faint); }
.msg-flag { margin: 5px 3px 0; font-size: 11px; line-height: 1.5; color: #9a6a23; }
.msg-flag.error { color: var(--danger); }
.typing { display: inline-flex; gap: 4px; align-items: center; height: 18px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: .45; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.cursor-caret { display: inline-block; width: 6px; height: 15px; margin-left: 2px; vertical-align: -2px; border-radius: 2px; background: var(--accent); animation: caret 1s steps(2) infinite; }
@keyframes caret { 50% { opacity: 0; } }

/* 输入与作品预览 */
.composer {
  flex: none;
  min-width: 0;
  padding: 12px 18px 14px;
  border-top: 1px solid var(--stroke);
  background: rgba(255, 255, 255, .42);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
.preview-bar { display: flex; padding: 2px 0 12px; }
.preview-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(100%, 390px);
  min-height: 68px;
  padding: 6px 36px 6px 6px;
  border: 1px solid var(--glass-line);
  border-radius: 13px;
  background: rgba(255, 255, 255, .58);
  box-shadow: 0 3px 10px rgba(60, 80, 140, .1);
}
.preview-item.is-failed { border-color: rgba(212, 95, 107, .35); background: rgba(255, 241, 242, .72); }
.preview-item > img { flex: none; width: 56px; height: 56px; object-fit: cover; display: block; border-radius: 9px; cursor: zoom-in; background: #fff; }
.preview-info { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.preview-info strong { font-size: 12px; font-weight: 650; }
.preview-info > span { color: var(--ink-soft); font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.preview-item.is-failed .preview-info > span { color: var(--danger); }
.preview-remove {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(80, 94, 125, .12);
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 22px;
  cursor: pointer;
}
.preview-retry { margin-top: 3px; padding: 3px 10px; border: 1px solid rgba(91, 124, 240, .22); border-radius: 999px; color: var(--accent); background: #fff; font-size: 11px; cursor: pointer; }
.composer-row { display: flex; align-items: flex-end; gap: 10px; }
.attach-group { display: flex; gap: 6px; flex: none; }
.icon-btn {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, .52);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .18s, color .18s, transform .18s, box-shadow .18s;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .92); color: var(--accent); transform: translateY(-1px); }
.icon-btn:active:not(:disabled) { transform: translateY(0); }
.icon-btn.active { color: #fff; background: linear-gradient(140deg, var(--accent), var(--accent-2)); border-color: transparent; box-shadow: 0 6px 16px rgba(91, 124, 240, .3); }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.composer-row textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  max-height: 132px;
  min-height: 42px;
  padding: 11px 14px;
  border-radius: 15px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, .72);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.5;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
  scrollbar-width: thin;
}
.composer-row textarea:focus { border-color: rgba(91, 124, 240, .5); box-shadow: 0 0 0 3px rgba(91, 124, 240, .1); }
.composer-row textarea::placeholder { color: var(--ink-faint); }
.composer-row textarea:disabled { opacity: .65; cursor: not-allowed; }
.send-btn {
  flex: none;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 14px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 16px rgba(91, 124, 240, .3);
  transition: transform .18s, box-shadow .18s, opacity .18s;
}
.send-btn svg { width: 21px; height: 21px; }
.send-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 9px 20px rgba(91, 124, 240, .36); }
.send-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.send-btn.stop { background: linear-gradient(140deg, #e0848c, #d0687a); }
.composer-hint { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 11.5px; color: var(--ink-faint); }
.composer-hint span { min-width: 0; }
.hint-right { white-space: nowrap; }

/* 大图与提示 */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px;
  background: rgba(24, 32, 54, .68);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.lightbox img { max-width: 100%; max-height: calc(100dvh - 116px); object-fit: contain; border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.lightbox-close { position: absolute; top: max(20px, env(safe-area-inset-top)); right: 20px; width: 40px; height: 40px; padding: 0; border: none; border-radius: 50%; background: rgba(255, 255, 255, .88); color: var(--ink); cursor: pointer; display: grid; place-items: center; }
.lightbox-close svg { width: 20px; height: 20px; }
.lightbox-caption { margin: 0; max-width: 90vw; color: rgba(255, 255, 255, .88); font-size: 12px; text-align: center; }
.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 14px);
  max-width: min(88vw, 460px);
  padding: 11px 18px;
  border-radius: 13px;
  background: rgba(32, 43, 70, .92);
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 12px 30px rgba(24, 34, 60, .24);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 窄屏与横向溢出兜底 */
@media (max-width: 680px) {
  .app-shell { width: 100%; height: 100dvh; margin: 0; border-radius: 0; border: none; }
  .topbar { padding: 12px 14px; padding-top: max(12px, env(safe-area-inset-top)); }
  .brand-text h1 { font-size: 15px; }
  .brand-text p { display: none; }
  .badge { padding: 6px 9px; font-size: 11px; }
  .join-view { padding: 16px 13px; }
  .welcome-card { padding: 24px 18px; }
  .lesson-bar { margin: 12px 13px 0; }
  .chat-log { padding: 14px 13px 8px; gap: 14px; }
  .msg-body { max-width: 84%; }
  .bubble { font-size: 14px; padding: 11px 13px; }
  .composer { padding: 10px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .composer-row { gap: 7px; }
  .attach-group { gap: 4px; }
  .attach-group .icon-btn { width: 34px; height: 34px; border-radius: 11px; }
  .attach-group .icon-btn svg { width: 17px; height: 17px; }
  .send-btn { width: 38px; height: 38px; border-radius: 12px; }
  .composer-hint .hint-right { display: none; }
  .msg-images img { width: 120px; }
  .lightbox { padding: 24px 14px; }
}
@media (max-width: 400px) {
  .topbar { padding-left: 10px; padding-right: 10px; }
  .brand { gap: 8px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 12px; }
  .brand-text h1 { font-size: 14px; }
  .badge { padding: 6px 8px; font-size: 10.5px; }
  .welcome-card { padding: 22px 14px; }
  .join-fields { grid-template-columns: 1fr; gap: 10px; }
  .composer-row textarea { padding: 10px 11px; font-size: 14px; }
  .preview-item { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .msg, .lightbox { animation: none; }
  .typing i, .cursor-caret { animation-duration: 2s; }
}
