:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --success: #047857;
  --success-soft: #d1fae5;
  --radius: 18px;
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    "PingFang SC", "Hiragino Sans GB", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
p {
  margin: 0;
}

code {
  padding: 2px 6px;
  border-radius: 6px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 0.9em;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.muted {
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.eyebrow.light {
  color: rgba(255, 255, 255, 0.72);
}

/* ---------- 登录 / 注册 ---------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background:
    radial-gradient(circle at 12% 18%, rgba(37, 99, 235, 0.4), transparent 42%),
    radial-gradient(circle at 88% 82%, rgba(13, 148, 136, 0.3), transparent 40%),
    #0b1220;
}

.auth-shell {
  width: min(1060px, 100%);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  border-radius: 28px;
  overflow: hidden;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 40px 90px rgba(2, 6, 23, 0.55);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  padding: 56px;
  color: #e2e8f0;
  background: linear-gradient(155deg, rgba(37, 99, 235, 0.32), rgba(15, 23, 42, 0) 62%);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #2563eb;
  color: #ffffff;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.35);
}

.brand-mark.small {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 16px;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.auth-brand h1 {
  max-width: 420px;
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1.24;
  letter-spacing: -0.02em;
}

.brand-copy {
  max-width: 400px;
  color: rgba(226, 232, 240, 0.7);
  font-size: 14px;
  line-height: 1.75;
}

.brand-points {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.brand-points li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.brand-points strong {
  display: block;
  font-size: 14px;
  color: #f8fafc;
}

.brand-points small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: rgba(226, 232, 240, 0.62);
}

.point-dot {
  width: 9px;
  height: 9px;
  margin-top: 6px;
  border-radius: 999px;
  flex: none;
}

.point-dot.blue {
  background: #60a5fa;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.16);
}

.point-dot.green {
  background: #34d399;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.16);
}

.point-dot.purple {
  background: #a78bfa;
  box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.16);
}

.auth-panel {
  display: flex;
  align-items: center;
  padding: 48px;
  background: #ffffff;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
}

.auth-title {
  font-size: 26px;
  letter-spacing: -0.02em;
}

.auth-sub {
  margin-top: 8px;
  margin-bottom: 26px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  margin-top: 4px;
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.24);
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-ghost {
  padding: 9px 14px;
  border-color: var(--border);
  background: #ffffff;
  color: #334155;
}

.btn-ghost:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.alert {
  margin-bottom: 18px;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.alert-success {
  background: var(--success-soft);
  color: var(--success);
}

.auth-switch {
  margin-top: 22px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.auth-switch a {
  font-weight: 700;
}

/* ---------- 角色端布局 ---------- */

.role-student {
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --accent-deep: #1e40af;
}

.role-parent {
  --accent: #059669;
  --accent-soft: #d1fae5;
  --accent-deep: #065f46;
}

.role-teacher {
  --accent: #7c3aed;
  --accent-soft: #ede9fe;
  --accent-deep: #5b21b6;
}

.portal-page {
  min-height: 100vh;
  background: var(--bg);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 252px;
  height: 100vh;
  padding: 24px 18px;
  background: #ffffff;
  border-right: 1px solid var(--border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 6px;
}

.sidebar-brand .brand-mark {
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
}

.role-chip {
  align-self: flex-start;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 700;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  color: #475569;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.16s ease, color 0.16s ease;
}

.nav-item:hover {
  background: #f1f5f9;
  color: var(--text);
  text-decoration: none;
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 3px;
  background: #cbd5e1;
  flex: none;
}

.nav-item.active .nav-dot {
  background: var(--accent);
}

.nav-label {
  flex: 1;
}

.soon {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 999px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.user-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--accent);
  color: #ffffff;
  font-size: 15px;
  font-weight: 800;
  flex: none;
}

.user-mini-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-mini-text strong {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-mini-text small {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 72px;
  padding: 0 32px;
  background: rgba(244, 246, 251, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.7);
}

.topbar-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.role-badge {
  padding: 6px 12px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 700;
}

.content {
  width: 100%;
  max-width: 1180px;
  padding: 30px 32px 48px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 34px;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--accent), #0f172a 92%);
  color: #ffffff;
  box-shadow: 0 24px 50px rgba(15, 23, 42, 0.18);
}

.hero-copy h1 {
  font-size: clamp(24px, 3vw, 32px);
  letter-spacing: -0.02em;
}

.hero-copy p:last-child {
  max-width: 560px;
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.74);
  font-size: 14px;
  line-height: 1.7;
}

.hero-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  flex: none;
}

.hero-badge span {
  font-size: 20px;
  font-weight: 800;
}

.hero-badge small {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.6);
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.card {
  padding: 22px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.08);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #e2e8f0;
}

.card-icon.blue {
  background: #dbeafe;
  box-shadow: inset 0 0 0 10px #bfdbfe;
}

.card-icon.green {
  background: #d1fae5;
  box-shadow: inset 0 0 0 10px #a7f3d0;
}

.card-icon.purple {
  background: #ede9fe;
  box-shadow: inset 0 0 0 10px #ddd6fe;
}

.card-icon.amber {
  background: #fef3c7;
  box-shadow: inset 0 0 0 10px #fde68a;
}

.tag {
  padding: 3px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
}

.card h3 {
  margin-top: 16px;
  font-size: 16px;
}

.card p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.panel {
  margin-top: 22px;
  padding: 24px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

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

.steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0 0;
  padding-left: 22px;
  color: #475569;
  font-size: 13px;
  line-height: 1.7;
}

.steps li::marker {
  color: var(--accent);
  font-weight: 800;
}

@media (max-width: 900px) {
  .auth-page {
    padding: 18px;
  }

  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    display: none;
  }

  .auth-panel {
    padding: 34px 24px;
  }

  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 16px 18px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-brand,
  .role-chip {
    display: none;
  }

  .nav {
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    margin-top: 0;
    padding-bottom: 2px;
  }

  .nav-item {
    white-space: nowrap;
    padding: 9px 12px;
  }

  .soon,
  .sidebar-footer {
    display: none;
  }

  .topbar {
    height: 62px;
    padding: 0 18px;
  }

  .content {
    padding: 20px 18px 36px;
  }

  .hero {
    padding: 26px;
  }

  .hero-badge {
    display: none;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .topbar-actions .role-badge {
    display: none;
  }

  .hero-copy h1 {
    font-size: 22px;
  }
}

/* ---------- 消息中心 ---------- */

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chat-page .app-shell {
  height: 100vh;
}

.chat-page .main {
  min-height: 0;
}

.content-chat {
  display: flex;
  flex: 1;
  min-height: 0;
  max-width: none;
  padding: 20px 24px 24px;
}

.chat-shell {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.06);
}

.chat-contacts {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #ffffff;
  border-right: 1px solid var(--border);
}

.chat-contacts-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 22px 20px 10px;
}

.chat-contacts-head h2 {
  font-size: 18px;
  letter-spacing: -0.01em;
}

.chat-contacts-head p {
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.5;
}

.chat-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 800;
}

.chat-search {
  padding: 8px 20px 14px;
}

.chat-search input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  font: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.chat-search input:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 10px 12px;
}

.contact-item {
  position: relative;
  display: flex;
  gap: 11px;
  width: 100%;
  padding: 11px 10px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.16s ease;
}

.contact-item:hover {
  background: #f8fafc;
}

.contact-item.active {
  background: var(--accent-soft);
}

.contact-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: #e2e8f0;
  color: #334155;
  font-size: 15px;
  font-weight: 800;
  flex: none;
}

.contact-avatar.role-student,
.msg-avatar.role-student {
  background: #dbeafe;
  color: #1d4ed8;
}

.contact-avatar.role-parent,
.msg-avatar.role-parent {
  background: #d1fae5;
  color: #047857;
}

.contact-avatar.role-teacher,
.msg-avatar.role-teacher {
  background: #ede9fe;
  color: #6d28d9;
}

.contact-avatar.role-admin,
.msg-avatar.role-admin {
  background: #fef3c7;
  color: #b45309;
}

.contact-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}

.contact-top {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.contact-top strong {
  overflow: hidden;
  font-size: 13.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-role {
  padding: 1px 6px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 9.5px;
  font-weight: 700;
  flex: none;
}

.contact-time {
  margin-left: auto;
  color: #94a3b8;
  font-size: 10px;
  flex: none;
}

.contact-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.contact-preview {
  flex: 1;
  overflow: hidden;
  color: #94a3b8;
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
}

.online-dot {
  position: absolute;
  left: 42px;
  bottom: 12px;
  width: 9px;
  height: 9px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #cbd5e1;
}

.online-dot.is-online {
  background: #22c55e;
}

.chat-list-empty {
  padding: 22px 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  text-align: center;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #f8fafc;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 74px;
  flex: none;
  padding: 0 22px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

.chat-peer {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.chat-peer-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chat-peer-text strong {
  font-size: 14.5px;
}

.chat-peer-text small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  flex: none;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f59e0b;
}

.chat-status[data-state="online"] .status-dot {
  background: #22c55e;
}

.chat-status[data-state="offline"] .status-dot,
.chat-status[data-state="error"] .status-dot {
  background: #ef4444;
}

.chat-messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  padding: 22px;
}

.chat-messages.is-loading {
  opacity: 0.5;
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: auto;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.chat-empty-mark {
  position: relative;
  width: 54px;
  height: 54px;
  margin-bottom: 6px;
  border-radius: 18px;
  background: var(--accent-soft);
}

.chat-empty-mark::after {
  content: "";
  position: absolute;
  left: 16px;
  top: 17px;
  width: 22px;
  height: 15px;
  border: 2px solid var(--accent);
  border-radius: 8px;
}

.chat-empty strong {
  color: var(--text);
  font-size: 14px;
}

.chat-empty p {
  max-width: 250px;
  font-size: 12px;
  line-height: 1.6;
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.msg-row.mine {
  justify-content: flex-end;
}

.msg-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: #e2e8f0;
  color: #334155;
  font-size: 11px;
  font-weight: 800;
  flex: none;
}

.msg-bubble {
  max-width: min(72%, 560px);
  padding: 10px 13px 7px;
  border: 1px solid var(--border);
  border-radius: 16px 16px 16px 5px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.msg-row.mine .msg-bubble {
  border: 0;
  border-radius: 16px 16px 5px 16px;
  background: var(--accent);
  color: #ffffff;
}

.msg-text {
  overflow-wrap: anywhere;
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.msg-time {
  margin-top: 4px;
  color: #94a3b8;
  font-size: 9.5px;
  text-align: right;
}

.msg-row.mine .msg-time {
  color: rgba(255, 255, 255, 0.68);
}

.msg-context-menu {
  position: fixed;
  z-index: 300;
  display: flex;
  flex-direction: column;
  min-width: 140px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
}

.msg-context-menu[hidden] {
  display: none;
}

.msg-context-menu button {
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.msg-context-menu button:hover {
  background: var(--surface, #f1f5f9);
}

.msg-context-menu button[data-action-kind="danger"] {
  color: #dc2626;
}

.msg-context-menu button[data-action-kind="danger"]:hover {
  background: #fee2e2;
}

.msg-bubble-recalled {
  background: var(--surface, #f1f5f9) !important;
  color: var(--text-muted, #64748b);
}

.msg-row.mine .msg-bubble-recalled {
  background: #e2e8f0;
}

.msg-text.msg-recalled {
  font-style: italic;
  color: var(--text-muted, #64748b);
  user-select: none;
}

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex: none;
  padding: 12px 16px;
  background: #ffffff;
  border-top: 1px solid var(--border);
}

.chat-composer textarea {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #f8fafc;
  font: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  outline: none;
  resize: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.chat-composer textarea:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.chat-composer textarea:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.chat-composer .btn {
  min-height: 42px;
  padding: 0 18px;
}

@media (max-width: 900px) {
  .content-chat {
    padding: 12px;
  }

  .chat-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .chat-contacts {
    max-height: 188px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .chat-contacts-head {
    padding: 12px 14px 4px;
  }

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

  .chat-search {
    padding: 6px 14px 8px;
  }

  .chat-list {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 10px 10px;
  }

  .contact-item {
    width: 220px;
    min-width: 220px;
  }

  .online-dot {
    display: none;
  }

  .chat-header {
    height: 62px;
    padding: 0 14px;
  }

  .chat-messages {
    padding: 16px;
  }

  .chat-composer {
    padding: 10px 12px;
  }
}

/* ---------- 作业提交 ---------- */

.homework-alert {
  margin-top: 18px;
  margin-bottom: 0;
}

.homework-upload {
  margin-top: 22px;
}

.homework-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 18px;
}

.upload-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 30px 20px;
  border: 1.5px dashed #cbd5e1;
  border-radius: 16px;
  background: #f8fafc;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.upload-drop:hover,
.upload-drop.is-dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  position: relative;
  width: 46px;
  height: 46px;
  margin-bottom: 4px;
  border-radius: 14px;
  background: var(--accent-soft);
}

.upload-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 15px;
  width: 2px;
  height: 16px;
  background: var(--accent);
  transform: translateX(-50%);
}

.upload-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 14px;
  width: 9px;
  height: 9px;
  border-left: 2px solid var(--accent);
  border-top: 2px solid var(--accent);
  transform: translateX(-50%) rotate(45deg);
}

.upload-drop strong {
  font-size: 14px;
}

.upload-drop small {
  color: var(--muted);
  font-size: 11.5px;
}

.upload-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #ffffff;
}

.upload-preview img {
  width: 88px;
  height: 88px;
  border-radius: 12px;
  border: 1px solid var(--border);
  object-fit: cover;
  flex: none;
}

.upload-preview-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.upload-preview-meta strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-preview-meta small {
  color: var(--muted);
  font-size: 11px;
}

.upload-error {
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

.homework-form-actions {
  display: flex;
  justify-content: flex-end;
}

.homework-history {
  margin-top: 22px;
}

.homework-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.homework-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #ffffff;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.homework-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.08);
}

.homework-thumb {
  display: block;
  aspect-ratio: 4 / 3;
  background: #f1f5f9;
}

.homework-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.homework-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
}

.homework-card-body strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.homework-card-body small {
  color: var(--muted);
  font-size: 11px;
}

.homework-card-actions {
  margin-top: 8px;
}

.homework-card-actions .btn {
  padding: 7px 12px;
  font-size: 12px;
}

.homework-empty {
  padding: 32px 20px;
  color: var(--muted);
  text-align: center;
}

.homework-empty strong {
  display: block;
  color: var(--text);
  font-size: 14px;
}

.homework-empty p {
  margin-top: 6px;
  font-size: 12px;
}

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

@media (max-width: 560px) {
  .homework-grid {
    grid-template-columns: 1fr;
  }

  .upload-preview {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---------- 作业列表 / 发布作业 ---------- */

.assignment-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.assignment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #ffffff;
}

.assignment-main {
  min-width: 0;
}

.assignment-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.assignment-head strong {
  font-size: 14px;
}

.assignment-main p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.assignment-main small {
  display: block;
  margin-top: 6px;
  color: #94a3b8;
  font-size: 11px;
}

.assignment-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.assignment-actions .btn {
  padding: 8px 14px;
  font-size: 12px;
}

.status-chip {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}

.status-chip.done {
  background: #d1fae5;
  color: #047857;
}

.status-chip.pending {
  background: #fef3c7;
  color: #b45309;
}

.status-chip.expired {
  background: #fee2e2;
  color: #b91c1c;
}

.status-chip.neutral {
  background: #f1f5f9;
  color: #475569;
}

@media (max-width: 560px) {
  .assignment-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .assignment-actions {
    width: 100%;
  }

  .assignment-actions .btn {
    flex: 1;
  }
}

/* ---------- 家长绑定 ---------- */

.binding-panel {
  margin-top: 22px;
}

.binding-code-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.binding-code {
  padding: 14px 20px;
  border-radius: 14px;
  background: #f1f5f9;
  color: var(--accent-deep);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.binding-hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.binding-form {
  max-width: 420px;
}

.binding-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.binding-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #ffffff;
}

.binding-item strong {
  display: block;
  font-size: 13px;
}

.binding-item small {
  color: var(--muted);
  font-size: 11px;
}

/* ---------- 批改作业 ---------- */

.grading-summary {
  display: flex;
  gap: 12px;
  margin-top: 22px;
}

.grading-stat {
  display: flex;
  flex: 1;
  align-items: baseline;
  gap: 8px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #ffffff;
}

.grading-stat strong {
  font-size: 28px;
  letter-spacing: -0.02em;
}

.grading-stat span {
  color: var(--muted);
  font-size: 12px;
}

.grading-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 18px;
}

.grading-card {
  display: flex;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #ffffff;
}

.grading-thumb {
  width: 180px;
  height: 135px;
  flex: none;
  overflow: hidden;
  border-radius: 12px;
  background: #f1f5f9;
}

.grading-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.grading-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.grading-body > small {
  color: var(--muted);
  font-size: 11px;
}

.grading-result {
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
}

.grading-score {
  display: inline-block;
  color: var(--accent-deep);
  font-size: 18px;
  font-weight: 800;
}

.grading-result p {
  margin-top: 4px;
  color: #334155;
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.grading-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.grading-form .field {
  font-size: 12px;
}

.grading-form textarea {
  min-height: 74px;
}

.grading-score-field {
  max-width: 150px;
}

/* ---------- 聊天中的批改信息块 ---------- */

.msg-bubble.msg-bubble-feedback {
  max-width: min(82%, 620px);
  padding: 10px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.msg-row.mine .msg-bubble.msg-bubble-feedback {
  background: transparent;
  color: inherit;
}

.msg-feedback {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--accent-soft);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.msg-row.mine .msg-feedback {
  background: #ffffff;
}

.msg-feedback-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.msg-feedback-label {
  color: var(--accent-deep);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.msg-feedback-score {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.msg-feedback-title {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: 13px;
}

.msg-feedback-comment {
  margin-top: 6px;
  color: #334155;
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.msg-bubble-feedback .msg-time,
.msg-row.mine .msg-bubble-feedback .msg-time {
  color: #94a3b8;
}

@media (max-width: 700px) {
  .grading-card {
    flex-direction: column;
  }

  .grading-thumb {
    width: 100%;
    height: 180px;
  }

  .grading-summary {
    flex-direction: column;
  }
}

/* ---------- 作业贡献热力图 ---------- */

.contribution-card {
  margin-top: 22px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.contribution-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

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

.contribution-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11.5px;
}

.contribution-stats {
  display: flex;
  gap: 18px;
}

.contribution-stats div {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}

.contribution-stats strong {
  font-size: 20px;
  letter-spacing: -0.02em;
}

.contribution-stats span {
  color: var(--muted);
  font-size: 10.5px;
}

.contribution-scroll {
  margin-top: 18px;
  padding-bottom: 4px;
  overflow-x: auto;
}

.contribution-months {
  display: flex;
  gap: 3px;
  height: 14px;
  padding-left: 28px;
  min-width: max-content;
}

.contribution-month {
  flex: 0 0 12px;
  width: 12px;
  overflow: visible;
  color: #94a3b8;
  font-size: 9px;
  white-space: nowrap;
}

.contribution-body {
  display: flex;
  gap: 6px;
  min-width: max-content;
}

.contribution-weekdays {
  display: grid;
  grid-template-rows: repeat(7, 12px);
  gap: 3px;
  width: 22px;
  flex: none;
  color: #94a3b8;
  font-size: 9px;
  line-height: 12px;
  text-align: right;
}

.contribution-weeks {
  display: flex;
  gap: 3px;
}

.contribution-week {
  display: grid;
  grid-template-rows: repeat(7, 12px);
  gap: 3px;
}

.contribution-cell {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: #ebedf0;
  transition: outline-color 0.12s ease;
}

.contribution-cell:hover {
  outline: 1px solid rgba(15, 23, 42, 0.35);
  outline-offset: 1px;
}

.contribution-cell.level-1 {
  background: #9be9a8;
}

.contribution-cell.level-2 {
  background: #40c463;
}

.contribution-cell.level-3 {
  background: #30a14e;
}

.contribution-cell.level-4 {
  background: #216e39;
}

.contribution-cell.is-future {
  background: transparent;
  pointer-events: none;
}

.contribution-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
}

.contribution-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
}

.contribution-legend .contribution-cell {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.contribution-legend .contribution-cell:hover {
  outline: none;
}

@media (max-width: 700px) {
  .contribution-card {
    padding: 18px;
  }

  .contribution-stats {
    width: 100%;
    justify-content: space-between;
  }

  .contribution-stats div {
    align-items: flex-start;
  }
}

/* ---------- 班级管理 ---------- */

.class-forms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.class-forms .panel {
  margin-top: 0;
}

.class-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.class-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: #ffffff;
}

.class-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.class-card > small {
  color: var(--muted);
  font-size: 11px;
}

.class-code-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.class-code {
  padding: 5px 10px;
  border-radius: 8px;
  background: #f1f5f9;
  color: var(--accent-deep);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.class-code-row .btn {
  padding: 6px 10px;
  font-size: 11px;
}

.homework-empty .btn {
  margin-top: 12px;
}

@media (max-width: 800px) {
  .class-forms,
  .class-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- 教师端 - 学生管理 ---------- */

.student-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.student-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: #ffffff;
}

.student-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.student-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.student-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.student-label {
  color: var(--muted);
  min-width: 40px;
}

.student-value {
  color: var(--text);
  word-break: break-all;
}

@media (max-width: 800px) {
  .student-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- 管理端 ---------- */

.role-admin {
  --accent: #0f766e;
  --accent-soft: #ccfbf1;
  --accent-deep: #115e59;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.admin-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.admin-stat span {
  color: var(--muted);
  font-size: 11px;
}

.admin-stat strong {
  font-size: 28px;
  letter-spacing: -0.03em;
}

.admin-stat small {
  color: var(--muted);
  font-size: 10.5px;
}

.admin-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.admin-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
}

.admin-list-item:last-child {
  border-bottom: none;
}

.admin-list-item > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-list-item strong {
  font-size: 13px;
}

.admin-list-item small {
  color: var(--muted);
  font-size: 11px;
}

.admin-list-meta {
  align-items: flex-end;
  text-align: right;
}

.panel-link {
  color: var(--accent-deep);
  font-size: 11px;
  font-weight: 600;
}

.admin-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.admin-filter input,
.admin-filter select {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  font: inherit;
  font-size: 12.5px;
  outline: none;
}

.admin-filter input[type="search"] {
  flex: 1;
  min-width: 200px;
}

.admin-filter input:focus,
.admin-filter select:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.admin-table-wrap {
  margin-top: 16px;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.admin-table th {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.admin-table td {
  padding: 12px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12.5px;
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table form {
  margin: 0;
}

.admin-table .btn {
  min-height: 32px;
  padding: 6px 12px;
  font-size: 11px;
}

.admin-user-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-user-cell strong {
  font-size: 12.5px;
}

.admin-user-cell small {
  color: var(--muted);
  font-size: 11px;
}

.admin-protected {
  font-size: 11px;
}

@media (max-width: 1000px) {
  .admin-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 800px) {
  .admin-split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .admin-stats {
    grid-template-columns: 1fr;
  }

  .admin-stat strong {
    font-size: 24px;
  }
}

/* ---------- AI 批改 ---------- */

.grading-ai-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.ai-grade-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.ai-spark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.ai-hint {
  color: var(--muted);
  font-size: 10.5px;
}

.ai-status {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 11.5px;
  line-height: 1.5;
}

.ai-status.is-loading {
  background: #eff6ff;
  color: #1d4ed8;
}

.ai-status.is-success {
  border: 1px solid #a7f3d0;
  background: #ecfdf5;
  color: #047857;
}

.ai-status.is-error {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.grading-ai-row .btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* ---------- 批改图标注 ---------- */

.annotation-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.annotation-preview img {
  max-width: 180px;
  max-height: 120px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}

.annotation-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.55);
}

.annotation-modal[hidden] {
  display: none;
}

.annotation-dialog {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(900px, 100%);
  max-height: 92vh;
  padding: 18px;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
}

.annotation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.annotation-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.annotation-title strong {
  font-size: 15px;
}

.annotation-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.annotation-toolbar .btn.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

#annotation-canvas {
  width: 100%;
  max-height: 62vh;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
  cursor: crosshair;
}

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

/* ---------- 学生个人信息 ---------- */

.profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 16px;
}

.profile-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.profile-class-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.profile-class-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
}

.profile-class-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.profile-class-main small {
  color: var(--muted);
  font-size: 11px;
}

.profile-class-item .btn {
  min-height: 32px;
  padding: 6px 12px;
  font-size: 11px;
}

.profile-join {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

@media (max-width: 800px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .profile-row {
    grid-template-columns: 1fr;
  }

  .profile-class-item {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* ---------- 课程表 ---------- */

.timetable-wrap {
  margin-top: 18px;
  overflow-x: auto;
}

.timetable {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.timetable th,
.timetable td {
  border: 1px solid var(--border);
}

.timetable th {
  padding: 10px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
}

.timetable td {
  width: 18%;
  height: 76px;
  padding: 5px;
  vertical-align: top;
  background: #ffffff;
}

.timetable .timetable-period-head,
.timetable .timetable-period {
  width: 76px;
  text-align: left;
  white-space: nowrap;
}

.timetable-entry {
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: 100%;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--accent-soft);
}

.timetable-entry strong {
  color: var(--accent-deep);
  font-size: 12px;
}

.timetable-entry small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.timetable-entry.is-mine {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.timetable-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  color: #cbd5e1;
}

.timetable-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.timetable-form-grid .field:first-child {
  grid-column: span 2;
}

.timetable-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.timetable-actions form {
  margin: 0;
}

.timetable-actions .btn {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 11px;
}

@media (max-width: 800px) {
  .timetable-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .timetable-form-grid {
    grid-template-columns: 1fr;
  }

  .timetable-form-grid .field:first-child {
    grid-column: auto;
  }
}
