* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;
  font-size: 19px;
  background: #f3f6ff;
  color: #1f2a44;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.hidden { display: none !important; }
.screen { height: 100%; }

/* 登录 */
#login { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: #fff; border-radius: 24px; padding: 40px 32px; text-align: center; max-width: 420px;
  box-shadow: 0 8px 30px rgba(79, 124, 255, .15); line-height: 1.7; }
.login-emoji { font-size: 64px; }
.login-card h1 { margin: 8px 0 16px; }

/* 主界面 */
#app { display: flex; flex-direction: column; }
header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .05); z-index: 2;
}
#teachers { display: flex; gap: 8px; }
#teachers button {
  display: flex; align-items: center; gap: 6px; padding: 10px 18px; border-radius: 999px;
  background: #eef2ff; font-weight: 600; color: #4f5d7a;
}
#teachers button span { font-size: 22px; }
#teachers button.active { background: #4f7cff; color: #fff; }
#teachers button.active[data-mode="english"] { background: #ff8a3d; }
.actions { display: flex; gap: 6px; }
.actions button { padding: 10px 14px; border-radius: 14px; background: #f3f6ff; position: relative; font-size: 18px; }
.badge { position: absolute; top: -4px; right: -4px; background: #ff4d4f; color: #fff; font-size: 13px;
  min-width: 20px; height: 20px; border-radius: 10px; line-height: 20px; padding: 0 5px; }

#messages { flex: 1; overflow-y: auto; padding: 20px 16px; -webkit-overflow-scrolling: touch; }
.msg { display: flex; gap: 10px; margin-bottom: 18px; max-width: 860px; margin-left: auto; margin-right: auto; }
.msg.user { flex-direction: row-reverse; }
.avatar { width: 42px; height: 42px; flex: none; border-radius: 50%; background: #fff; display: flex;
  align-items: center; justify-content: center; font-size: 24px; box-shadow: 0 2px 6px rgba(0, 0, 0, .06); }
.bubble { padding: 12px 16px; border-radius: 20px; line-height: 1.65; max-width: 80%; word-break: break-word;
  background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .05); }
.msg.user .bubble { background: #4f7cff; color: #fff; border-top-right-radius: 6px; }
.msg.assistant .bubble { border-top-left-radius: 6px; }
.english .msg.user .bubble { background: #ff8a3d; }
.bubble img { max-width: 220px; max-height: 220px; border-radius: 12px; display: block; margin-bottom: 6px; }
.bubble ul { margin: 6px 0; padding-left: 22px; }
.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.speak { margin-top: 6px; font-size: 16px; color: #8a94ad; padding: 4px 0; }
.typing::after { content: "▍"; animation: blink 1s infinite; color: #4f7cff; }
@keyframes blink { 50% { opacity: 0; } }
.welcome { text-align: center; color: #8a94ad; margin-top: 40px; line-height: 1.8; }
.welcome .big { font-size: 56px; }

#previews { display: flex; gap: 8px; padding: 0 16px; background: #fff; }
#previews:not(:empty) { padding-top: 10px; }
.preview { position: relative; }
.preview img { width: 72px; height: 72px; object-fit: cover; border-radius: 12px; }
.preview button { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%;
  background: #1f2a44; color: #fff; font-size: 13px; }

footer {
  display: flex; align-items: flex-end; gap: 10px; background: #fff;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px);
}
#input {
  flex: 1; resize: none; border: 2px solid #e3e8f5; border-radius: 22px; padding: 10px 16px;
  font: inherit; max-height: 160px; outline: none; background: #f8faff;
}
#input:focus { border-color: #4f7cff; }
.round { width: 48px; height: 48px; flex: none; border-radius: 50%; background: #eef2ff; font-size: 22px;
  display: flex; align-items: center; justify-content: center; }
.round.primary { background: #4f7cff; color: #fff; }
.round:disabled { opacity: .4; }
#btn-mic.listening { background: #ff4d4f; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 77, 79, .5); } 50% { box-shadow: 0 0 0 12px rgba(255, 77, 79, 0); } }

/* 任务面板 */
.panel { position: fixed; inset: 0; background: rgba(31, 42, 68, .35); display: flex; justify-content: flex-end; z-index: 10; }
.panel > * { background: #fff; }
.panel-head { position: absolute; right: 0; top: 0; width: min(420px, 100%); display: flex; justify-content: space-between;
  align-items: center; padding: calc(env(safe-area-inset-top) + 12px) 20px 12px; }
.panel-head h2 { margin: 0; font-size: 22px; }
#tasks-body { width: min(420px, 100%); height: 100%; overflow-y: auto; padding: calc(env(safe-area-inset-top) + 80px) 20px 20px; }
.task { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 16px; background: #f3f6ff; margin-bottom: 10px; }
.task .content { flex: 1; line-height: 1.5; }
.task button { background: #4f7cff; color: #fff; padding: 8px 14px; border-radius: 12px; font-size: 16px; white-space: nowrap; }
.task.done { background: #eefaf0; color: #3a8a4a; }
.tasks-title { color: #8a94ad; font-size: 16px; margin: 18px 0 8px; }
.empty { color: #8a94ad; text-align: center; padding: 30px 0; }

@media (max-width: 600px) {
  #teachers button { padding: 8px 12px; font-size: 16px; }
  .actions button { padding: 8px 10px; font-size: 16px; }
  #btn-tasks { font-size: 0; } #btn-tasks::before { content: "📋"; font-size: 18px; }
}
