/* ============================================================
   差班生 · 学生端设计系统
   设计理念：语音优先 —— 学生像"打电话"一样和差班生对话，
   屏幕只承担「偶尔瞄一眼」的表情/进度反馈，不是聊天记录。
   视觉：温暖、圆润、大字、高对比（面向 K12，儿童友好）。
   ============================================================ */

:root {
  --bg: #fdf5ef;          /* 暖米色背景 */
  --card: #ffffff;
  --primary: #ff6b4a;     /* 珊瑚橙，主色 */
  --primary-soft: #ffe6dd;
  --accent: #ffb020;      /* 琥珀，顿悟/成就 */
  --accent-soft: #fff2d6;
  --ok: #2fb879;          /* 掌握/成长 绿 */
  --warn: #f5a623;
  --text: #2d2926;
  --muted: #9a8f83;
  --line: #f0e6dd;

  --r-lg: 24px;
  --r-md: 16px;
  --shadow: 0 8px 30px rgba(120, 70, 40, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.55;
  overscroll-behavior: none;
}

#app { max-width: 480px; margin: 0 auto; height: 100%; display: flex; flex-direction: column; }

/* ---------- 顶部栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px 12px;
}
.topbar .back { font-size: 22px; background: none; border: none; cursor: pointer; color: var(--text); padding: 4px; }
.topbar .title { font-size: 20px; font-weight: 800; flex: 1; }
.topbar .ring-sm { width: 44px; height: 44px; }

/* ---------- 掌握度进度环 ---------- */
.ring {
  --pct: 0;
  width: 120px; height: 120px; border-radius: 50%;
  background: conic-gradient(var(--ok) calc(var(--pct) * 1%), var(--line) 0);
  display: grid; place-items: center;
  position: relative;
  flex: none;
}
.ring::before {
  content: ""; position: absolute; inset: 12px;
  background: var(--card); border-radius: 50%;
}
.ring .ring-inner { position: relative; text-align: center; z-index: 1; }
.ring .ring-num { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1; }
.ring .ring-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ring-sm { width: 44px; height: 44px; }
.ring-sm::before { inset: 5px; }
.ring-sm .ring-num { font-size: 13px; }
.ring-sm .ring-label { display: none; }

/* ---------- 差班生头像（表情随状态变化） ---------- */
.avatar {
  width: 168px; height: 168px; border-radius: 50%;
  background: linear-gradient(135deg, #ffd9c8, #ffe8dd);
  display: grid; place-items: center;
  margin: 0 auto;
  box-shadow: var(--shadow);
  border: 4px solid #fff;
  position: relative;
  transition: transform 0.3s ease;
}
.avatar .face { font-size: 96px; line-height: 1; }
.avatar.bounce { animation: bounce 0.5s ease; }
@keyframes bounce { 0%,100%{transform:translateY(0)} 40%{transform:translateY(-14px)} }

/* ---------- 页面容器 ---------- */
.screen { flex: 1; display: flex; flex-direction: column; padding: 8px 24px 28px; }

/* ---------- 差班生主页 ---------- */
.home-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
.name-line { text-align: center; }
.name-line .name { font-size: 26px; font-weight: 800; }
.name-line .grade { font-size: 14px; color: var(--muted); margin-top: 2px; }

.status-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 10px 18px; font-size: 15px;
  box-shadow: var(--shadow); max-width: 88%;
}
.status-chip .emoji { font-size: 20px; }

.todo-list { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.todo {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 14px 16px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow);
}
.todo .todo-emoji { font-size: 24px; }
.todo .todo-text { flex: 1; font-size: 15px; }
.todo .todo-tag { font-size: 12px; color: var(--muted); background: #f7f2ec; padding: 2px 10px; border-radius: 999px; }

/* ---------- 教学对话页（语音优先） ---------- */
.teach-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; }
.teach-point { font-size: 14px; color: var(--muted); background: #f7f2ec; padding: 4px 14px; border-radius: 999px; }

.last-msg {
  text-align: center; font-size: 19px; font-weight: 600;
  max-width: 92%; min-height: 1.6em;
  color: var(--text);
}
.last-msg.dim { color: var(--muted); font-weight: 400; font-size: 16px; }

/* 顿悟高光 */
.insight {
  background: var(--accent-soft); border: 1px solid #ffdf9e;
  border-radius: var(--r-md); padding: 14px 18px;
  text-align: center; font-weight: 700; font-size: 17px; color: #9a6a00;
  animation: pop 0.4s ease;
}
@keyframes pop { 0%{transform:scale(0.8);opacity:0} 100%{transform:scale(1);opacity:1} }

/* ---------- 底部操作区 ---------- */
.actions { padding: 8px 24px calc(20px + env(safe-area-inset-bottom)); }
.mic-row { display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 14px; }

.mic-btn {
  width: 92px; height: 92px; border-radius: 50%;
  border: none; cursor: pointer;
  background: var(--primary); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 10px 26px rgba(255, 107, 74, 0.4);
  transition: transform 0.15s ease, background 0.15s;
}
.mic-btn .mic-ico { font-size: 34px; }
.mic-btn.listening { background: #e5484d; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.08)} }
.mic-btn:disabled { opacity: 0.5; }

.side-btn {
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 12px 18px; font-size: 15px; cursor: pointer; color: var(--text);
  box-shadow: var(--shadow);
}
.side-btn.primary { background: var(--primary); color: #fff; border: none; }

.hint-line { text-align: center; font-size: 13px; color: var(--muted); min-height: 1.4em; }

/* ---------- 输入框（语音的兜底） ---------- */
.text-input-row { display: flex; gap: 10px; margin-top: 12px; }
.text-input-row input {
  flex: 1; padding: 13px 16px; border: 1px solid var(--line); border-radius: 999px;
  font-size: 16px; font-family: inherit; background: var(--card);
}
.text-input-row .send { border: none; background: var(--primary); color: #fff; border-radius: 999px; padding: 0 22px; font-size: 15px; cursor: pointer; }

/* ---------- 登录/注册 ---------- */
.auth-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 0 8px; }
.auth-wrap h1 { font-size: 24px; text-align: center; margin-bottom: 8px; }
.auth-wrap input, .auth-wrap select {
  width: 100%; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-md);
  font-size: 16px; font-family: inherit; background: var(--card);
}
.auth-wrap .btn { border: none; background: var(--primary); color: #fff; border-radius: var(--r-md); padding: 15px; font-size: 16px; font-weight: 700; cursor: pointer; }
.auth-wrap .link { text-align: center; font-size: 14px; color: var(--muted); }
.auth-wrap .link b { color: var(--primary); cursor: pointer; }
.error { color: #e5484d; font-size: 14px; text-align: center; }

/* ---------- 加载/提示 ---------- */
.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; height: 100%; color: var(--muted); }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--primary-soft); border-top-color: var(--primary); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%);
  background: rgba(45, 41, 38, 0.9); color: #fff; border-radius: 999px;
  padding: 10px 20px; font-size: 14px; opacity: 0; transition: opacity 0.3s; pointer-events: none; z-index: 99;
}
.toast.show { opacity: 1; }

/* ---------- 聊天功能工具栏 ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 12px; }
.tool-btn {
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 14px; font-size: 14px; cursor: pointer; color: var(--text);
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 4px;
}
.tool-btn:active { transform: scale(0.96); }
.tool-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(45,41,38,0.45); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  background: var(--card); border-radius: var(--r-lg); width: 100%; max-width: 460px;
  max-height: 84vh; overflow-y: auto; padding: 20px; box-shadow: var(--shadow);
}
.modal-card h2 { font-size: 19px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.modal-card .x { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-card label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.modal-card input, .modal-card textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md);
  font-size: 15px; font-family: inherit; background: #fff; resize: vertical;
}
.modal-card textarea { min-height: 80px; }

/* ---------- 课程表 ---------- */
.sched-table { width: 100%; border-collapse: collapse; margin: 8px 0; background: #fff; }
.sched-table th, .sched-table td { border: 1px solid var(--line); padding: 9px; text-align: center; font-size: 15px; }
.sched-table th { background: #faf5ef; font-weight: 700; }

/* ---------- 手写板 ---------- */
.hw-canvas {
  width: 100%; height: 260px; display: block; touch-action: none; cursor: crosshair;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-md);
}
.modal-card:fullscreen {
  max-width: none; width: 100vw; height: 100vh; max-height: none;
  border-radius: 0; display: flex; flex-direction: column;
}
.modal-card:fullscreen .hw-canvas { flex: 1; height: auto; min-height: 40vh; }

/* ---------- 聊天记录 ---------- */
.chat-log {
  max-height: 40vh; overflow-y: auto; text-align: left; padding: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  width: 100%;
}
.chat-line { margin-bottom: 8px; font-size: 14px; line-height: 1.5; word-break: break-word; }
.chat-line.me { color: var(--primary); }
.chat-line.ai { color: var(--text); }
.chat-speak {
  border: none; background: none; cursor: pointer; font-size: 13px;
  padding: 0 2px 0 6px; vertical-align: middle; opacity: 0.75;
}
.chat-speak:active { opacity: 1; }

/* ---------- 键值对编辑 ---------- */
.pair-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.pair-row input { flex: 1; margin: 0; }
.pair-row .pair-arrow { color: var(--muted); flex: none; }
.pair-row .del { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--danger); flex: none; }

/* ---------- 语音熄屏 ---------- */
.voice-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.9); z-index: 2000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.voice-tip { color: #fff; font-size: 16px; margin-top: 16px; opacity: 0.85; }
.hw-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.hw-color { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }

/* ---------- 选择列表（学科/教材/问题集） ---------- */
.pick-list { display: flex; flex-direction: column; gap: 8px; }
.domain-group { display: flex; flex-direction: column; gap: 8px; }
.domain-header { font-size: 13px; font-weight: 700; color: var(--primary); margin: 4px 4px 0; }

/* ---------- 页签 ---------- */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tab {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 14px; color: var(--muted);
}
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pick-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: #fff; font-size: 15px; cursor: pointer; text-align: left;
}
.pick-item:active { background: var(--primary-soft); }
.pick-item .sub { color: var(--muted); font-size: 12px; }
.pick-item .del { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--danger); flex: none; }

/* 首页按钮组 */
.home-btns { display: flex; flex-direction: column; gap: 10px; width: 100%; }
