:root {
  --ink: #142b2f;
  --ink-2: #244b4e;
  --muted: #6b7f7e;
  --muted-2: #8a9a97;
  --paper: #f7f3e9;
  --paper-2: #efe8da;
  --white: #fffdf8;
  --teal: #0f766e;
  --teal-dark: #0a5b56;
  --teal-soft: #d9f0e9;
  --coral: #df6a4f;
  --coral-soft: #fbe3da;
  --gold: #e5b34d;
  --line: #ded5c6;
  --line-dark: rgba(255, 255, 255, 0.12);
  --nav-w: 232px;
  --chat-w: clamp(336px, 31vw, 404px);
  --radius: 20px;
  --shadow: 0 18px 46px rgba(29, 48, 47, 0.12);
  --shadow-soft: 0 8px 24px rgba(29, 48, 47, 0.08);
  --font: "PingFang SC", "Noto Sans SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--paper-2);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, textarea, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.35);
  outline-offset: 2px;
}
svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.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;
}

.app {
  display: grid;
  grid-template-columns: var(--nav-w) var(--chat-w) minmax(0, 1fr);
  /* Chrome 97 (Lenovo WebView) has no dvh; 100% tracks the visible viewport. */
  height: 100%;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: var(--paper-2);
}

/* ---------- sidebar ---------- */
.sidebar {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px calc(14px + env(safe-area-inset-bottom));
  color: #eaf4ef;
  background:
    radial-gradient(circle at 18% 0%, rgba(61, 151, 137, 0.25), transparent 34%),
    linear-gradient(180deg, #102c2f 0%, #0d2427 100%);
  position: relative;
  z-index: 20;
  overflow-y: auto;
  scrollbar-width: thin;
}
.brand { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 2px 6px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 13px;
  display: grid; place-items: center;
  color: #ffe9b0;
  background: linear-gradient(145deg, rgba(255, 222, 143, 0.24), rgba(255, 255, 255, 0.06));
  border: 1px solid rgba(255, 235, 180, 0.22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}
.brand-mark svg { width: 21px; height: 21px; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-copy strong { font-size: 15px; letter-spacing: .02em; white-space: nowrap; }
.brand-copy span { font-size: 10px; color: #91aaa2; letter-spacing: .08em; margin-top: 4px; text-transform: uppercase; }
.sidebar-close { display: none; margin-left: auto; color: #d7e8e2; }
.learner-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.learner-avatar {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 13px;
  background: #f6dca8;
  font-size: 22px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.08);
}
.learner-copy { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.learner-copy strong { font-size: 14px; }
.learner-copy span { font-size: 10.5px; color: #9fb5ad; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: #61d3a4; margin-left: auto; box-shadow: 0 0 0 4px rgba(97, 211, 164, 0.12); flex: none; }

.nav { display: flex; flex-direction: column; gap: 5px; margin-top: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 45px;
  padding: 0 12px;
  border: 0; border-radius: 13px;
  color: #bdd0c9;
  background: transparent;
  text-align: left;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.nav-item svg { width: 19px; height: 19px; opacity: .9; }
.nav-item span { font-size: 14px; font-weight: 590; }
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.nav-item:active { transform: scale(.985); }
.nav-item.is-active { color: #102c2f; background: #f4dfa8; box-shadow: 0 8px 18px rgba(0,0,0,.14); }
.nav-item.is-active svg { opacity: 1; }

.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.streak-card {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.streak-emoji { font-size: 19px; }
.streak-card div { display: flex; flex-direction: column; line-height: 1.25; }
.streak-card strong { font-size: 12px; color: #f1e6c4; }
.streak-card span { font-size: 10px; color: #8fa8a0; margin-top: 3px; }
.teacher-link {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px;
  border-radius: 12px;
  color: #9fb5ad;
  font-size: 11.5px;
  text-decoration: none;
  border: 1px dashed rgba(255,255,255,.13);
}
.teacher-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.teacher-link svg { width: 17px; height: 17px; }

/* ---------- chat ---------- */
.chat-panel {
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  background: #fbf8f0;
  border-left: 1px solid rgba(20, 43, 47, 0.06);
  border-right: 1px solid rgba(20, 43, 47, 0.1);
  position: relative;
  z-index: 10;
}
.chat-header {
  display: flex; align-items: center; gap: 11px;
  min-height: 67px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(20, 43, 47, 0.08);
  background: rgba(251, 248, 240, 0.92);
  backdrop-filter: blur(12px);
}
.tutor-identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tutor-avatar {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  color: #fffdf7;
  background: linear-gradient(145deg, #164e4b, #0f766e);
  font-weight: 700; font-size: 15px;
  box-shadow: 0 5px 12px rgba(15, 118, 110, .24), inset 0 1px 0 rgba(255,255,255,.24);
}
.tutor-identity strong { display: block; font-size: 14px; line-height: 1.2; }
.tutor-identity span { display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #45b98a; display: inline-block; }
.chat-header .icon-button:last-child { margin-left: auto; }

.icon-button {
  width: 40px; height: 40px;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 12px;
  color: var(--ink-2);
  background: transparent;
  flex: none;
}
.icon-button:hover { background: rgba(20, 43, 47, 0.06); }
.icon-button:active { transform: scale(.96); }
/* 必须放在 .icon-button 之后：两者同为单类选择器，靠顺序覆盖 display，否则汉堡在桌面也常显 */
.menu-button { display: none; }

.chat-scroll {
  flex: 1; min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 14px 10px;
  scrollbar-width: thin;
  scrollbar-color: #d8cfbf transparent;
}
.day-divider { display: flex; align-items: center; gap: 10px; margin: 2px 0 16px; }
.day-divider::before, .day-divider::after { content: ""; height: 1px; background: #e5dccb; flex: 1; }
.day-divider span { font-size: 10px; color: #8b9b96; letter-spacing: .03em; white-space: nowrap; }

.message-list { display: flex; flex-direction: column; gap: 14px; }
.message { display: flex; align-items: flex-start; gap: 8px; max-width: 100%; animation: rise .25s ease both; }
.message.is-user { flex-direction: row-reverse; }
.message-avatar {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  font-size: 12px;
  margin-top: 2px;
}
.message.is-tutor .message-avatar { color: #fff; background: #164e4b; }
.message.is-user .message-avatar { color: #7a3b29; background: #f4d3c8; }
.bubble {
  max-width: min(88%, 312px);
  padding: 11px 13px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.message.is-tutor .bubble {
  background: #fffdf8;
  border: 1px solid #e7ddcd;
  border-top-left-radius: 6px;
  color: #203b3e;
  box-shadow: 0 3px 10px rgba(29,48,47,.035);
}
.message.is-user .bubble {
  color: #fffdf7;
  background: #0f766e;
  border-top-right-radius: 6px;
  box-shadow: 0 5px 14px rgba(15,118,110,.18);
}
.message-meta { display: flex; align-items: center; gap: 8px; margin-top: 5px; font-size: 10px; color: #8d9c96; }
.message.is-user .message-meta { justify-content: flex-end; }
.read-aloud {
  border: 0; background: transparent; color: #6b8c85; padding: 0; font-size: 10px;
  display: inline-flex; align-items: center; gap: 3px;
}
.read-aloud:hover { color: var(--teal); }
.message.is-proactive .bubble { border-color: #b9ded3; background: #f1fbf7; }
.message-chip-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.message-chip {
  font-size: 9.5px; padding: 3px 7px; border-radius: 999px;
  color: #46655f; background: #eff5ef; border: 1px solid #dce8de;
}
.typing { display: inline-flex; gap: 3px; padding: 4px 1px; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: #7fa49b; animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

.quick-actions {
  display: flex; gap: 6px;
  padding: 6px 12px 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.quick-actions::-webkit-scrollbar { display: none; }
.quick-chip {
  flex: none;
  border: 1px solid #d9d0bf;
  background: #fffdf8;
  color: #45615c;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 11px;
  min-height: 34px;
}
.quick-chip:hover { border-color: #9dc7bc; background: #f4fbf8; color: #0f5f58; }
.quick-chip:active { transform: scale(.97); }

.composer {
  display: flex; align-items: flex-end; gap: 6px;
  margin: 6px 12px 0;
  padding: 5px 6px 5px 8px;
  border-radius: 18px;
  background: #fffdf8;
  border: 1px solid #ded5c6;
  box-shadow: 0 5px 18px rgba(29, 48, 47, 0.06);
}
.composer:focus-within { border-color: #86bdb2; box-shadow: 0 0 0 3px rgba(15,118,110,.08); }
.composer textarea {
  flex: 1; min-width: 0;
  resize: none;
  border: 0; outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  max-height: 104px;
  padding: 8px 2px;
}
.composer textarea::placeholder { color: #9ba9a4; }
.sound-button.is-off { color: #b45309; background: #fff3e0; }
.sound-button.is-off:hover { color: #92400e; }
.mic-button {
  width: 34px; height: 38px; border-radius: 12px; color: #78908a;
  transition: background .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.mic-button.is-recording {
  color: #fff; background: var(--coral);
  box-shadow: 0 0 0 4px rgba(223,106,79,.16);
  animation: mic-pulse 1.2s ease-in-out infinite;
}
.mic-button.is-busy { opacity: .55; }
@keyframes mic-pulse { 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) {
  .mic-button.is-recording { animation: none; }
}
.send-button {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 13px;
  color: #fff;
  background: var(--teal);
  box-shadow: 0 5px 12px rgba(15,118,110,.2);
}
.send-button:active { transform: scale(.95); }
.send-button svg { width: 18px; height: 18px; }
.privacy-note {
  margin: 7px 16px calc(8px + env(safe-area-inset-bottom));
  font-size: 9.5px;
  color: #95a39e;
  text-align: center;
}

/* ---------- stage ---------- */
.stage-panel {
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  background:
    radial-gradient(circle at 80% 0%, rgba(255, 255, 255, 0.36), transparent 38%),
    #e8e1d3;
  position: relative;
}
.stage-header {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  min-height: 72px;
  padding: 11px 18px;
  border-bottom: 1px solid rgba(20, 43, 47, 0.09);
  background: rgba(240, 234, 222, 0.86);
  backdrop-filter: blur(12px);
}
.stage-title-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.subject-pill {
  flex: none;
  font-size: 10px; font-weight: 700;
  letter-spacing: .04em;
  color: #15544f;
  background: #d8eee7;
  border: 1px solid #bfe1d8;
  border-radius: 999px;
  padding: 5px 8px;
}
.stage-title-wrap h1 {
  margin: 0; font-size: 16px; line-height: 1.3; font-weight: 720;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stage-title-wrap p {
  margin: 3px 0 0; font-size: 10.5px; color: #718482;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stage-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.ghost-button {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid #d4cbbb;
  border-radius: 11px;
  color: #45605b;
  background: rgba(255, 253, 248, .55);
  font-size: 11px;
}
.ghost-button:hover { background: #fffdf8; border-color: #b9d8cf; }
.ghost-button svg { width: 16px; height: 16px; }
.stage-actions .icon-button { border: 1px solid #d4cbbb; background: rgba(255, 253, 248, .55); }

.stage-body { flex: 1; min-height: 0; padding: 14px 16px 10px; }
.frame-card {
  position: relative;
  width: 100%; height: 100%;
  min-height: 280px;
  border-radius: 18px;
  overflow: hidden;
  background: #fffdf8;
  border: 1px solid #d6ccbb;
  box-shadow: 0 20px 46px rgba(29, 48, 47, 0.12), inset 0 1px 0 rgba(255,255,255,.7);
}
.frame-card iframe { width: 100%; height: 100%; border: 0; display: block; background: #fffdf8; }
.frame-loading {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: #fffdf8;
  color: #708a84; font-size: 12px;
  transition: opacity .25s ease, visibility .25s ease;
}
.frame-loading.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-orbit {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid #dcece7; border-top-color: var(--teal);
  animation: spin 1s linear infinite;
}
.frame-badge {
  pointer-events: none;
  position: absolute; top: 10px; right: 10px; z-index: 3;
  font-size: 9.5px; color: #55746c;
  background: rgba(255,253,248,.88);
  border: 1px solid #dfe9e4;
  border-radius: 999px;
  padding: 4px 8px;
  backdrop-filter: blur(8px);
}
.stage-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 18px calc(13px + env(safe-area-inset-bottom));
}
.goal-chip { display: flex; align-items: center; gap: 7px; min-width: 0; }
.goal-chip span { font-size: 9.5px; color: #84928d; white-space: nowrap; }
.goal-chip strong { font-size: 10.5px; color: #2c5551; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-hint { display: flex; align-items: center; gap: 6px; min-width: 0; color: #6c817b; font-size: 10.5px; }
.stage-hint span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pulse-dot { width: 6px; height: 6px; border-radius: 50%; background: #4bbd91; box-shadow: 0 0 0 4px rgba(75,189,145,.13); flex: none; }
.stage-footer .ghost-button { flex: none; }



.assignment-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 5px 0 0;
  padding: 3px 8px;
  border: 1px solid #ecd9ab;
  border-radius: 999px;
  background: #fff8e6;
  color: #8a6a22;
  font-size: 9.5px;
  line-height: 1.4;
  max-width: min(100%, 560px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.assignment-line::before { content: '▸'; font-size: 9px; }
.assignment-line[hidden] { display: none; }
.assignment-line.is-done {
  border-color: #cfe6d9;
  background: #edf8f1;
  color: #2f6e58;
}
.assignment-line.is-done::before { content: '✓'; }
.assignment-line.is-overdue {
  border-color: #ecd0b7;
  background: #fff4e8;
  color: #a85d1d;
}
.assignment-line.is-overdue::before { content: '!'; }

/* ---------- assessment ---------- */
.app[data-mode="assessment"] { grid-template-columns: minmax(0, 1fr); }
.app[data-mode="assessment"] .sidebar,
.app[data-mode="assessment"] .chat-panel { display: none; }
.app[data-mode="assessment"] .stage-panel { grid-column: 1; }
.app[data-mode="assessment"] .tutor-pill { display: none; }
.app[data-mode="assessment"] .stage-header { min-height: 64px; }
.app[data-mode="assessment"] .stage-body { padding: 0; }
.app[data-mode="assessment"] .frame-card { border-radius: 0; border: 0; box-shadow: none; }
.app[data-mode="assessment"] .stage-footer { background: rgba(240, 234, 222, .9); padding-top: 10px; }
.app[data-mode="assessment"] .mobile-tabs { display: none; }
.app[data-mode="assessment"] .stage-hint { visibility: hidden; }
.app[data-mode="assessment"] #focusButtonFooter,
.app[data-mode="assessment"] #focusButton { display: none; }

/* ---------- focus / tutor pill ---------- */
.tutor-pill {
  display: none;
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 14px));
  z-index: 50;
  align-items: center; gap: 8px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  padding: 7px 12px 7px 7px;
  color: #fffdf8;
  background: rgba(16, 44, 47, 0.94);
  box-shadow: 0 14px 30px rgba(10, 35, 35, 0.3);
  backdrop-filter: blur(12px);
  font-size: 12px;
  animation: pillIn .25s ease both;
}
.tutor-pill-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: #f4dfa8; color: #17332f;
  font-size: 12px; font-weight: 700;
}
.tutor-pill svg { width: 17px; height: 17px; margin-left: 1px; opacity: .8; }
.app[data-mode="focus"] { grid-template-columns: minmax(0, 1fr); }
.app[data-mode="focus"] .sidebar,
.app[data-mode="focus"] .chat-panel { display: none; }
.app[data-mode="focus"] .stage-panel { grid-column: 1; }
.app[data-mode="focus"] .stage-header { min-height: 64px; }
.app[data-mode="focus"] .stage-body { padding: 0; }
.app[data-mode="focus"] .frame-card { border-radius: 0; border: 0; box-shadow: none; }
.app[data-mode="focus"] .stage-footer { background: rgba(240, 234, 222, .9); padding-top: 10px; }
.app[data-mode="focus"] .tutor-pill { display: flex; }

/* ---------- drawer ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(16, 35, 35, 0.28);
  backdrop-filter: blur(2px);
  opacity: 0; visibility: hidden;
  transition: opacity .22s ease, visibility .22s ease;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 70;
  width: min(390px, 92vw);
  display: flex; flex-direction: column;
  background: #fbf8f0;
  border-left: 1px solid #ded4c3;
  box-shadow: -18px 0 46px rgba(20, 43, 47, 0.16);
  transform: translateX(102%);
  transition: transform .24s cubic-bezier(.2,.8,.2,1);
  visibility: hidden;
}
.app.drawer-open .drawer-backdrop { opacity: 1; visibility: visible; }
.app.drawer-open .drawer { transform: translateX(0); visibility: visible; }
.drawer-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 18px 12px;
  border-bottom: 1px solid #e4dacb;
}
.eyebrow { font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: #8a9a94; }
.drawer-header h2 { margin: 5px 0 0; font-size: 17px; letter-spacing: -.01em; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px 20px; }
.drawer-footer { padding: 11px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid #e4dacb; }
.drawer-footer p { margin: 0; font-size: 10px; line-height: 1.5; color: #8b9b96; }
.drawer-loading { font-size: 12px; color: #8b9b96; padding: 12px 0; }
.memory-section { margin-bottom: 22px; }
.memory-section h3 {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 0 9px; font-size: 11px; letter-spacing: .04em; color: #617a73;
}
.memory-section h3 span { font-size: 9px; color: #9aa8a3; font-weight: 400; }
.skill-row { margin-bottom: 13px; }
.skill-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.skill-row-top strong { font-size: 12px; }
.skill-row-top span { font-size: 10px; color: #7b8e88; }
.meter { height: 7px; border-radius: 999px; background: #e6e2d4; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #e7b45a, #5bb99d); }
.memory-item {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 10px 11px; margin-bottom: 7px;
  border: 1px solid #e1d8c8; border-radius: 12px;
  background: #fffdf8;
}
.memory-item-icon { font-size: 15px; line-height: 1.4; }
.memory-item strong { display: block; font-size: 11.5px; line-height: 1.4; }
.memory-item span { display: block; font-size: 10px; color: #7c8f89; line-height: 1.45; margin-top: 3px; }
.interest-row { display: flex; flex-wrap: wrap; gap: 6px; }
.interest-chip {
  border: 1px solid #d6e7df; background: #eff8f3; color: #35645a;
  border-radius: 999px; padding: 5px 9px; font-size: 10px;
}
.teacher-note {
  padding: 11px 12px; border-left: 3px solid #e5b34d;
  background: #fff8e9; border-radius: 3px 11px 11px 3px;
  font-size: 11px; line-height: 1.55; color: #5c5441;
  margin-bottom: 8px;
}
.teacher-note small { display: block; margin-top: 5px; color: #9a8c6f; font-size: 9px; }

/* ---------- toast ---------- */
.toast-stack {
  position: fixed; z-index: 90;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: none;
  display: flex; align-items: flex-start; gap: 9px;
  padding: 11px 13px;
  border-radius: 14px;
  background: rgba(16, 44, 47, 0.96);
  color: #f4f7f1;
  box-shadow: 0 14px 34px rgba(10, 35, 35, 0.28);
  font-size: 12px; line-height: 1.5;
  animation: toastIn .24s ease both;
}
.toast .toast-icon { color: #f4dfa8; font-size: 15px; }
.toast button {
  pointer-events: auto;
  border: 0; background: transparent; color: #f4dfa8; font-size: 11px;
  white-space: nowrap; padding: 0; margin-left: auto; align-self: center;
}
.toast.is-leaving { animation: toastOut .2s ease both; }

/* ---------- responsive ---------- */
.mobile-tabs { display: none; }
/* 900–1179px：平板横屏。原来收成 76px 图标条，菜单文字全被隐藏、汉堡按钮又无效，
   学生根本看不到「今天/课程/作品/进度/帮助」。改为窄版带文字侧栏。 */
@media (max-width: 1179px) {
  :root { --nav-w: 182px; }
  .sidebar { padding-left: 10px; padding-right: 10px; gap: 12px; }
  .brand { justify-content: flex-start; gap: 8px; padding: 2px 2px; }
  .brand-copy strong { font-size: 14px; }
  .brand-copy span { font-size: 9px; }
  .learner-card { padding: 8px; gap: 8px; position: relative; }
  .learner-avatar { width: 32px; height: 32px; font-size: 15px; }
  .learner-copy strong { font-size: 13px; }
  .learner-copy span { font-size: 10px; }
  .online-dot { position: absolute; margin: 0; right: 10px; bottom: 12px; width: 7px; height: 7px; }
  .nav { width: 100%; align-items: stretch; }
  .nav-item { justify-content: flex-start; gap: 9px; padding: 0 10px; width: 100%; min-height: 42px; border-radius: 13px; }
  .nav-item svg { width: 18px; height: 18px; }
  .nav-item span { font-size: 13px; }
  .sidebar-bottom { width: 100%; align-items: stretch; }
  .streak-card { display: none; }
  .teacher-link { justify-content: flex-start; padding: 8px 10px; }
}

@media (max-width: 899px) {
  :root { --nav-w: 0px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 80;
    width: min(78vw, 310px);
    padding: 18px 14px calc(14px + env(safe-area-inset-bottom));
    align-items: stretch;
    transform: translateX(-104%);
    transition: transform .24s cubic-bezier(.2,.8,.2,1);
    box-shadow: 18px 0 46px rgba(10, 35, 35, 0.24);
  }
  .app.nav-open .sidebar { transform: translateX(0); }
  .brand { justify-content: flex-start; }
  .brand-copy, .learner-copy, .nav-item span, .streak-card, .teacher-link span { display: flex; }
  .brand-copy { display: flex; }
  .learner-card { justify-content: flex-start; padding: 10px; }
  .online-dot { position: static; margin-left: auto; width: 8px; height: 8px; }
  .nav { align-items: stretch; }
  .nav-item { justify-content: flex-start; width: 100%; padding: 0 12px; }
  .sidebar-bottom { align-items: stretch; }
  .teacher-link { justify-content: flex-start; padding: 9px 11px; }
  .sidebar-close { display: inline-grid; }
  .menu-button { display: inline-grid; }
  .chat-panel, .stage-panel { grid-column: 1; }
  .chat-panel { border-right: 0; }
  .app[data-view="chat"] .stage-panel { display: none; }
  .app[data-view="stage"] .chat-panel { display: none; }
  .app[data-mode="focus"] .chat-panel { display: none; }
  .app[data-mode="focus"] .stage-panel { display: flex; }
  .stage-header { min-height: 68px; padding: 10px 14px; }
  .stage-body { padding: 10px 12px 8px; }
  .stage-footer { padding: 0 14px calc(76px + env(safe-area-inset-bottom)); }
  .app[data-mode="focus"] .stage-footer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .stage-footer .ghost-button span { display: none; }
  .privacy-note { margin-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .toast-stack { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .mobile-tabs {
    position: fixed; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); z-index: 45;
    transform: translateX(-50%);
    display: flex; align-items: center; gap: 3px;
    padding: 5px;
    border-radius: 18px;
    background: rgba(16, 44, 47, 0.95);
    box-shadow: 0 12px 30px rgba(10, 35, 35, 0.28);
    backdrop-filter: blur(12px);
  }
  .mobile-tabs button {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    min-width: 66px; min-height: 46px;
    border: 0; border-radius: 13px;
    color: #9fb5ad; background: transparent;
    font-size: 9.5px;
  }
  .mobile-tabs button svg { width: 19px; height: 19px; }
  .mobile-tabs button.is-active { color: #183532; background: #f4dfa8; }
  .app[data-mode="focus"] .mobile-tabs { display: none; }
  .mobile-tabs { display: flex; }
}

@media (max-width: 520px) {
  .stage-title-wrap h1 { font-size: 14px; }
  .stage-title-wrap p { max-width: 190px; }
  .stage-actions .ghost-button { display: none; }
  .stage-hint { display: none; }
  .goal-chip { max-width: 65%; }
  .chat-header { padding: 9px 11px; }
  .chat-scroll { padding-left: 11px; padding-right: 11px; }
  .composer { margin-left: 9px; margin-right: 9px; }
  .quick-actions { padding-left: 9px; padding-right: 9px; }
  .bubble { max-width: 91%; font-size: 13px; }
}

@media (max-height: 620px) {
  .stage-header { min-height: 58px; }
  .chat-header { min-height: 58px; }
  .stage-footer { display: none; }
  .privacy-note { display: none; }
  /* 矮屏（平板横屏 498px 高）：侧栏压缩，保证菜单不被卡片挤出屏幕 */
  .sidebar { gap: 10px; padding-top: 14px; }
  .brand { min-height: 38px; }
  .learner-card { padding: 6px; }
  .nav-item { min-height: 38px; }
  /* 卡片不要被 flex 压缩成细条：保持自然高度，让侧栏自己滚动 */
  .task-card, .sidebar-bottom { flex: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes pillIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.message.is-streaming .read-aloud { opacity: .35; pointer-events: none; }
.message.is-streaming .bubble::after { content: '▍'; margin-left: 2px; opacity: .45; animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }


.account-card {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 11px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.account-copy { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.account-copy strong { color: #fff; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-copy span { color: rgba(255,255,255,.55); font-size: 10px; }
.account-logout { color: #f4dfa8; font-size: 11px; text-decoration: none; white-space: nowrap; }
.account-logout:hover { text-decoration: underline; }
.teacher-account { font-size: 12px; color: #44615f; white-space: nowrap; }

/* divider shown when the child switches courseware */
.chat-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 6px;
  color: var(--muted, #6b7c78);
  font-size: 12.5px;
  letter-spacing: 0.02em;
}

.chat-divider::before,
.chat-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: currentColor;
  opacity: 0.22;
}

/* assessment mode ---------------------------------------------------- */
.assessment-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 12px 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: #fff4d6;
  border: 1px solid #f0cf86;
  color: #6a4a12;
  font-size: 13px;
}

.assessment-bar[hidden] { display: none; }

.assessment-submit {
  flex: none;
  min-height: 40px;
  padding: 0 18px;
  border-radius: 12px;
  border: none;
  background: #d7871f;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.assessment-submit:disabled { opacity: 0.6; }

#app[data-mode='assessment'] #quickActions,
#app[data-mode='assessment'] .mic-button { display: none; }

.assessment-result {
  border-radius: 16px;
  border: 1px solid #e2d3a8;
  background: #fffdf3;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.55;
}

.assessment-result h3 { margin: 0 0 6px; font-size: 15px; }
.assessment-result ul { margin: 8px 0 0; padding-left: 18px; }
.assessment-result .pass { color: #2f7a4d; }
.assessment-result .fail { color: #a34a2a; }

/* 中间栏分段：小老师 / 任务（可滚动内容从导航栏移出） ---------------- */
.chat-tabs { display: flex; gap: 6px; padding: 10px 12px 0; flex: none; }
.chat-tab {
  border: 1px solid #e4dacb; background: #fbf8f0; color: #4b5b56;
  border-radius: 999px; font-size: 12px; font-weight: 600;
  padding: 6px 13px; min-height: 30px; cursor: pointer;
}
.chat-tab:hover { background: #f5efe2; }
.chat-tab.is-active { background: #102c2f; border-color: #102c2f; color: #f6f1e4; }
.chat-tasks { display: none; flex: 1; min-height: 0; overflow-y: auto; padding: 10px 12px 14px; }
.chat-panel[data-tab="tasks"] .chat-tasks { display: flex; flex-direction: column; gap: 10px; }
.chat-panel[data-tab="tasks"] .chat-scroll,
.chat-panel[data-tab="tasks"] .quick-actions,
.chat-panel[data-tab="tasks"] .composer,
.chat-panel[data-tab="tasks"] .privacy-note,
.chat-panel[data-tab="tasks"] .assessment-bar { display: none; }
.chat-tasks .task-card { margin: 0; box-shadow: 0 1px 2px rgba(16, 44, 47, 0.06); }

/* task card in the sidebar ------------------------------------------- */
.task-card {
  margin: 10px 14px 4px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #f7f3e9;
  border: 1px solid #ece4d3;
}
.task-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.task-card-head strong { font-size: 12px; color: #7a6a4d; letter-spacing: .04em; }
.task-more {
  border: 0;
  background: none;
  color: #2f7d5b;
  font-size: 11px;
  cursor: pointer;
}
.task-list { display: grid; gap: 6px; }
.task-row {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: #fffdf8;
  border-radius: 10px;
  padding: 7px 9px;
  cursor: pointer;
  font: inherit;
}
.task-row.is-current { border-color: #b9d3c3; background: #f2f8f3; }
.task-row strong {
  display: block;
  font-size: 12.5px;
  color: #33413c;
  font-weight: 600;
  line-height: 1.35;
}
.task-row span { font-size: 11px; color: #8a9187; }
.task-row.is-done span { color: #2f7d5b; }
.task-row.is-overdue span { color: #b3563c; }
.task-feedback {
  margin-top: 5px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #fdf6e6;
  font-size: 11.5px;
  color: #6b5836;
  line-height: 1.5;
}

.review-card { background: #f4f1fb; border-color: #e2dcf0; }
.review-card .task-card-head strong { color: #5b4d7a; }
.review-count { font-size: 11px; color: #7a6b9a; }
.review-row {
  background: #fffdfa;
  border: 1px solid #ece6f4;
  border-radius: 10px;
  padding: 7px 9px;
}
.review-row strong { display: block; font-size: 12.5px; color: #3b3550; }
.review-row span { font-size: 11px; color: #8b8399; }
.review-actions { display: flex; gap: 6px; margin-top: 5px; }
.review-actions button {
  border: 1px solid #d9d0ea;
  background: #faf8ff;
  color: #4c3f74;
  border-radius: 8px;
  font-size: 11px;
  padding: 3px 8px;
  cursor: pointer;
}

.account-invite {
  border: 1px solid rgba(15, 118, 110, .25);
  background: rgba(15, 118, 110, .08);
  color: #0f5f59;
  border-radius: 999px;
  padding: 4px 9px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.account-invite:hover { background: rgba(15, 118, 110, .14); }
