/* ==========================================================================
   JIZHI (集智) Multi-Agent Collaborative Academic Writing Platform
   Design System: Layered Academic Blue & White (蓝白层次简约风)
   ========================================================================== */

:root {
  /* 🎨 Backgrounds & Surfaces (Porcelain & Ice Blue Hierarchy) */
  --bg-primary: #f0f4f9;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-blue-tint: #eff6ff;
  --bg-ice: #e0f2fe;
  
  /* 📝 Typography Hierarchy (Deep Navy to Slate) */
  --text-main: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  
  /* 🔷 Blue Accent Palette */
  --primary-blue: #2563eb;
  --primary-blue-hover: #1d4ed8;
  --primary-navy: #1e3a8a;
  --accent-cyan: #0284c7;
  --accent-sky: #38bdf8;
  --accent-emerald: #059669;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;
  --accent-purple: #7c3aed;
  
  /* 🪟 Borders & Shadows */
  --border-subtle: #e2e8f0;
  --border-blue: #bfdbfe;
  --border-active: #3b82f6;
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-card: 0 4px 20px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
  --shadow-floating: 0 12px 32px -4px rgba(15, 23, 42, 0.12), 0 4px 12px -2px rgba(15, 23, 42, 0.06);
  --shadow-glow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font-family);
  background: #f0f4f9;
  color: var(--text-main);
  min-height: 100vh;
  margin: 0;
  padding: 0;
  -webkit-overflow-scrolling: touch;
}

/* 🎓 仅在学生三栏协作工作台模式下锁定视口为 100vh */
html.app-student-workspace-mode,
body.app-student-workspace-mode,
body.app-student-workspace-mode #app {
  height: 100vh;
  min-height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

#app { 
  display: flex; 
  flex-direction: column; 
  min-height: 100vh; 
  width: 100vw; 
}

#app.app-teacher-mode,
.teacher-portal-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f0f4f9;
}

.card, .canvas-area, .chat-stream, .chat-panel, .panel, .editor-container, .student-workspace-container, .teacher-etherpad-container, .teacher-chat-stream, .etherpad-readonly-shield {
  overscroll-behavior: contain;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

.teacher-etherpad-container iframe {
  overscroll-behavior: contain;
  overscroll-behavior-y: contain;
}

/* ==========================================================================
   1. APP NAVIGATION HEADER (CLEAN WHITE & SAPPHIRE BLUE)
   ========================================================================== */
.app-header {
  height: 44px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 6px;
  z-index: 100;
  white-space: nowrap;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.app-header::-webkit-scrollbar {
  display: none;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.brand-logo {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #1e40af, #2563eb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 4px;
}

.brand-badge {
  background: #eff6ff;
  color: #2563eb;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid #bfdbfe;
}

.stage-nav {
  display: flex;
  align-items: center;
  background: #f1f5f9;
  padding: 2px;
  border-radius: 30px;
  border: 1px solid #e2e8f0;
  gap: 2px;
  flex-shrink: 0;
}

.stage-btn {
  background: transparent;
  border: none;
  color: #64748b;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.stage-btn:hover {
  color: #1e293b;
  background: rgba(255, 255, 255, 0.6);
}

.stage-btn.active {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
  font-weight: 700;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.timer-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 5px 12px;
  border-radius: 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", monospace;
  font-size: 12.5px;
  font-weight: 700;
  color: #1d4ed8;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-ann-bell-btn {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #334155;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.nav-ann-bell-btn:hover {
  border-color: #3b82f6;
  color: #2563eb;
  background: #f8fafc;
}

.nav-ann-bell-btn.has-unread {
  border-color: #059669;
  color: #059669;
  background: #ecfdf5;
  animation: bellPulse 1.5s infinite;
}

@keyframes bellPulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.35); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.unread-count {
  background: #ef4444;
  color: white;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 800;
}

.header-icon-btn {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #2563eb;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.header-icon-btn:hover {
  background: #dbeafe;
  color: #1d4ed8;
}

.header-icon-btn.logout {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}

.header-icon-btn.logout:hover {
  background: #fee2e2;
  color: #b91c1c;
}

/* ==========================================================================
   2. MAIN LAYOUT GRID (LEFT WORKSPACE CANVAS + RIGHT CHAT SIDEBAR)
   ========================================================================== */
.main-content {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 450px;
  height: calc(100vh - 44px);
  overflow: hidden;
  background: #f0f4f9;
}

@media (min-width: 701px) {
  .main-content.etherpad-editor-expanded {
    grid-template-columns: minmax(0, 1fr) clamp(260px, 23vw, 320px);
  }
}

@media (max-width: 700px) {
  .main-content.etherpad-editor-expanded {
    grid-template-rows: minmax(72vh, 72vh) minmax(400px, 65vh);
  }
}

.canvas-panel {
  padding: 12px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.chat-panel {
  background: #ffffff;
  border-left: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
  box-shadow: -2px 0 10px rgba(15, 23, 42, 0.02);
}

.chat-header {
  padding: 14px 18px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  flex-shrink: 0;
}

.chat-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #0f172a;
}

.active-agent-pills { display: flex; gap: 6px; }

.agent-pill {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #2563eb;
  font-weight: 600;
}

/* ==========================================================================
   3. CHAT STREAM, BUBBLES & COMPOSER
   ========================================================================== */
.chat-stream {
  flex: 1;
  padding: 16px;
  overflow-y: auto !important;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #f8fafc;
}

.chat-message {
  display: flex;
  gap: 10px;
  max-width: 88%;
}

.chat-message.other {
  align-self: flex-start;
  flex-direction: row;
}

.chat-message.other .msg-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.chat-message.me {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-message.me .msg-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #bfdbfe;
  border-radius: 16px 4px 16px 16px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.msg-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.msg-meta {
  font-size: 11px;
  color: #64748b;
}

.msg-sender {
  font-weight: 700;
  color: #334155;
}

.msg-bubble {
  padding: 11px 15px;
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.mention-tag {
  background: #eff6ff;
  color: #2563eb;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
  border: 1px solid #bfdbfe;
}

/* Mention Popover Menu */
.at-mention-menu {
  background: #ffffff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 10px;
  margin: 0 16px 8px 16px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.1);
  flex-shrink: 0;
  animation: popoverFadeIn 0.15s ease-out;
}

@keyframes popoverFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.at-menu-header {
  font-size: 11px;
  font-weight: 800;
  color: #2563eb;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #e2e8f0;
}

.at-menu-list {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.at-group-title {
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  margin: 4px 0 2px 4px;
  text-transform: uppercase;
}

.at-item {
  font-size: 12px;
  color: #334155;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.at-item:hover {
  background: #eff6ff;
  color: #1d4ed8;
}

.at-item.agent {
  color: #0284c7;
  font-weight: 600;
}

.at-item.agent:hover {
  background: #e0f2fe;
}

/* Emoji Bar */
.emoji-bar {
  padding: 6px 14px;
  background: #ffffff;
  display: flex;
  gap: 8px;
  border-top: 1px solid #e2e8f0;
  overflow-x: auto;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
}

.emoji-btn {
  cursor: pointer;
  font-size: 16px;
  transition: transform 0.15s ease;
  padding: 3px 5px;
  border-radius: 6px;
}

.emoji-btn:hover {
  transform: scale(1.3);
  background: #f1f5f9;
}

/* Chat Input Bar */
.chat-input-bar {
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  flex-shrink: 0;
}

.modern-spacious-input {
  flex: 1;
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 12px !important;
  padding: 11px 16px !important;
  color: #0f172a !important;
  font-size: 13.5px !important;
  line-height: 1.5 !important;
  min-height: 44px !important;
  outline: none !important;
  transition: all 0.2s ease !important;
}

.modern-spacious-input:focus {
  border-color: #2563eb !important;
  background: #ffffff !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15) !important;
}

.modern-send-btn {
  background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
  border: none !important;
  color: white !important;
  width: 44px !important;
  height: 44px !important;
  border-radius: 12px !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.3) !important;
  transition: all 0.2s ease !important;
}

.modern-send-btn:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 5px 14px rgba(37, 99, 235, 0.4) !important;
}

.modern-send-btn:active {
  transform: translateY(0) !important;
}

/* ==========================================================================
   4. CARDS & PROPOSAL GRIDS
   ========================================================================== */
.card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.card-title {
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.proposals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.proposal-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 14px;
  transition: all 0.2s ease;
}

.proposal-card:hover {
  border-color: #bfdbfe;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.proposal-card.voted {
  border-color: #3b82f6;
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.proposal-title {
  font-weight: 800;
  font-size: 14px;
  color: #0f172a;
  margin-bottom: 4px;
}

.vote-btn {
  margin-top: 10px;
  width: 100%;
  padding: 7px 12px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  transition: all 0.15s ease;
}

.vote-btn:hover:not([disabled]) {
  background: #eff6ff;
  color: #2563eb;
  border-color: #3b82f6;
}

.vote-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.vote-btn.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: #f1f5f9;
}

/* ==========================================================================
   5. ACADEMIC CONTRACT & AGREEMENT CARD
   ========================================================================== */
.contract-card {
  background: #ffffff !important;
  border: 2px solid #3b82f6 !important;
  border-radius: 16px !important;
  padding: 24px !important;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.08) !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

.large-contract-input {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 8px !important;
  padding: 10px 14px !important;
  color: #0f172a !important;
  font-size: 13.5px !important;
  font-weight: 600 !important;
  outline: none !important;
  transition: all 0.15s ease !important;
}

.large-contract-input:focus {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15) !important;
}

.contract-time-input.large {
  width: 60px;
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 6px !important;
  padding: 5px 8px !important;
  text-align: center !important;
  font-size: 13px !important;
  font-weight: 700 !important;
}

.contract-time-input.large:focus {
  border-color: #2563eb !important;
}

/* ==========================================================================
   6. WORD-GRADE ACADEMIC RICH TEXT EDITOR (CLEAN PORCELAIN DESK)
   ========================================================================== */
.word-editor-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.word-toolbar {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  padding: 4px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  user-select: none;
  flex-shrink: 0;
}

.word-toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
  background: #f8fafc;
  padding: 2px 4px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

.word-select {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 11px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  height: 24px;
}

.word-select:focus {
  border-color: #2563eb;
}

.word-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #334155;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 24px;
  transition: all 0.15s ease;
}

.word-btn:hover {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.word-btn.active {
  background: #2563eb;
  color: white;
}

.word-btn.plugin-btn {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.word-btn.plugin-btn:hover {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
}

.word-page-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  background: #ffffff;
  display: flex;
  justify-content: center;
}

.word-page {
  background: #ffffff;
  color: #0f172a;
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  padding: 16px 20px;
  border-radius: 0;
  box-shadow: none;
  font-family: "SimSun", "Songti SC", "Times New Roman", serif;
  font-size: 14.5px;
  line-height: 1.75;
  outline: none;
  box-sizing: border-box;
}

.word-editor-container.fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 99999 !important;
  border-radius: 0 !important;
}

.search-replace-bar {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: #334155;
}

.search-replace-bar input {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  outline: none;
}

.academic-abstract-box {
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-left: 5px solid #2563eb;
  padding: 16px 20px;
  margin: 20px 0;
  border-radius: 4px;
}

.academic-abstract-box .abstract-title {
  font-weight: 800;
  font-family: "SimHei", sans-serif;
  color: #0f172a;
  margin-bottom: 6px;
  text-indent: 0 !important;
}

.academic-abstract-box .keywords-row {
  font-weight: 700;
  color: #1e3a8a;
  margin-top: 10px;
  font-size: 13.5px;
  text-indent: 0 !important;
}

.word-page .academic-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13.5px;
  text-indent: 0;
}

.word-page .academic-table thead {
  border-top: 2.5px solid #0f172a;
  border-bottom: 1.5px solid #0f172a;
  background: #f8fafc;
}

.word-page .academic-table th {
  padding: 8px 10px;
  font-weight: 700;
  color: #0f172a;
  text-align: center;
}

.word-page .academic-table tbody {
  border-bottom: 2.5px solid #0f172a;
}

.word-page .academic-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
  text-align: center;
  color: #334155;
}

.word-page .academic-figure {
  text-align: center;
  margin: 18px 0;
  text-indent: 0;
}

.word-page .academic-figure img {
  max-width: 90%;
  max-height: 380px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.word-page .figure-caption {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  margin-top: 6px;
  text-indent: 0 !important;
  text-align: center;
}

.word-page .citation-tag {
  color: #0284c7;
  font-weight: 700;
  font-size: 11px;
  vertical-align: super;
  cursor: pointer;
  user-select: none;
}

/* ==========================================================================
   6.5 REAL-TIME COLLABORATIVE PRESENCE & LIVE CURSORS
   ========================================================================== */
.collab-presence-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-size: 12px;
  flex-shrink: 0;
}

.collab-presence-title {
  font-weight: 700;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 5px;
}

.collab-member-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.collab-presence-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  transition: all 0.2s ease;
}

.collab-presence-pill.active {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.collab-presence-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

/* Continuous Chat Stream Stage Divider */
.chat-stage-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 18px 0 10px 0;
  text-align: center;
  position: relative;
}

.chat-stage-divider::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: #e2e8f0;
  z-index: 1;
}

.chat-stage-divider-pill {
  position: relative;
  z-index: 2;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 14px;
  border-radius: 14px;
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.08);
}

.remote-cursor-widget {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: text-bottom;
  margin: 0 1px;
  user-select: none;
  pointer-events: none;
  z-index: 100;
}

.remote-caret-bar {
  display: inline-block;
  width: 3px;
  height: 1.3em;
  border-radius: 2px;
  animation: collabCaretBlink 0.9s ease-in-out infinite;
  box-shadow: 0 0 6px currentColor;
}

@keyframes collabCaretBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.remote-caret-flag {
  position: absolute;
  bottom: calc(100% + 2px);
  left: -2px;
  color: #ffffff !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  padding: 3px 8px !important;
  border-radius: 6px 6px 6px 0 !important;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  line-height: 1.2 !important;
  z-index: 1000 !important;
  pointer-events: none;
}

.collab-editing-node-highlight {
  position: relative;
  border-left: 3.5px solid transparent;
  padding-left: 6px;
  margin-left: -9.5px;
  transition: all 0.3s ease;
}

/* ==========================================================================
   7. MODALS (STANDARD INDUSTRY PATTERN: CLEAN FIXED OVERLAY & CARD BODY SCROLL)
   ========================================================================== */
body.modal-open .modal-overlay,
body.modal-open .modal-mask,
body.modal-open .table-config-modal-overlay,
body.modal-open #modal-change-password,
body.modal-open #modal-task-extended-unlock {
  pointer-events: auto !important;
  user-select: auto !important;
}

.modal-overlay,
.modal-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 20px;
  overflow: hidden; /* 🌟 遮罩层严格静止不滚动，彻底消除双重滚动条 */
  overscroll-behavior: contain !important;
  touch-action: none;
  animation: overlayFadeIn 0.15s ease-out;
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.teacher-modal-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-lg);
  width: 620px;
  max-width: 95vw;
  max-height: 85vh; /* 🌟 限制卡片高度，超出部分由 body 内部平滑滚动 */
  box-shadow: var(--shadow-floating);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: contain !important;
  touch-action: pan-y;
  animation: modalSlideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.teacher-modal-header {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  flex-shrink: 0; /* 🌟 头部绝对固定不滚动 */
}

.teacher-modal-header.task-theme-gradient {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-bottom: 1px solid #bfdbfe;
}

.teacher-modal-header.ann-theme-gradient {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border-bottom: 1px solid #a7f3d0;
}

.modal-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-header-title h3 {
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
}

.modal-icon-badge {
  font-size: 24px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-icon-badge.task {
  background: #dbeafe;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

.modal-icon-badge.ann {
  background: #d1fae5;
  border: 1px solid #a7f3d0;
  color: #059669;
}

.modal-close-btn {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #64748b;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s ease;
}

.modal-close-btn:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}

.teacher-modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 0;
  overflow-y: auto; /* 🌟 仅有正文区域产生平滑滚动 */
  overscroll-behavior: contain;
  background: #ffffff;
}

.teacher-modal-footer {
  padding: 14px 24px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0; /* 🌟 底部操作按钮绝对固定不滚动 */
}

.teacher-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.teacher-form-group label {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 4px;
}

.teacher-form-group label .req {
  color: #e11d48;
  font-weight: 800;
}

.teacher-input {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 8px !important;
  padding: 11px 14px !important;
  color: #0f172a !important;
  font-size: 13.5px !important;
  outline: none !important;
  transition: all 0.15s ease !important;
}

.teacher-input:focus {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15) !important;
}

.teacher-textarea {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 8px !important;
  padding: 12px 14px !important;
  color: #0f172a !important;
  font-size: 13.5px !important;
  line-height: 1.6 !important;
  min-height: 110px !important;
  resize: vertical !important;
  outline: none !important;
  transition: all 0.15s ease !important;
}

.teacher-textarea:focus {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15) !important;
}

.teacher-modal-footer {
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.modal-btn {
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
}

.modal-btn.cancel {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
}

.modal-btn.cancel:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.modal-btn.submit.task-theme {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.3);
}

.modal-btn.submit.ann-theme {
  background: linear-gradient(135deg, #059669, #047857);
  color: white;
  box-shadow: 0 3px 10px rgba(5, 150, 105, 0.3);
}

/* ==========================================================================
   8. TEACHER PORTAL & MONITORING (HIGH CONTRAST BLUE & WHITE)
   ========================================================================== */
.teacher-portal-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  background: #f0f4f9;
}

.teacher-header {
  height: 62px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.teacher-content {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 20px;
  overflow-y: auto;
}

.teacher-ann-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
}

.teacher-action-btn {
  background: linear-gradient(135deg, #1d4ed8, #2563eb) !important;
  color: #ffffff !important;
  border: none !important;
  border-radius: 8px !important;
  padding: 8px 18px !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  line-height: 1.4 !important;
}

.teacher-action-btn:hover {
  filter: brightness(1.08) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35) !important;
}

.teacher-action-btn:active {
  transform: translateY(0) !important;
}

.monitor-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 13px;
}

.monitor-table th, .monitor-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.monitor-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
}

.monitor-table td {
  color: #1e293b;
}

/* ==========================================================================
   10. STUDENT TASK PORTAL & DASHBOARD (我的写作任务大厅)
   ========================================================================== */
.student-task-portal {
  min-height: 100vh;
  background: #f0f4f9;
  display: flex;
  flex-direction: column;
  overflow-y: auto !important;
}

.student-task-card {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.student-task-card:hover {
  border-color: var(--border-active);
  box-shadow: var(--shadow-sm);
}

.btn-enter-task-workspace:hover {
  filter: brightness(1.08);
  transform: scale(1.01);
}

/* Custom Clean Scrollbars */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* 🤖 智能体正在思考中跳动三点动效 */
@keyframes dotPulse {
  0%, 80%, 100% {
    transform: scale(0.35);
    opacity: 0.35;
  }
  40% {
    transform: scale(1.15);
    opacity: 1;
  }
}

.thinking-bubble {
  animation: modalFadeIn 0.25s ease-out;
}

/* 🎓 阶段三答辩输入框与卡片极致顺滑滚动优化 */
.feedback-direct-input {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
}

.feedback-direct-input::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.feedback-direct-input::-webkit-scrollbar-track {
  background: transparent;
}

.feedback-direct-input::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.feedback-direct-input::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

#stage3-defense-card {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

#stage3-defense-card::-webkit-scrollbar {
  width: 7px;
}

#stage3-defense-card::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}


/* v2901 presentation closeout: shared surfaces, readable feedback, native controls. */
:root { --ui-space: 12px; --ui-focus: #1d4ed8; }
button, input, textarea, select { font-family: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible,
select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--ui-focus); outline-offset: 3px;
}
button:disabled, input:disabled, select:disabled, textarea:disabled {
  cursor: not-allowed; opacity: .65;
}
input[type="checkbox"] { accent-color: var(--primary-blue); }
textarea { line-height: 1.65; }
.btn, .teacher-action-btn, .modal-btn, .header-icon-btn { min-height: 36px; }
.card, .panel, .canvas-panel, .msg-body, .chat-panel { min-width: 0; }
.chat-stream, .teacher-chat-stream { scrollbar-gutter: stable; }
.chat-message .msg-bubble { line-height: 1.75; overflow-wrap: anywhere; }
.agent-card {
  --agent-accent: #475569;
  width: 100%; min-width: 0; flex: 0 0 auto; margin: 4px 0 12px;
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--agent-accent); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); overflow: hidden; color: var(--text-body);
}
.agent-card--auctioneer { --agent-accent: #7c3aed; }
.agent-card--managingEditor { --agent-accent: #047857; }
.agent-card--reviewingEditor { --agent-accent: #0369a1; }
.agent-card--proponent { --agent-accent: #15803d; }
.agent-card--opponent { --agent-accent: #b91c1c; }
.agent-card--neutral { --agent-accent: #92400e; }
.agent-card-header { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px 14px; background: var(--bg-subtle); border-bottom: 1px solid var(--border-subtle); }
.agent-card-avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: white; font-size: 17px; flex-shrink: 0; }
.agent-card-identity { flex: 1; min-width: 90px; display: flex; flex-direction: column; gap: 2px; }
.agent-card-identity strong { font-size: 13px; color: var(--agent-accent); overflow-wrap: anywhere; }
.agent-card-role, .agent-card-footer { font-size: 11px; color: #64748b; }
.agent-card-status { font-size: 11px; border: 1px solid var(--border-subtle); border-radius: 6px; padding: 2px 6px; background: white; color: #475569; }
.agent-card-status[data-status="failed"], .agent-card-status[data-status="failed_final"] { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }
.agent-card-status[data-status="completed"], .agent-card-status[data-status="committed"] { color: #166534; background: #f0fdf4; border-color: #bbf7d0; }
.agent-card-body { padding: 14px; font-size: 13px; line-height: 1.8; overflow-wrap: anywhere; }
.agent-card-body p + p { margin-top: 8px; }
.agent-card-body h4 { font-size: 13px; color: var(--text-main); margin: 12px 0 6px; }
.agent-card-body h4:first-child { margin-top: 0; }
.agent-card-body ul, .agent-card-body ol { margin: 8px 0; padding-left: 22px; }
.agent-card-body li + li { margin-top: 4px; }
.agent-card-body pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg-subtle); border-radius: 6px; padding: 10px; margin: 8px 0; }
.agent-card-body code { font-size: .95em; }
.agent-card-footer { padding: 0 14px 12px; display: flex; flex-wrap: wrap; gap: 6px 12px; }
.agent-card-actions { padding: 0 14px 12px; }
.agent-card-actions button { max-width: 100%; white-space: normal; }
.portal-header { min-height: 60px; height: auto; background: white; border-bottom: 1px solid var(--border-subtle); display:flex; justify-content:space-between; align-items:center; gap:12px; padding:12px 24px; flex-wrap:wrap; }
.portal-header .brand-section, .portal-header .header-controls { flex-wrap: wrap; min-width: 0; }
.portal-main { flex:1; padding:28px; max-width:1200px; width:100%; margin:0 auto; display:flex; flex-direction:column; gap:24px; }
.portal-task-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap:20px; }
.student-task-card { background:var(--bg-card); border:1px solid var(--border-subtle); border-radius:var(--radius-md); padding:22px; box-shadow:var(--shadow-sm); display:flex; flex-direction:column; justify-content:space-between; min-width:0; overflow-wrap:anywhere; }
.student-task-card.task-readonly { border-color:#fca5a5; }
.teacher-monitor-grid { grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); }
.monitor-table th, .monitor-table td { line-height:1.6; overflow-wrap:anywhere; }
.monitor-table tbody tr:hover { background:#f8fafc; }
.monitor-table tbody tr:focus-within { background:#eff6ff; }
.teacher-modal-card { max-width:calc(100vw - 32px); }
.teacher-modal-body { overscroll-behavior:contain; }
.teacher-modal-header, .teacher-modal-footer { gap:12px; flex-wrap:wrap; }
.teacher-input { min-height:38px; line-height:1.5; }
@media (max-width: 900px) {
  .teacher-monitor-grid { grid-template-columns: minmax(0, 1fr); overflow-y:auto; }
  .portal-main { padding:16px; }
}
@media (max-width: 600px) {
  .portal-header { padding:12px 16px; }
  .student-task-card { padding:16px; }
  .agent-card-header { padding:10px; }
  .agent-card-body { padding:12px; font-size:14px; }
  .agent-card-footer { padding:0 12px 12px; }
  .teacher-modal-card { max-width:calc(100vw - 16px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration:0.01ms !important; animation-iteration-count:1 !important; transition-duration:0.01ms !important; scroll-behavior:auto !important; }
}

@media (max-width: 1100px) and (min-width: 701px) {
  .main-content { grid-template-columns:minmax(0, 1fr) minmax(280px, 34%); }
}
@media (max-width: 700px) {
  .main-content { grid-template-columns:minmax(0, 1fr); grid-template-rows:minmax(360px, 60vh) minmax(400px, 65vh); overflow-y:auto; }
  .chat-panel { border-left:0; border-top:1px solid var(--border-subtle); }
  .canvas-panel { padding:12px; }
  .chat-header, .active-agent-pills { flex-wrap:wrap; gap:6px; }
}

/* v2925: milestone guidance stays in the normal conversation layout. */
.agent-chat-message .msg-avatar { background: #eef2ff; color: #4338ca; }
.agent-chat-message .msg-meta { gap: 10px; }
.agent-chat-message .msg-meta time { color: #94a3b8; font-size: 11px; }
.chat-message.other .agent-guidance-bubble {
  background: #f5f8ff;
  border: 1px solid #dbe5f5;
  border-left: 3px solid #819cc7;
  box-shadow: none;
}
.agent-guidance-label { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; color: #64748b; font-size: 11px; }
.agent-guidance-label strong { font-size: 12px; color: #334155; }
