.context-tutor {
  --tutor-ink: #172b28;
  --tutor-muted: #64746f;
  --tutor-line: #dbe4e1;
  --tutor-paper: #ffffff;
  --tutor-soft: #f4f8f6;
  --tutor-brand: #087f6d;
  --tutor-brand-deep: #075f53;
  --tutor-blue: #315fa8;
  --tutor-amber: #c47a17;
  position: fixed;
  z-index: 80;
  right: 22px;
  bottom: 22px;
  color: var(--tutor-ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

.context-tutor * {
  box-sizing: border-box;
  letter-spacing: 0;
}

.context-tutor button,
.context-tutor textarea {
  color: inherit;
  font: inherit;
}

.context-tutor-launcher {
  position: relative;
  width: 76px;
  height: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 0 0 3px;
  border: 0;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 10px 12px rgba(12, 48, 41, .2));
  transition: opacity .16s ease, transform .18s ease, filter .18s ease;
}

.context-tutor-launcher::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 6px;
  width: 9px;
  height: 9px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--tutor-amber);
  box-shadow: 0 2px 6px rgba(56, 40, 10, .18);
}

.context-tutor-launcher:hover {
  background: transparent;
  transform: translateY(-3px);
  filter: drop-shadow(0 12px 13px rgba(12, 48, 41, .22));
}

.context-tutor.is-open .context-tutor-launcher {
  opacity: 0;
  pointer-events: none;
}

.context-tutor.is-open .context-tutor-welcome {
  display: none;
}

.context-tutor-launcher-label {
  position: relative;
  z-index: 5;
  min-width: 60px;
  padding: 4px 8px 5px;
  border: 1px solid rgba(255, 255, 255, .82);
  border-radius: 6px;
  background: #086a5c;
  color: #fff;
  box-shadow: 0 5px 12px rgba(7, 71, 62, .18);
  font-size: 10px;
  font-weight: 750;
  line-height: 1;
  text-align: center;
}

.context-tutor-welcome {
  position: absolute;
  right: 82px;
  bottom: 27px;
  width: 176px;
  padding: 9px 11px;
  border: 1px solid #d6e3df;
  border-radius: 7px;
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 12px 28px rgba(11, 43, 37, .13);
  pointer-events: none;
  transform-origin: right center;
  animation: tutorWelcome 8s both 1s;
}

.context-tutor-welcome::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: 18px;
  width: 8px;
  height: 8px;
  border-top: 1px solid #d6e3df;
  border-right: 1px solid #d6e3df;
  background: #fff;
  transform: rotate(45deg);
}

.context-tutor-welcome strong,
.context-tutor-welcome span {
  display: block;
}

.context-tutor-welcome strong {
  font-size: 11px;
  line-height: 1.35;
}

.context-tutor-welcome span {
  margin-top: 3px;
  color: var(--tutor-muted);
  font-size: 9px;
  line-height: 1.4;
}

@keyframes tutorWelcome {
  0% { opacity: 0; transform: translateX(7px) scale(.97); }
  8%, 78% { opacity: 1; transform: translateX(0) scale(1); }
  100% { opacity: 0; transform: translateX(5px) scale(.98); visibility: hidden; }
}

.context-tutor-launcher:focus-visible,
.context-tutor button:focus-visible,
.context-tutor textarea:focus-visible,
.selection-tutor-actions button:focus-visible {
  outline: 3px solid rgba(8, 127, 109, .22);
  outline-offset: 2px;
}

.context-tutor-panel {
  position: absolute;
  right: 0;
  bottom: 94px;
  width: min(408px, calc(100vw - 28px));
  height: min(640px, calc(100dvh - 112px));
  min-height: 440px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  border: 1px solid #cedbd7;
  border-radius: 8px;
  background: var(--tutor-paper);
  box-shadow: 0 28px 72px rgba(11, 43, 37, .2), 0 4px 14px rgba(11, 43, 37, .08);
  transform-origin: right bottom;
  animation: tutorPanelIn .16s ease-out;
}

.context-tutor-panel[hidden] {
  display: none;
}

@keyframes tutorPanelIn {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.context-tutor-head {
  position: relative;
  min-height: 62px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--tutor-line);
  background: #f9fbfa;
}

.context-tutor-head::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--tutor-brand);
}

.context-tutor-mark {
  position: relative;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid #c4ddd7;
  border-radius: 8px;
  overflow: hidden;
  background: #edf6f3;
  box-shadow: inset 0 0 0 3px #fff;
}

.context-tutor-mark::after {
  content: "";
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 7px;
  height: 7px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #22a06b;
}

.tutor-teacher-avatar {
  position: relative;
  width: 34px;
  height: 34px;
  display: block;
  overflow: hidden;
  border: 1px solid #b8d9d1;
  border-radius: 50%;
  background: #dceee9;
}

.tutor-teacher-face {
  position: absolute;
  z-index: 2;
  left: 8px;
  top: 7px;
  width: 18px;
  height: 20px;
  border: 1px solid #bf8067;
  border-radius: 48% 48% 45% 45%;
  background: #f4b99a;
}

.tutor-teacher-hair {
  position: absolute;
  z-index: 3;
  left: 7px;
  top: 5px;
  width: 21px;
  height: 10px;
  border-radius: 11px 11px 4px 4px;
  background: #263a36;
  clip-path: polygon(0 0, 100% 0, 100% 74%, 76% 55%, 61% 89%, 38% 59%, 19% 84%, 0 68%);
}

.tutor-teacher-eye {
  position: absolute;
  top: 9px;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #263a36;
}

.tutor-teacher-eye-left { left: 4px; }
.tutor-teacher-eye-right { right: 4px; }

.tutor-teacher-smile {
  position: absolute;
  left: 6px;
  top: 13px;
  width: 5px;
  height: 3px;
  border-right: 1px solid #8a463e;
  border-bottom: 1px solid #8a463e;
  border-radius: 0 0 5px;
  transform: rotate(45deg);
}

.tutor-teacher-collar {
  position: absolute;
  left: 5px;
  bottom: -8px;
  width: 24px;
  height: 17px;
  border-radius: 9px 9px 0 0;
  background: #087f6d;
}

.tutor-mascot {
  position: relative;
  width: 58px;
  height: 66px;
  display: block;
  transform-origin: center bottom;
}

.tutor-mascot-launcher {
  position: absolute;
  left: 10px;
  top: 0;
  animation: tutorMascotFloat 3.4s ease-in-out infinite;
}

.tutor-mascot-header {
  position: absolute;
  left: 4px;
  top: 1px;
  transform: scale(.56);
  transform-origin: top left;
}

.tutor-mascot-shadow {
  position: absolute;
  left: 12px;
  bottom: 0;
  width: 36px;
  height: 7px;
  border-radius: 50%;
  background: rgba(24, 56, 49, .17);
  filter: blur(2px);
  animation: tutorMascotShadow 3.4s ease-in-out infinite;
}

.tutor-mascot-body {
  position: absolute;
  left: 14px;
  bottom: 5px;
  width: 31px;
  height: 28px;
  border: 2px solid #064f45;
  border-radius: 12px 12px 7px 7px;
  background: #0c7d6c;
  overflow: visible;
  animation: tutorMascotBreathe 2.7s ease-in-out infinite;
}

.tutor-mascot-neck {
  position: absolute;
  z-index: 1;
  left: 10px;
  top: -6px;
  width: 8px;
  height: 8px;
  border: 1px solid #c48265;
  background: #f0b494;
}

.tutor-mascot-shirt {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 9px 9px 5px 5px;
}

.tutor-mascot-shirt::before {
  content: "";
  position: absolute;
  left: 11px;
  top: -2px;
  width: 7px;
  height: 7px;
  border-right: 2px solid #d4eee8;
  border-bottom: 2px solid #d4eee8;
  transform: rotate(45deg);
}

.tutor-mascot-badge {
  position: absolute;
  right: 4px;
  top: 9px;
  width: 8px;
  height: 8px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #f4b44f;
  color: #5d3a05;
  font: 700 5px/1 sans-serif;
}

.tutor-mascot-arm {
  position: absolute;
  z-index: -1;
  width: 8px;
  height: 23px;
  border: 2px solid #064f45;
  border-radius: 6px;
  background: #0c7d6c;
}

.tutor-mascot-arm-left {
  left: -6px;
  top: 5px;
  transform: rotate(12deg);
}

.tutor-mascot-arm-right {
  right: -7px;
  top: 1px;
  transform: rotate(-32deg);
  transform-origin: 4px 19px;
  animation: tutorMascotWave 3.4s ease-in-out infinite;
}

.tutor-mascot-hand {
  position: absolute;
  left: -1px;
  top: -7px;
  width: 7px;
  height: 9px;
  border: 1px solid #c48265;
  border-radius: 5px 5px 4px 4px;
  background: #f0b494;
}

.tutor-mascot-head {
  position: absolute;
  z-index: 3;
  left: 10px;
  top: 1px;
  width: 39px;
  height: 38px;
  border: 2px solid #263a36;
  border-radius: 46% 46% 44% 44%;
  background: #f5bd9e;
  animation: tutorMascotNod 4.2s ease-in-out infinite;
}

.tutor-mascot-ear {
  position: absolute;
  top: 17px;
  width: 6px;
  height: 9px;
  border: 1px solid #c48265;
  background: #f0aa8a;
}

.tutor-mascot-ear-left { left: -5px; border-radius: 6px 2px 2px 6px; }
.tutor-mascot-ear-right { right: -5px; border-radius: 2px 6px 6px 2px; }

.tutor-mascot-hair {
  position: absolute;
  z-index: 2;
  left: -1px;
  top: -2px;
  width: 37px;
  height: 16px;
  border-radius: 20px 19px 7px 6px;
  background: #263a36;
  clip-path: polygon(0 0, 100% 0, 100% 62%, 83% 52%, 72% 84%, 56% 57%, 38% 88%, 24% 57%, 0 77%);
}

.tutor-mascot-face { position: absolute; inset: 0; }

.tutor-mascot-eye {
  position: absolute;
  top: 19px;
  width: 4px;
  height: 5px;
  border-radius: 50%;
  background: #263a36;
  transform-origin: center;
  animation: tutorMascotBlink 5.2s infinite;
}

.tutor-mascot-eye-left { left: 9px; }
.tutor-mascot-eye-right { right: 9px; }

.tutor-mascot-brow {
  position: absolute;
  top: 15px;
  width: 7px;
  height: 2px;
  border-radius: 2px;
  background: #5a443d;
}

.tutor-mascot-brow-left { left: 7px; transform: rotate(-5deg); }
.tutor-mascot-brow-right { right: 7px; transform: rotate(5deg); }

.tutor-mascot-cheek {
  position: absolute;
  top: 25px;
  width: 6px;
  height: 3px;
  border-radius: 50%;
  background: rgba(217, 105, 93, .28);
}

.tutor-mascot-cheek-left { left: 4px; }
.tutor-mascot-cheek-right { right: 4px; }

.tutor-mascot-mouth {
  position: absolute;
  left: 15px;
  top: 26px;
  width: 6px;
  height: 4px;
  border-right: 1.5px solid #8a463e;
  border-bottom: 1.5px solid #8a463e;
  border-radius: 0 0 6px 0;
  transform: rotate(45deg);
}

.context-tutor.is-thinking .tutor-mascot-launcher {
  animation-duration: 1.35s;
}

.context-tutor.is-thinking .tutor-mascot-eye {
  animation: tutorMascotThink 1.1s ease-in-out infinite alternate;
}

@keyframes tutorMascotFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

@keyframes tutorMascotShadow {
  0%, 100% { transform: scaleX(1); opacity: .85; }
  50% { transform: scaleX(.84); opacity: .55; }
}

@keyframes tutorMascotBreathe {
  0%, 100% { transform: scaleX(1); }
  50% { transform: scaleX(1.035); }
}

@keyframes tutorMascotWave {
  0%, 50%, 100% { transform: rotate(-32deg); }
  8% { transform: rotate(-58deg); }
  16% { transform: rotate(-25deg); }
  24% { transform: rotate(-55deg); }
  32% { transform: rotate(-30deg); }
}

@keyframes tutorMascotNod {
  0%, 68%, 100% { transform: rotate(0); }
  74% { transform: rotate(3deg); }
  82% { transform: rotate(-2deg); }
}

@keyframes tutorMascotBlink {
  0%, 44%, 48%, 100% { transform: scaleY(1); }
  46% { transform: scaleY(.08); }
}

@keyframes tutorMascotThink {
  from { transform: translateX(-1px); }
  to { transform: translateX(1px); }
}

.context-tutor-title {
  min-width: 0;
}

.context-tutor-title strong,
.context-tutor-title span {
  display: block;
}

.context-tutor-title strong {
  color: #173b34;
  font-size: 15px;
  font-weight: 760;
  line-height: 1.35;
}

.context-tutor-title span {
  margin-top: 3px;
  overflow: hidden;
  color: var(--tutor-muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-tutor-title span i {
  width: 5px;
  height: 5px;
  display: inline-block;
  margin-right: 5px;
  border-radius: 50%;
  background: #22a06b;
  vertical-align: 1px;
}

.context-tutor-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #657772;
}

.context-tutor-icon:hover {
  background: #edf3f1;
  color: var(--tutor-ink);
}

.context-tutor-icon:disabled {
  opacity: .32;
  pointer-events: none;
}

.context-tutor-icon svg,
.context-tutor-send svg,
.selection-tutor-actions svg,
.context-tutor-context svg,
.context-tutor-suggestions svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.context-tutor-context {
  min-width: 0;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  border-bottom: 1px solid #e9efed;
  background: #f2f7f5;
}

.context-tutor-context-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid #c9ded8;
  border-radius: 7px;
  background: #fff;
  color: var(--tutor-brand);
}

.context-tutor-context-icon svg { width: 15px; height: 15px; }

.context-tutor-context > div {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.context-tutor-context b {
  flex: 0 0 auto;
  color: var(--tutor-brand-deep);
  font-size: 9px;
  font-weight: 750;
  line-height: 1.3;
  white-space: nowrap;
}

.context-tutor-context div > span {
  min-width: 0;
  margin-top: 0;
  overflow: hidden;
  color: #4f625d;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-tutor-thread {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 17px 14px 13px;
  background: #fcfdfd;
  scroll-behavior: smooth;
}

.context-tutor-empty {
  margin: auto 0;
  padding: 14px;
  border: 1px solid #dce7e4;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(17, 63, 54, .05);
}

.context-tutor-empty-intro {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: start;
  gap: 11px;
}

.context-tutor-empty-avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #c7ddd7;
  border-radius: 8px;
  background: #edf6f3;
}

.context-tutor-empty-avatar .tutor-teacher-avatar { transform: scale(1.08); }

.context-tutor-empty em,
.context-tutor-empty strong,
.context-tutor-empty-intro span {
  display: block;
}

.context-tutor-empty em {
  margin-bottom: 3px;
  color: var(--tutor-brand);
  font-size: 9px;
  font-style: normal;
  font-weight: 750;
}

.context-tutor-empty strong {
  font-size: 14px;
  line-height: 1.45;
}

.context-tutor-empty-intro div > span {
  margin-top: 5px;
  color: var(--tutor-muted);
  font-size: 11px;
  line-height: 1.65;
}

.context-tutor-message {
  max-width: 92%;
}

.context-tutor-message.student {
  align-self: flex-end;
}

.context-tutor-message.teacher {
  align-self: flex-start;
}

.context-tutor-message-meta {
  min-height: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 5px 2px;
}

.context-tutor-message small {
  display: block;
  color: #83908d;
  font-size: 9px;
}

.context-tutor-message-disclosure {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 0 6px;
  border: 1px solid #c7dcd6;
  color: #42665e;
  background: #f3f8f6;
  border-radius: 4px;
  font-size: 8px;
  line-height: 1;
}

.context-tutor-message.student .context-tutor-message-meta {
  justify-content: flex-end;
  margin-right: 2px;
}

.context-tutor-message-avatar {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #c9ded8;
  border-radius: 5px;
  background: #edf6f3;
}

.context-tutor-message-avatar .tutor-teacher-avatar {
  transform: scale(.5);
}

.context-tutor-bubble {
  margin: 0;
  padding: 11px 12px;
  border: 1px solid var(--tutor-line);
  border-radius: 8px;
  background: #f3f7f6;
  font-size: 12px;
  line-height: 1.75;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.context-tutor-message.student .context-tutor-bubble {
  border-color: var(--tutor-brand-deep);
  background: var(--tutor-brand-deep);
  color: #fff;
}

.context-tutor-message.loading .context-tutor-bubble::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 12px;
  margin-left: 3px;
  vertical-align: -2px;
  background: var(--tutor-brand);
  animation: tutorCursor .8s steps(1) infinite;
}

.context-tutor-message.error .context-tutor-bubble {
  border-color: #e4c4bf;
  background: #fff3f1;
  color: #883d36;
}

@keyframes tutorCursor { 50% { opacity: 0; } }

.context-tutor-suggestions {
  min-height: 42px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 5px 11px;
  border-top: 1px solid #edf1f0;
  background: #fbfcfc;
  scrollbar-width: none;
}

.context-tutor-suggestions::-webkit-scrollbar {
  display: none;
}

.context-tutor-suggestions button {
  min-width: 0;
  min-height: 31px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 7px;
  border: 1px solid #d5e0dd;
  border-radius: 5px;
  background: #fff;
  color: #49605a;
  font-size: 10px;
  font-weight: 680;
  white-space: nowrap;
}

.context-tutor-suggestions svg { width: 14px; height: 14px; flex: 0 0 auto; }

.context-tutor-suggestions button:hover {
  border-color: #9ebdb5;
  color: var(--tutor-brand-deep);
}

.context-tutor-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  align-items: end;
  gap: 8px;
  padding: 9px 11px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--tutor-line);
  background: #fff;
}

.context-tutor-composer textarea {
  width: 100%;
  max-height: 96px;
  min-height: 40px;
  resize: none;
  padding: 10px 11px;
  border: 1px solid #cfdad7;
  border-radius: 8px;
  background: #fbfcfc;
  font-size: 12px;
  line-height: 1.55;
}

.context-tutor-composer textarea:focus {
  border-color: #7eaca1;
  background: #fff;
}

.context-tutor-send {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--tutor-brand-deep);
  color: #fff;
}

.context-tutor-send:hover {
  background: #064f45;
}

.context-tutor-send.stop {
  background: #a14940;
}

.selection-tutor-actions {
  --tutor-brand-deep: #075f53;
  position: fixed;
  z-index: 95;
  width: min(310px, calc(100vw - 16px));
  padding: 10px;
  border: 1px solid #d5dfdc;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 26px rgba(11, 43, 37, .18);
  animation: tutorSelectionIn .14s ease-out;
}

.selection-tutor-actions,
.selection-tutor-actions *,
.tutor-selection-guide,
.tutor-selection-guide * {
  box-sizing: border-box;
  letter-spacing: 0;
}

.selection-tutor-actions[hidden] {
  display: none;
}

[data-tutor-content],
[data-tutor-content] p,
[data-tutor-content] span,
[data-tutor-content] h1,
[data-tutor-content] h2,
[data-tutor-content] h3,
[data-tutor-content] li {
  -webkit-user-select: text;
  user-select: text;
}

.app-view.active:not(.hidden) {
  -webkit-user-select: text;
  user-select: text;
}

.app-view.active:not(.hidden) :is(button, a[href], input, textarea, select, option, label, [role="button"], [contenteditable="true"]) {
  -webkit-user-select: none;
  user-select: none;
}

.selection-tutor-copy span,
.selection-tutor-copy strong {
  display: block;
}

.selection-tutor-copy span {
  color: #74827e;
  font: 650 9px/1.3 Inter, ui-sans-serif, system-ui, "Microsoft YaHei", sans-serif;
}

.selection-tutor-copy strong {
  margin-top: 4px;
  overflow: hidden;
  color: #203c36;
  font: 650 11px/1.55 Inter, ui-sans-serif, system-ui, "Microsoft YaHei", sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-tutor-buttons {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 6px;
  margin-top: 9px;
}

.selection-tutor-actions button {
  min-height: 32px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  border: 1px solid #cbdad6;
  border-radius: 5px;
  background: #fff;
  color: #314944;
  font: 700 11px/1 Inter, ui-sans-serif, system-ui, "Microsoft YaHei", sans-serif;
}

.selection-tutor-actions button:hover {
  background: #edf5f2;
  color: var(--tutor-brand-deep);
}

.selection-tutor-actions button:first-child {
  border-color: var(--tutor-brand-deep);
  background: var(--tutor-brand-deep);
  color: #fff;
}

@keyframes tutorSelectionIn {
  from { opacity: 0; transform: translateY(4px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.tutor-selection-guide {
  --tutor-brand-deep: #075f53;
  position: fixed;
  z-index: 79;
  right: 110px;
  bottom: 25px;
  width: min(300px, calc(100vw - 24px));
  padding: 15px 40px 14px 15px;
  border: 1px solid #cdded9;
  border-radius: 8px;
  background: #fff;
  color: #1b3530;
  box-shadow: 0 18px 44px rgba(11, 43, 37, .17);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  animation: tutorPanelIn .18s ease-out;
}

.tutor-selection-guide[hidden] { display: none; }

.tutor-selection-guide::after {
  content: "";
  position: absolute;
  right: -6px;
  bottom: 28px;
  width: 10px;
  height: 10px;
  border-top: 1px solid #cdded9;
  border-right: 1px solid #cdded9;
  background: #fff;
  transform: rotate(45deg);
}

.tutor-selection-guide strong {
  display: block;
  font-size: 13px;
  line-height: 1.4;
}

.tutor-selection-guide p {
  margin: 6px 0 11px;
  color: #60716d;
  font-size: 11px;
  line-height: 1.65;
}

.tutor-selection-guide-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: #70807c;
}

.tutor-selection-guide-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.tutor-selection-guide button:focus-visible {
  outline: 3px solid rgba(8, 127, 109, .22);
  outline-offset: 2px;
}

.tutor-selection-demo {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--tutor-brand-deep);
  border-radius: 5px;
  background: var(--tutor-brand-deep);
  color: #fff;
  font-size: 11px;
  font-weight: 750;
}

.tutor-guide-mobile { display: none; }
}

.context-tutor mjx-container {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

@media (max-width: 720px) {
  .context-tutor {
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom));
  }

  body[data-view-layer="secondary"] .context-tutor,
  body[data-tutor-surface="lab"] .context-tutor {
    bottom: calc(12px + env(safe-area-inset-bottom));
  }

  body[data-tutor-surface="lab"] .context-tutor:not(.is-open) {
    right: 4px;
  }

  body[data-tutor-surface="lab"] .context-tutor:not(.is-open) .context-tutor-launcher {
    width: 48px;
    height: 56px;
  }

  body[data-tutor-surface="lab"] .context-tutor:not(.is-open) .tutor-mascot-launcher {
    left: 3px;
    transform: scale(.7);
    transform-origin: left bottom;
    animation: none;
  }

  body[data-tutor-surface="lab"] .context-tutor:not(.is-open) .context-tutor-launcher-label {
    min-width: 46px;
    padding: 3px 5px 4px;
    font-size: 8px;
  }

  .context-tutor-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(82px + env(safe-area-inset-bottom));
    width: auto;
    height: min(54dvh, 500px);
    min-height: min(330px, calc(100dvh - 118px));
    max-height: calc(100dvh - 118px);
  }

  body[data-view-layer="secondary"] .context-tutor-panel,
  body[data-tutor-surface="lab"] .context-tutor-panel {
    bottom: calc(82px + env(safe-area-inset-bottom));
  }

  .context-tutor-launcher {
    width: 70px;
    height: 80px;
  }

  .tutor-mascot-launcher {
    left: 6px;
    transform: scale(.94);
  }

  .context-tutor-welcome {
    display: none;
  }

  .tutor-selection-guide {
    right: 76px;
    bottom: calc(91px + env(safe-area-inset-bottom));
  }

  .tutor-selection-guide::after {
    right: 24px;
    bottom: -6px;
    transform: rotate(135deg);
  }

  .tutor-guide-desktop { display: none; }
  .tutor-guide-mobile { display: inline; }

  .selection-tutor-actions {
    width: min(330px, calc(100vw - 16px));
  }

  .selection-tutor-actions.is-mobile-dock {
    right: 8px;
    bottom: calc(82px + env(safe-area-inset-bottom));
    left: 8px;
    top: auto;
    width: auto;
    box-shadow: 0 14px 38px rgba(11, 43, 37, .24);
  }
}

@media (prefers-reduced-motion: reduce) {
  .context-tutor-panel,
  .context-tutor-launcher,
  .context-tutor-message.loading .context-tutor-bubble::after,
  .tutor-mascot-launcher,
  .tutor-mascot-shadow,
  .tutor-mascot-body,
  .tutor-mascot-head,
  .tutor-mascot-eye,
  .tutor-mascot-arm-right,
  .context-tutor-welcome,
  .selection-tutor-actions,
  .tutor-selection-guide {
    animation: none;
    transition: none;
  }
}

body[data-active-view="home"].dialog-open .context-tutor {
  display: none;
}

body[data-active-view="admin"] .context-tutor {
  display: none;
}

@media (max-width: 720px) {
  body[data-active-view="practice"] .context-tutor:not(.is-open) {
    right: 4px;
    bottom: calc(10px + env(safe-area-inset-bottom));
  }

  body[data-active-view="practice"] .context-tutor:not(.is-open) .context-tutor-launcher {
    width: 56px;
    height: 64px;
    opacity: .9;
  }

  body[data-active-view="practice"] .context-tutor:not(.is-open) .tutor-mascot-launcher {
    left: 2px;
    transform: scale(.72);
    transform-origin: center bottom;
  }

  body[data-active-view="practice"] .context-tutor:not(.is-open) .context-tutor-launcher-label {
    min-width: 46px;
    padding-inline: 5px;
    font-size: 9px;
  }
}

@media (min-width: 721px) {
  body[data-active-view="video"] .context-tutor {
    top: 118px;
    bottom: auto;
  }

  body[data-active-view="video"] .context-tutor-panel {
    position: fixed;
    top: 118px;
    right: 22px;
    bottom: auto;
    height: min(640px, calc(100dvh - 140px));
  }
}

body.tutor-video-task-visible .context-tutor {
  bottom: 104px;
}

body.tutor-video-task-visible .context-tutor:not(.is-open) {
  right: 4px;
}

body.tutor-video-task-visible .context-tutor:not(.is-open) .context-tutor-launcher {
  width: 48px;
  height: 52px;
}

body.tutor-video-task-visible .context-tutor:not(.is-open) .tutor-mascot-launcher {
  left: 4px;
  transform: scale(.68);
  transform-origin: left bottom;
  animation: none;
}

body.tutor-video-task-visible .context-tutor:not(.is-open) .context-tutor-launcher-label,
body.tutor-video-task-visible .context-tutor:not(.is-open) .context-tutor-welcome {
  display: none;
}

body.tutor-video-task-visible .tutor-selection-guide {
  bottom: 107px;
}

body[data-tutor-surface="lab"] .tutor-selection-guide {
  display: none !important;
}

body[data-active-view="chat"] .tutor-selection-guide {
  display: none !important;
}

@media (max-width: 720px) {
  body.tutor-video-task-visible .context-tutor,
  body[data-view-layer="secondary"].tutor-video-task-visible .context-tutor,
  body[data-tutor-surface="lab"].tutor-video-task-visible .context-tutor {
    bottom: calc(150px + env(safe-area-inset-bottom));
  }

  body.tutor-video-task-visible .context-tutor-panel,
  body[data-view-layer="secondary"].tutor-video-task-visible .context-tutor-panel,
  body[data-tutor-surface="lab"].tutor-video-task-visible .context-tutor-panel {
    bottom: calc(150px + env(safe-area-inset-bottom));
    max-height: calc(100dvh - 178px);
  }

  body.tutor-video-task-visible .tutor-selection-guide {
    bottom: calc(164px + env(safe-area-inset-bottom));
  }

  .tutor-selection-guide {
    right: 72px;
    width: min(244px, calc(100vw - 92px));
    padding: 12px 34px 11px 12px;
  }

  .tutor-selection-guide p {
    margin: 4px 0 8px;
    line-height: 1.5;
  }
}

/* V3 surface treatment. Keep the current teacher character and behavior intact. */
.context-tutor {
  --tutor-line: #e3e8e6;
  --tutor-soft: #f6f8f7;
}

.context-tutor-launcher {
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, .16));
}

.context-tutor-launcher-label {
  border-color: rgba(255, 255, 255, .72);
  background: #173d37;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .13);
}

.context-tutor-panel {
  width: min(408px, calc(100vw - 28px));
  height: min(660px, calc(100dvh - 112px));
  border-color: rgba(0, 0, 0, .1);
  border-radius: 8px;
  box-shadow: 0 34px 90px rgba(0, 0, 0, .22), 0 3px 12px rgba(0, 0, 0, .06);
}

.context-tutor-head {
  min-height: 68px;
  padding: 10px 13px;
  border-bottom-color: rgba(0, 0, 0, .07);
  background: rgba(250, 251, 251, .9);
  backdrop-filter: saturate(150%) blur(16px);
}

.context-tutor-head::before {
  display: none;
}

.context-tutor-mark {
  border-color: rgba(8, 127, 109, .14);
  background: #eef7f4;
  box-shadow: 0 7px 18px rgba(8, 127, 109, .08);
}

.context-tutor-context {
  min-height: 48px;
  padding: 8px 13px;
  border-bottom-color: rgba(0, 0, 0, .055);
  background: #f7f9f8;
}

.context-tutor-context-icon {
  border-color: rgba(0, 0, 0, .07);
  background: #fff;
}

.context-tutor-context b {
  font-size: 9px;
}

.context-tutor-context div > span {
  font-size: 11px;
}

.context-tutor-thread {
  gap: 17px;
  padding: 20px 15px 16px;
  background: #fbfcfc;
}

.context-tutor-empty {
  padding: 17px;
  border-color: rgba(0, 0, 0, .07);
  background: #fff;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .055);
}

.context-tutor-empty strong {
  font-size: 15px;
}

.context-tutor-message {
  max-width: 90%;
}

.context-tutor-bubble {
  padding: 12px 13px;
  border-color: rgba(0, 0, 0, .07);
  border-radius: 8px;
  background: #f1f4f3;
  font-size: 12px;
  line-height: 1.8;
}

.context-tutor-message.student .context-tutor-bubble {
  border-color: #173d37;
  background: #173d37;
}

.context-tutor-suggestions {
  min-height: 48px;
  gap: 7px;
  padding: 7px 11px;
  border-top-color: rgba(0, 0, 0, .055);
  background: #fafbfb;
}

.context-tutor-suggestions button {
  min-height: 34px;
  border-color: rgba(0, 0, 0, .075);
  border-radius: 7px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .025);
}

.context-tutor-composer {
  gap: 9px;
  padding: 10px 11px calc(11px + env(safe-area-inset-bottom));
  border-top-color: rgba(0, 0, 0, .07);
}

.context-tutor-composer textarea {
  min-height: 42px;
  padding: 10px 12px;
  border-color: rgba(0, 0, 0, .1);
  border-radius: 8px;
  background: #f7f8f8;
  font-size: 12px;
}

.context-tutor-send {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #173d37;
  box-shadow: 0 7px 18px rgba(23, 61, 55, .18);
}

.selection-tutor-actions,
.tutor-selection-guide {
  border-color: rgba(0, 0, 0, .09);
  box-shadow: 0 22px 56px rgba(0, 0, 0, .18);
}

@media (max-width: 720px) {
  .context-tutor-panel {
    left: 10px;
    right: 10px;
    bottom: calc(80px + env(safe-area-inset-bottom));
    height: min(58dvh, 520px);
    min-height: min(350px, calc(100dvh - 120px));
  }

  .context-tutor-head {
    min-height: 60px;
  }

  .context-tutor-thread {
    padding: 15px 12px 12px;
  }

  .context-tutor-empty {
    padding: 14px;
  }

  .context-tutor-suggestions {
    display: flex;
    overflow-x: auto;
  }

  .context-tutor-suggestions button {
    flex: 0 0 auto;
    padding-inline: 10px;
  }
}

/* Mobile dock: the closed assistant finds a free edge slot; the open assistant
   becomes a focused drawer instead of covering whichever action sits below it. */
@media (max-width: 720px) {
  body.context-tutor-open {
    overflow: hidden;
  }

  .context-tutor {
    right: 6px;
    top: auto;
    bottom: calc(84px + env(safe-area-inset-bottom));
  }

  .context-tutor:not(.is-open) .context-tutor-launcher {
    width: 52px;
    height: 58px;
    opacity: .96;
  }

  .context-tutor:not(.is-open) .tutor-mascot-launcher {
    left: -2px;
    top: -9px;
    scale: .68;
    transform-origin: bottom center;
    animation: none;
  }

  .context-tutor:not(.is-open) .context-tutor-launcher-label {
    min-width: 46px;
    padding: 3px 5px 4px;
    font-size: 8px;
  }

  .context-tutor.is-open::before {
    content: "";
    position: fixed;
    z-index: 0;
    inset: 0;
    background: rgba(9, 24, 20, .3);
    backdrop-filter: blur(2px);
  }

  .context-tutor.is-open .context-tutor-panel,
  body[data-view-layer="secondary"] .context-tutor.is-open .context-tutor-panel,
  body[data-tutor-surface="lab"] .context-tutor.is-open .context-tutor-panel,
  body.tutor-video-task-visible .context-tutor.is-open .context-tutor-panel {
    position: fixed;
    z-index: 1;
    inset: calc(8px + env(safe-area-inset-top)) 8px calc(8px + env(safe-area-inset-bottom));
    width: auto;
    height: auto;
    min-height: 0;
    max-height: none;
    border-radius: 12px;
  }

  .context-tutor.is-open .context-tutor-thread {
    padding-bottom: 16px;
  }
}
/* Shared assistant presentation: mini-program teacher, web-native behavior. */
.context-tutor-launcher {
  width: 72px;
  height: 72px;
  padding: 6px;
  justify-content: center;
  overflow: visible;
  border: 1px solid rgba(46, 189, 199, .46);
  border-radius: 50%;
  background: rgba(248, 254, 253, .94);
  box-shadow: 0 14px 34px rgba(10, 90, 82, .15), inset 0 1px 0 #fff;
  filter: none;
  backdrop-filter: blur(16px);
}

.context-tutor-launcher:hover {
  background: #fff;
  box-shadow: 0 18px 42px rgba(10, 90, 82, .19), inset 0 1px 0 #fff;
  filter: none;
}

.context-tutor-launcher::after { display: none; }

.tutor-image-avatar {
  display: block;
  overflow: hidden;
  border-radius: 50%;
  background: #e5f8f6;
}

.tutor-image-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
  user-select: none;
}

.tutor-image-avatar-launcher {
  width: 58px;
  height: 58px;
  animation: tutorAvatarFloat 3.8s ease-in-out infinite;
}

.context-tutor-launcher-label {
  min-width: 31px;
  height: 23px;
  position: absolute;
  right: -3px;
  bottom: -2px;
  display: grid;
  padding: 0 6px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 12px;
  color: #fff;
  background: #087f72;
  box-shadow: 0 5px 13px rgba(8, 127, 114, .22);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
}

@keyframes tutorAvatarFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

.context-tutor-panel {
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  border-radius: 16px;
}

.context-tutor-handle { display: none; }

.context-tutor-head {
  grid-template-columns: 44px minmax(0, 1fr) auto auto;
  min-height: 70px;
}

.context-tutor-mark {
  width: 44px;
  height: 44px;
  padding: 2px;
  overflow: hidden;
  border-radius: 50%;
  background: #e8f8f6;
}

.context-tutor-mark::after { display: none; }

.tutor-image-avatar-header {
  width: 100%;
  height: 100%;
}

.context-tutor-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .context-tutor:not(.is-open) .context-tutor-launcher {
    width: 62px;
    height: 62px;
    padding: 5px;
  }

  .context-tutor:not(.is-open) .tutor-image-avatar-launcher {
    width: 50px;
    height: 50px;
    animation: tutorAvatarFloat 3.8s ease-in-out infinite;
    scale: 1;
  }

  .context-tutor:not(.is-open) .context-tutor-launcher-label {
    min-width: 28px;
    height: 21px;
    display: grid;
    padding: 0 5px;
    font-size: 8px;
  }

  .context-tutor.is-open .context-tutor-panel,
  body[data-view-layer="secondary"] .context-tutor.is-open .context-tutor-panel,
  body[data-tutor-surface="lab"] .context-tutor.is-open .context-tutor-panel,
  body.tutor-video-task-visible .context-tutor.is-open .context-tutor-panel {
    inset: auto 8px 8px;
    height: min(72dvh, 660px);
    min-height: min(520px, calc(100dvh - 38px));
    grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
    border-radius: 22px 22px 0 0;
  }

  .context-tutor-handle {
    width: 40px;
    height: 4px;
    display: block;
    margin: 9px auto 1px;
    border-radius: 2px;
    background: #c8d9d5;
  }

  .context-tutor-head {
    min-height: 64px;
    padding-top: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tutor-image-avatar-launcher { animation: none; }
}
