:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --bg2: #f1f3f8;
  --panel: #ffffff;
  --panel2: #f5eef7;
  --line: #dfe3ed;
  --text: #252838;
  --dim: #747b91;
  --accent: #d94f8a;
  --accent-soft: rgba(217, 79, 138, .11);
  --ok: #16864b;
  --warn: #9a6700;
  --err: #c43b45;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(124, 58, 237, .07), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(255, 126, 182, .08), transparent 60%),
    var(--bg);
  color: var(--text);
  overflow: hidden;
}
body.auth-locked #app { visibility: hidden; }
#app { display: flex; height: 100vh; height: 100dvh; }

/* ---------- 侧栏 ---------- */
#sidebar {
  width: 286px; min-width: 286px;
  background: linear-gradient(180deg, #ffffff, #f4f5fa);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 20px 16px 14px;
  gap: 10px;
}
.brand-row { display: flex; flex-direction: column; gap: 10px; }
.logo { font-size: 20px; font-weight: 800; letter-spacing: .5px; white-space: nowrap;
  background: linear-gradient(90deg, #ff7eb6, #a78bfa, #5eead4);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.logo-sub { display: block; font-size: 11px; font-weight: 500; letter-spacing: 3px; color: var(--dim); -webkit-text-fill-color: var(--dim); margin-top: 4px; }
.status-pill {
  border: 1px solid var(--line); background: var(--panel); color: var(--dim);
  border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer; text-align: left;
}
.status-pill.ok { color: var(--ok); border-color: rgba(22, 134, 75, .3); background: rgba(22, 134, 75, .05); }
.status-pill.bad { color: var(--err); border-color: rgba(196, 59, 69, .3); background: rgba(196, 59, 69, .04); }
.status-pill.mock { color: var(--warn); border-color: rgba(154, 103, 0, .3); background: rgba(154, 103, 0, .04); }
.student-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: 8px 10px;
}
.student-chip > div { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.student-chip-avatar {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; object-fit: cover;
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line), 0 3px 10px rgba(47, 52, 72, .12);
}
.student-chip-avatar-picture { display: contents; }
.student-chip span { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.student-chip small { color: var(--dim); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; }
.student-chip button { border: 0; background: none; color: var(--dim); font: inherit; font-size: 11px; cursor: pointer; }
.student-chip button:hover { color: var(--err); }
.side-label { font-size: 11px; letter-spacing: 2px; color: var(--dim); margin-top: 8px; }

.teacher-card {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer; user-select: none;
  transition: background .15s, border-color .15s;
}
.teacher-card:hover { background: var(--panel); }
.teacher-card.active { background: var(--panel2); border-color: var(--tc, var(--accent)); }
.avatar {
  width: 38px; height: 38px; min-width: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 19px;
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,.25), transparent 55%), var(--tc, var(--accent));
  box-shadow: 0 2px 10px color-mix(in srgb, var(--tc, var(--accent)) 45%, transparent);
}
.avatar-image { object-fit: cover; border: 2px solid #fff; }
.avatar-picture { display: contents; }
.teacher-card .t-name { font-size: 14px; font-weight: 700; }
.teacher-card .t-tag { font-size: 11px; color: var(--dim); margin-top: 1px; }
.model-control {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 11px; background: var(--panel);
}
.model-control label { color: var(--dim); font-size: 11px; white-space: nowrap; }
.model-control select {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 12px; cursor: pointer;
}
.model-control select:focus { color: var(--accent); }
.model-control select:disabled { opacity: .55; cursor: not-allowed; }

.actions { display: flex; flex-direction: column; gap: 7px; }
.act {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 9px 12px; border-radius: 11px; font-size: 13.5px; cursor: pointer; text-align: left;
  transition: background .15s, transform .05s;
}
.act:hover { background: var(--panel2); }
.act:active { transform: scale(.98); }
.act.primary { background: linear-gradient(90deg, rgba(255,126,182,.18), rgba(167,139,250,.18)); border-color: rgba(255,126,182,.4); font-weight: 700; }
.act.ghost { color: var(--dim); }
.act:disabled { opacity: .45; cursor: not-allowed; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.upload-btn {
  display: block; text-align: center; font-size: 13px; padding: 9px;
  border: 1px dashed var(--line); border-radius: 11px; color: var(--dim); cursor: pointer;
}
.upload-btn:hover { color: var(--text); border-color: var(--accent); }
.hint { font-size: 11px; color: var(--dim); line-height: 1.6; }
.hint code { background: var(--panel); padding: 1px 5px; border-radius: 5px; }

/* ---------- 主区 ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#tabs { display: flex; gap: 4px; padding: 12px 18px 0; border-bottom: 1px solid var(--line); overflow-x: auto; flex-shrink: 0; }
.tab {
  background: none; border: none; color: var(--dim); font-size: 14px; padding: 9px 16px 11px;
  cursor: pointer; border-bottom: 2px solid transparent; font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.view[hidden] { display: none !important; }

/* ---------- 课堂 ---------- */
#view-classroom {
  position: relative; isolation: isolate; overflow: hidden;
  --scene-a: #dce9f3; --scene-b: #f6eadf; --scene-glow: rgba(232, 114, 74, .18);
  background: color-mix(in srgb, var(--bg) 88%, var(--scene-a));
}
#view-classroom[data-scene-tone="paddock"] { --scene-a:#d9deef; --scene-b:#f2dfdc; --scene-glow:rgba(227,70,83,.18); }
#view-classroom[data-scene-tone="workshop"] { --scene-a:#d7e8e6; --scene-b:#efe6d7; --scene-glow:rgba(29,145,132,.17); }
#view-classroom[data-scene-tone="telemetry"] { --scene-a:#d8e5f5; --scene-b:#e7e0f4; --scene-glow:rgba(58,111,198,.18); }
#view-classroom[data-scene-tone="archive"] { --scene-a:#e7dfd3; --scene-b:#eee7dc; --scene-glow:rgba(145,96,52,.16); }
#view-classroom[data-scene-tone="wind"] { --scene-a:#d9eeee; --scene-b:#e5eafb; --scene-glow:rgba(38,151,178,.17); }
#view-classroom[data-scene-tone="track"] { --scene-a:#dcdff1; --scene-b:#f0dfdf; --scene-glow:rgba(198,53,78,.19); }
#view-classroom[data-scene-tone="power"] { --scene-a:#ece3d3; --scene-b:#e5e2ef; --scene-glow:rgba(224,137,32,.18); }
#view-classroom[data-scene-tone="command"] { --scene-a:#d8e1ef; --scene-b:#e3e7ee; --scene-glow:rgba(40,92,170,.19); }
#view-classroom[data-scene-tone="vault"] { --scene-a:#eee2bf; --scene-b:#eadce4; --scene-glow:rgba(191,136,26,.23); }
#view-classroom::before, #view-classroom::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  transition: opacity .25s ease, background .35s ease;
}
#view-classroom::before {
  background:
    radial-gradient(700px 320px at 78% 4%, var(--scene-glow), transparent 68%),
    radial-gradient(580px 360px at 4% 76%, color-mix(in srgb, var(--scene-a) 65%, transparent), transparent 72%),
    linear-gradient(145deg, color-mix(in srgb, var(--scene-a) 48%, transparent), color-mix(in srgb, var(--scene-b) 38%, transparent));
  opacity: .9;
}
#view-classroom::after {
  background-image:
    linear-gradient(90deg, transparent 0 49.7%, color-mix(in srgb, var(--text) 5%, transparent) 50% 50.3%, transparent 50.6%),
    linear-gradient(0deg, transparent 0 49.7%, color-mix(in srgb, var(--text) 4%, transparent) 50% 50.3%, transparent 50.6%);
  background-size: 86px 86px; mask-image: linear-gradient(to bottom, rgba(0,0,0,.5), transparent 75%); opacity: .42;
}
#view-classroom[data-story-mode="off"]::before,
#view-classroom[data-story-mode="off"]::after { opacity: 0; }
.story-scene {
  position: relative; z-index: 2; flex: 0 0 auto; min-height: 92px;
  margin: 12px 8% 0; padding: 15px 18px; display: flex; align-items: center; gap: 15px;
  border: 1px solid color-mix(in srgb, var(--scene-glow) 65%, var(--line)); border-radius: 16px;
  background: linear-gradient(112deg, rgba(255,255,255,.88), rgba(255,255,255,.68));
  box-shadow: 0 12px 30px color-mix(in srgb, var(--scene-glow) 50%, transparent);
  backdrop-filter: blur(13px); overflow: hidden;
}
.story-scene::after {
  content:''; position:absolute; width:190px; height:190px; right:-52px; top:-96px; border-radius:50%;
  border:28px solid color-mix(in srgb, var(--scene-glow) 62%, transparent); opacity:.62; pointer-events:none;
}
.story-scene-mark {
  position: relative; flex: 0 0 54px; width: 54px; height: 54px; border-radius: 16px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--scene-a) 75%, white), color-mix(in srgb, var(--scene-glow) 80%, white));
  border: 1px solid rgba(255,255,255,.78); box-shadow: inset 0 0 0 5px rgba(255,255,255,.24);
}
.story-scene-mark::before, .story-scene-mark::after, .story-scene-mark span, .story-scene-mark i {
  content:''; position:absolute; display:block;
}
.story-scene-mark::before { width:34px; height:3px; background:rgba(255,255,255,.92); top:18px; left:10px; transform:skewX(-26deg); }
.story-scene-mark::after { width:27px; height:3px; background:rgba(255,255,255,.72); top:31px; left:15px; transform:skewX(-26deg); }
.story-scene-mark span { width:7px; height:7px; border-radius:50%; background:white; left:10px; bottom:8px; box-shadow:27px 0 0 rgba(255,255,255,.92); }
.story-scene-mark i { inset:7px; border:1px solid rgba(255,255,255,.4); border-radius:11px; }
.story-scene-copy { min-width:0; flex:1; display:flex; flex-direction:column; gap:3px; }
.story-scene-eyebrow { color:color-mix(in srgb, var(--accent) 72%, #4b5268); font-size:10px; font-weight:800; letter-spacing:1.7px; text-transform:uppercase; }
.story-scene-copy strong { font-size:17px; line-height:1.35; letter-spacing:.02em; }
.story-scene-copy small { color:var(--dim); font-size:12px; line-height:1.5; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.story-scene-progress { position:relative; z-index:1; display:flex; flex-direction:column; align-items:flex-end; gap:6px; color:var(--dim); font-size:10.5px; white-space:nowrap; }
.story-scene-progress span { padding:4px 9px; border:1px solid rgba(255,255,255,.92); border-radius:999px; background:rgba(255,255,255,.58); }
#view-classroom[data-story-mode="off"] .story-scene { display:none; }
#view-classroom[data-story-mode="light"] .story-scene { min-height:48px; margin-top:8px; padding:8px 13px; border-radius:12px; gap:10px; }
#view-classroom[data-story-mode="light"] .story-scene-mark { flex-basis:32px; width:32px; height:32px; border-radius:9px; }
#view-classroom[data-story-mode="light"] .story-scene-mark::before { width:20px; top:11px; left:6px; }
#view-classroom[data-story-mode="light"] .story-scene-mark::after { width:16px; top:19px; left:9px; }
#view-classroom[data-story-mode="light"] .story-scene-mark span,
#view-classroom[data-story-mode="light"] .story-scene-mark i,
#view-classroom[data-story-mode="light"] .story-scene-copy small,
#view-classroom[data-story-mode="light"] #storySceneKeys { display:none; }
#view-classroom[data-story-mode="light"] .story-scene-copy strong { font-size:13px; }
#view-classroom[data-story-mode="light"] .story-scene-eyebrow { font-size:9px; }
#chat { position:relative; z-index:1; flex: 1; overflow-y: auto; padding: 26px 8% 16px; scroll-behavior: smooth; }
#chat.answering { padding-bottom: var(--answer-reserve, 160px); }
.msg { display: flex; gap: 12px; margin-bottom: 22px; max-width: 860px; }
.msg .avatar { margin-top: 2px; }
.msg .body { min-width: 0; }
.msg .who { font-size: 12.5px; color: var(--dim); margin-bottom: 5px; font-weight: 600; }
.bubble {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 4px 16px 16px 16px; padding: 13px 17px; font-size: 15px; line-height: 1.85;
  overflow-wrap: break-word; box-shadow: 0 3px 14px rgba(47, 52, 72, .045);
}
.msg.user { flex-direction: row-reverse; margin-left: auto; }
.msg.user .bubble {
  background: linear-gradient(135deg, rgba(255,126,182,.16), rgba(167,139,250,.14));
  border-color: rgba(255,126,182,.28); border-radius: 16px 4px 16px 16px;
}
.msg.user .who { text-align: right; }
.event-chip {
  text-align: center; color: var(--dim); font-size: 12px; margin: 18px 0; letter-spacing: 1px;
}

.event-chip.story-entry {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: linear-gradient(110deg, color-mix(in srgb, var(--accent) 12%, var(--card)), var(--card));
  box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--text);
  letter-spacing: .03em;
}
.tool-line { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.tool-chip {
  font-size: 11.5px; color: var(--dim); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 10px;
}
.tool-chip.failed { color: #b42318; background: #fff1f0; border-color: #f7b4ad; }
.meta-line { font-size: 11px; color: var(--dim); margin-top: 7px; }
.typing { display: inline-block; }
.typing i { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--dim); margin-right: 3px; animation: blink 1.2s infinite; font-style: normal; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25 } 30% { opacity: 1 } }

/* ---------- 独立剧情时间线 ---------- */
.story-column-intro {
  margin:4px 8% 0; padding:10px 14px; color:var(--dim); font-size:12px; line-height:1.65;
  border:1px solid color-mix(in srgb, var(--accent) 20%, var(--line)); border-radius:11px;
  background:linear-gradient(100deg, color-mix(in srgb, var(--accent) 7%, white), rgba(255,255,255,.7));
}
.story-timeline { position:relative; padding-top:20px; }
.story-timeline::before {
  content:''; position:absolute; left:calc(8% + 12px); top:18px; bottom:40px; width:1px;
  background:linear-gradient(var(--accent), color-mix(in srgb, var(--accent) 15%, transparent)); opacity:.28;
}
.story-episode {
  position:relative; max-width:920px; margin:0 0 22px 34px; padding:19px 21px;
  border:1px solid color-mix(in srgb, var(--accent) 18%, var(--line)); border-radius:16px;
  background:linear-gradient(135deg, rgba(255,255,255,.96), color-mix(in srgb, var(--accent) 4%, white));
  box-shadow:0 9px 30px rgba(45,49,70,.055);
}
.story-episode::before {
  content:''; position:absolute; left:-28px; top:24px; width:11px; height:11px; border-radius:50%;
  background:var(--accent); border:4px solid var(--bg); box-shadow:0 0 0 1px color-mix(in srgb, var(--accent) 35%, var(--line));
}
.story-episode > header { display:flex; justify-content:space-between; align-items:flex-start; gap:14px; margin-bottom:8px; }
.story-episode > header span { color:var(--accent); font-size:10px; font-weight:800; letter-spacing:1.4px; }
.story-episode > header h3 { margin:3px 0 0; font-size:17px; line-height:1.45; }
.story-episode > header time { color:var(--dim); font-size:10.5px; white-space:nowrap; }
.story-episode-meta { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:13px; }
.story-episode-meta span { padding:3px 8px; color:var(--dim); font-size:10.5px; border-radius:999px; background:var(--bg2); border:1px solid var(--line); }
.story-episode-content { color:var(--text); font-size:14.5px; line-height:1.9; }
.story-episode-content.streaming::after { content:''; display:inline-block; width:2px; height:1em; margin-left:3px; vertical-align:-.12em; background:var(--accent); animation:story-caret .8s steps(1) infinite; }
@keyframes story-caret { 50% { opacity:0; } }
.story-empty { margin:12vh auto; max-width:480px; text-align:center; color:var(--dim); line-height:1.8; }
.story-empty b { display:block; color:var(--text); font-size:17px; margin-bottom:4px; }

/* ---------- 结构化学习产品 ---------- */
.product-grid { overflow:auto; padding:20px; display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; }
.product-card { background:var(--panel); border:1px solid var(--line); border-radius:15px; padding:18px; min-width:0; }
.product-card.wide { grid-column:1/-1; }
.eyebrow { display:block; color:var(--accent); font-size:11px; letter-spacing:1.5px; margin-bottom:8px; }
.product-card h3 { margin-bottom:10px; }.product-content { color:var(--dim); line-height:1.65; }
.mastery-row { display:grid; grid-template-columns:minmax(100px,1fr) 120px 42px; gap:8px; align-items:center; margin:7px 0; font-size:12px; }
.mastery-row progress { width:100%; accent-color:var(--accent); }
.quiz-form fieldset { border:0; border-top:1px solid var(--line); padding:13px 0; }
.quiz-form legend { font-weight:700; margin-bottom:8px; }.quiz-form label { display:block; padding:5px; }
.quiz-form input[type="text"],.quiz-form input:not([type]) { width:100%; padding:10px; border:1px solid var(--line); border-radius:9px; }
.form-error.pass { color:var(--ok); }.report-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:12px; }
.report-grid div { background:var(--bg2); border-radius:12px; padding:14px; display:flex; flex-direction:column; }.report-grid b{font-size:24px}.report-grid span{font-size:12px;color:var(--dim)}
.lab-wrap,.ap-wrap { padding:20px; overflow:auto; }.lab-controls,.ap-toolbar { display:flex; gap:10px; align-items:end; flex-wrap:wrap; margin-bottom:14px; }
.lab-controls label { display:flex; flex-direction:column; gap:5px; color:var(--dim); font-size:12px; }.lab-controls input { padding:9px;border:1px solid var(--line);border-radius:8px; }
.lab-grid { display:grid; grid-template-columns:minmax(0,3fr) minmax(180px,1fr); gap:14px; }.lab-grid canvas { width:100%; height:auto; background:white; border:1px solid var(--line); border-radius:14px; }
#functionTable { width:100%;border-collapse:collapse;background:var(--panel) }#functionTable th,#functionTable td{padding:7px;border-bottom:1px solid var(--line);text-align:right}
.ap-wrap{max-width:900px;margin:0 auto;width:100%}.ap-wrap textarea{width:100%;margin:12px 0;padding:12px;border:1px solid var(--line);border-radius:10px}.ap-wrap label{display:block;padding:7px}.ap-wrap select{padding:8px;border:1px solid var(--line);border-radius:8px}

/* markdown 内容 */
.md p { margin: 8px 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 16px 0 8px; line-height: 1.5; }
.md h1 { font-size: 1.35em; } .md h2 { font-size: 1.22em; } .md h3 { font-size: 1.1em; }
.md ul, .md ol { padding-left: 1.5em; margin: 8px 0; }
.md li { margin: 4px 0; }
.md em { color: #7353ba; font-style: italic; opacity: .96; }   /* 旁白 · 神态动作 */
.md strong { color: #9c2d62; }
.md blockquote { border-left: 3px solid var(--accent); padding: 2px 14px; margin: 10px 0; color: var(--dim); background: rgba(255,126,182,.05); border-radius: 0 8px 8px 0; }
.md code:not(.hljs) { background: var(--bg2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.md pre { margin: 10px 0; border-radius: 10px; overflow: auto; border: 1px solid var(--line); }
.md pre code { display: block; padding: 12px 14px; font-size: 13px; line-height: 1.6; }
.md table { border-collapse: collapse; margin: 10px 0; width: 100%; font-size: 14px; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; }
.md th { background: var(--bg2); }
.md hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.md .katex {
  font-size: 1.18em;
  line-height: 1.35;
}
.md .katex .mfrac { font-size: 1.08em; }
.md .katex-display {
  overflow-x: auto; overflow-y: hidden;
  margin: 12px 0; padding: 10px 8px;
  background: rgba(167, 139, 250, .055);
  border-radius: 9px;
}
.md .katex-display > .katex { font-size: 1.32em; }

/* ---------- 输入区 ---------- */
#composer {
  position:relative; z-index:3; display: flex; gap: 10px; align-items: flex-end;
  padding: 14px 8% 20px; border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(246,247,251,.72), rgba(246,247,251,.97));
}
#input {
  flex: 1; resize: none; max-height: 200px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 13px;
  padding: 12px 15px; font-size: 15px; line-height: 1.6; font-family: inherit;
  outline: none; transition: border-color .15s;
}
#input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#btnSend, .stop {
  border: none; border-radius: 13px; padding: 12px 22px; font-size: 15px; font-weight: 700;
  cursor: pointer; font-family: inherit; color: #ffffff;
  background: linear-gradient(90deg, #ff7eb6, #a78bfa);
}
#btnSend:disabled { opacity: .4; cursor: not-allowed; }
.stop { background: var(--panel2); color: var(--err); border: 1px solid rgba(248,113,113,.4); }
.voice {
  flex: 0 0 auto; min-width: 42px; min-height: 48px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); color: var(--dim); font-size: 18px; cursor: pointer;
  transition: color .15s, border-color .15s, background .15s, transform .05s;
}
.voice:hover { color: var(--accent); border-color: var(--accent); }
.voice:active { transform: scale(.96); }
.voice.listening { color: #fff; border-color: var(--err); background: var(--err); animation: voicePulse 1.15s ease-in-out infinite; }
.voice:disabled { opacity: .45; cursor: not-allowed; animation: none; }
@keyframes voicePulse { 50% { box-shadow: 0 0 0 6px rgba(196, 59, 69, .13); } }

/* ---------- 文档页 ---------- */
.doc-head { display: flex; align-items: center; gap: 12px; padding: 16px 8% 10px; }
.doc-head h2 { font-size: 17px; flex: 0 0 auto; }
.doc-tools { display: flex; gap: 8px; align-items: center; flex: 1; }
.doc-body { flex: 1; overflow-y: auto; padding: 6px 8% 40px; font-size: 15px; line-height: 1.9; }
.mini {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 6px 13px; border-radius: 9px; font-size: 12.5px; cursor: pointer; font-family: inherit;
}
.mini:hover { background: var(--panel2); }
.mini.primary { background: linear-gradient(90deg, rgba(255,126,182,.25), rgba(167,139,250,.25)); border-color: rgba(255,126,182,.45); font-weight: 700; }
#fileSelect {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; padding: 6px 10px; font-size: 12.5px; max-width: 340px; font-family: inherit;
}
.settings-hint { padding: 0 8%; font-size: 12.5px; color: var(--dim); line-height: 1.7; margin-bottom: 10px; }
.automatic-notes {
  flex: 1; overflow-y: auto; margin: 0 8% 20px; background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px; padding: 20px 24px; font-size: 14px; line-height: 1.75;
}

/* ---------- 课程安排 ---------- */
.planner-badge {
  color: var(--accent); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 999px; padding: 3px 10px; font-size: 11px;
}
.planner-body { flex: 1; overflow-y: auto; padding: 4px 8% 40px; }
.planner-card {
  background: linear-gradient(145deg, rgba(255,126,182,.07), rgba(167,139,250,.07));
  border: 1px solid var(--line); border-radius: 16px; padding: 20px; margin-bottom: 20px;
}
.planner-intro { color: var(--dim); line-height: 1.75; font-size: 13px; margin-bottom: 16px; }
.planner-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.planner-grid label { display: flex; flex-direction: column; gap: 6px; }
.planner-grid label > span { color: var(--dim); font-size: 12px; }
.planner-grid select, .planner-grid input {
  width: 100%; min-width: 0; background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; font: inherit; font-size: 13px; outline: none;
}
.planner-grid select:focus, .planner-grid input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.planner-grid select:disabled { opacity: .5; }
.planner-summary { margin-top: 14px; color: var(--dim); font-size: 12.5px; line-height: 1.7; }
.planner-summary b { color: var(--text); }
.planner-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; }
.plan-version-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--line); }
.plan-version-row label { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.plan-version-row label span { color: var(--dim); font-size: 11px; }
.plan-version-row select { width: 100%; min-width: 0; border: 1px solid var(--line); background: var(--bg2); color: var(--text); border-radius: 9px; padding: 7px 9px; font: inherit; font-size: 12px; }
.planner-preview {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px 20px 28px; font-size: 14px; line-height: 1.75; overflow-x: auto;
}
.planner-preview table { min-width: 760px; }
.planner-preview td:first-child, .planner-preview th:first-child { text-align: center; width: 52px; }
.mini:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 学生特点 ---------- */
.profile-wrap { flex: 1; overflow-y: auto; padding: 4px 8% 40px; }
.profile-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.profile-intro { color: var(--dim); font-size: 13px; line-height: 1.75; margin-bottom: 18px; }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.profile-grid label, .login-fields label { display: flex; flex-direction: column; gap: 6px; }
.profile-grid label.wide { grid-column: 1 / -1; }
.profile-grid label > span, .login-fields label > span { color: var(--dim); font-size: 12px; }
.profile-grid input, .profile-grid textarea, .profile-grid select,
.login-fields input, .inline-form input, .admin-create-grid input, .student-admin-row input {
  width: 100%; min-width: 0; background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 13px; outline: none;
}
.profile-grid textarea { resize: vertical; line-height: 1.6; }
.profile-grid input:focus, .profile-grid textarea:focus, .profile-grid select:focus,
.login-fields input:focus, .inline-form input:focus, .admin-create-grid input:focus, .student-admin-row input:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.profile-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.form-error { min-height: 1.5em; color: var(--err); font-size: 12px; margin-top: 9px; }
.avatar-fieldset { border: 0; margin: 0 0 20px; padding: 0; }
.avatar-fieldset legend { color: var(--dim); font-size: 12px; margin-bottom: 9px; }
.avatar-picker {
  display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 8px;
  padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg2);
}
.avatar-option {
  aspect-ratio: 1; min-width: 0; padding: 2px; border: 2px solid transparent; border-radius: 50%;
  background: transparent; cursor: pointer; transition: transform .12s, border-color .12s, box-shadow .12s;
}
.avatar-option:hover { transform: translateY(-2px); }
.avatar-option.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.avatar-option picture { display: contents; }
.avatar-option img { width: 100%; height: 100%; display: block; border-radius: 50%; object-fit: cover; }

@media (max-width: 820px) {
  #app { flex-direction: column; }
  #sidebar {
    width: 100%; min-width: 0; height: auto; flex: 0 0 auto;
    padding: 9px 11px 10px; gap: 7px;
    border-right: 0; border-bottom: 1px solid var(--line);
    box-shadow: 0 5px 18px rgba(47, 52, 72, .055);
  }
  .brand-row { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; }
  .logo { font-size: 17px; letter-spacing: 0; white-space: nowrap; }
  .logo-sub { display: inline; margin: 0 0 0 7px; font-size: 9px; letter-spacing: 1px; }
  .status-pill { flex: 0 0 auto; padding: 5px 9px; font-size: 11px; }
  .student-chip { padding: 6px 9px; }
  .student-chip span { font-size: 12.5px; }
  .side-label { display: none; }
  #teacherList {
    display: flex; gap: 6px; overflow-x: auto; overscroll-behavior-inline: contain;
    scrollbar-width: none; padding-bottom: 1px;
  }
  #teacherList::-webkit-scrollbar { display: none; }
  .teacher-card { flex: 0 0 122px; gap: 7px; padding: 6px 8px; }
  .teacher-card .avatar { width: 30px; height: 30px; min-width: 30px; font-size: 16px; }
  .teacher-card .t-name { font-size: 12px; }
  .teacher-card .t-tag { display: none; }
  .model-control { padding: 6px 9px; }
  .model-control select { font-size: 13px; }
  .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .act { padding: 7px 8px; font-size: 12px; text-align: center; white-space: nowrap; }
  .sidebar-foot { display: none; }
  #main { flex: 1 1 auto; min-height: 0; }
  #tabs { gap: 0; padding: 4px 7px 0; scrollbar-width: none; }
  #tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 0 0 auto; padding: 8px 10px 9px; font-size: 12.5px; white-space: nowrap; }
  .story-scene { min-height:72px; margin:8px 11px 0; padding:10px 11px; gap:9px; border-radius:13px; }
  .story-scene-mark { flex-basis:38px; width:38px; height:38px; border-radius:11px; }
  .story-scene-mark::before { width:24px; top:13px; left:7px; }
  .story-scene-mark::after { width:20px; top:23px; left:10px; }
  .story-scene-mark span, .story-scene-mark i { display:none; }
  .story-scene-copy strong { font-size:14px; }
  .story-scene-copy small { font-size:10.5px; }
  .story-scene-progress { font-size:9.5px; }
  #storySceneKeys { display:none; }
  #chat { padding: 13px 11px 8px; }
  .msg { width: 100%; max-width: 100%; gap: 8px; margin-bottom: 15px; }
  .msg .avatar { width: 32px; height: 32px; min-width: 32px; font-size: 16px; }
  .msg .body { max-width: calc(100% - 40px); }
  .msg.user .body { max-width: 88%; }
  .msg .who { font-size: 11.5px; margin-bottom: 3px; }
  .bubble { padding: 10px 12px; font-size: 14px; line-height: 1.75; }
  .story-column-intro { margin:3px 11px 0; }
  .story-timeline::before { left:23px; }
  .story-episode { margin-left:22px; padding:15px 14px; border-radius:13px; }
  .story-episode::before { left:-18px; }
  .story-episode > header { flex-direction:column; gap:3px; }
  .product-grid { grid-template-columns:1fr; padding:10px; }.product-card.wide{grid-column:auto}.report-grid{grid-template-columns:repeat(2,1fr)}
  .lab-wrap,.ap-wrap{padding:10px}.lab-grid{grid-template-columns:1fr}.mastery-row{grid-template-columns:minmax(90px,1fr) 90px 38px}
  #composer { gap: 7px; padding: 8px 9px calc(9px + env(safe-area-inset-bottom)); }
  #input { min-height: 44px; padding: 9px 11px; font-size: 16px; line-height: 1.5; }
  #btnSend, .stop, .voice { min-height: 44px; }
  #btnSend, .stop { padding: 9px 14px; font-size: 14px; }
  .voice { min-width: 44px; font-size: 18px; }
  .planner-grid, .profile-grid { grid-template-columns: 1fr; }
  .avatar-picker { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; padding: 10px; }
  .profile-grid label.wide { grid-column: auto; }
  .planner-body, .profile-wrap, .doc-body { padding-left: 11px; padding-right: 11px; }
  .planner-card, .profile-card, .planner-preview { padding: 15px 13px; border-radius: 13px; }
  .plan-version-row { align-items: stretch; flex-direction: column; }
  .planner-actions, .profile-actions { flex-wrap: wrap; }
  .doc-head { padding: 11px 11px 8px; flex-wrap: wrap; gap: 8px; }
  .doc-head h2 { font-size: 15px; }
  .doc-tools { min-width: 100%; overflow-x: auto; padding-bottom: 2px; }
  #fileSelect { flex: 1 1 170px; min-width: 150px; }
  .settings-hint { padding: 0 11px; font-size: 12px; }
  .automatic-notes { margin: 0 11px 11px; padding: 15px; font-size: 14px; }
  .planner-grid select, .planner-grid input,
  .profile-grid input, .profile-grid textarea, .profile-grid select,
  .login-fields input, .inline-form input, .admin-create-grid input, .student-admin-row input,
  #fileSelect { font-size: 16px; }
  .md .katex { font-size: 1.16em; }
  .md .katex-display > .katex { font-size: 1.25em; }
  .modal { align-items: flex-start; padding: max(14px, env(safe-area-inset-top)) 0 max(14px, env(safe-area-inset-bottom)); overflow-y: auto; }
  .modal-card { width: calc(100vw - 22px); max-height: none; padding: 20px 17px; border-radius: 15px; }
  .modal-actions { flex-wrap: wrap; }
}

@media (max-width: 430px) {
  .logo-sub { display: none; }
  .status-pill { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .planner-badge { font-size: 10px; padding: 2px 7px; }
  #toast { bottom: 18px; width: max-content; max-width: calc(100vw - 24px); text-align: center; }
}

/* ---------- 弹窗 / 提示 ---------- */
.modal { position: fixed; inset: 0; background: rgba(48, 52, 70, .32); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-card {
  width: min(640px, 92vw); max-height: 86vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px 30px;
  line-height: 1.8; font-size: 14px;
}
.modal-card h2 { margin-bottom: 10px; }
.modal-card ol { padding-left: 1.4em; margin: 10px 0; }
.modal-card li { margin: 10px 0; }
.modal-card pre {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 13px; margin: 7px 0; font-size: 12.5px; overflow-x: auto;
}
.modal-card code { background: var(--bg2); padding: 1px 6px; border-radius: 5px; font-size: .92em; }
.modal-card .dim { color: var(--dim); font-size: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.modal-actions.split { justify-content: space-between; }
.login-card { width: min(460px, 92vw); }
.mobile-blocked-card { text-align:center; }
.mobile-blocked-card .eyebrow { margin-bottom:4px; }
.mobile-blocked-card .modal-actions { justify-content:center; }
.login-fields { display: grid; gap: 13px; margin-top: 16px; }
.onboarding-card { width: min(620px, 94vw); }
.onboarding-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.onboarding-heading h2 { margin: 2px 0 0; }
.onboarding-heading strong { color: var(--accent); white-space: nowrap; font-size: 13px; }
.onboarding-progress { height: 7px; overflow: hidden; margin: 13px 0 12px; border-radius: 999px; background: var(--bg2); }
.onboarding-progress span { display: block; width: 11.11%; height: 100%; border-radius: inherit; background: var(--accent); transition: width .2s ease; }
.onboarding-question { min-height: 190px; display: flex; flex-direction: column; justify-content: center; gap: 11px; }
.onboarding-question label { display: flex; flex-direction: column; gap: 8px; }
.onboarding-question label > span { font-size: 18px; font-weight: 700; line-height: 1.45; }
.onboarding-question small { color: var(--dim); line-height: 1.65; }
.onboarding-question input, .onboarding-question textarea, .onboarding-question select {
  width: 100%; background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 11px;
  padding: 12px 13px; font: inherit; font-size: 15px; outline: none;
}
.onboarding-question textarea { min-height: 110px; resize: vertical; line-height: 1.65; }
.onboarding-question input:focus, .onboarding-question textarea:focus, .onboarding-question select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.ghost-button { color: var(--dim); background: transparent; }
.modal-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-close { border: 0; background: none; color: var(--dim); font-size: 25px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.admin-card { width: min(980px, 94vw); max-height: 92vh; overflow: auto; }
.inline-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; margin-top: 14px; }
.admin-section { margin-top: 18px; }
.admin-toolbar { display: flex; align-items: center; justify-content: space-between; }
.admin-section h3 { font-size: 14px; margin-bottom: 10px; }
.admin-access-section { padding:14px; border:1px solid var(--line); border-radius:12px; background:var(--bg2); }
.admin-access-controls { display:flex; align-items:center; gap:8px; margin-top:10px; }
.admin-access-controls select { flex:1; min-width:220px; padding:7px 10px; border:1px solid var(--line); border-radius:9px; background:var(--panel); color:var(--text); font:inherit; }
.admin-create-grid { display: grid; grid-template-columns: 1fr 1fr 1.5fr auto; gap: 8px; }
.student-admin-list { display: flex; flex-direction: column; gap: 8px; color: var(--dim); }
.student-admin-row {
  display: grid; grid-template-columns: minmax(150px, 1fr) minmax(180px, 1fr) auto;
  align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 11px; padding: 9px 10px;
}
.student-admin-info { display: flex; flex-direction: column; min-width: 0; }
.student-admin-info strong { color: var(--text); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.student-admin-info small { color: var(--dim); font-size: 11px; }
.student-admin-actions { display:flex; flex-wrap:wrap; justify-content:flex-end; gap:6px; }
.mini.danger { color:#a12828; border-color:rgba(180,45,45,.28); background:rgba(220,70,70,.06); }
.mini.danger:hover { background:rgba(220,70,70,.12); }
.admin-file-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.admin-file-tools select { min-width: 150px; flex: 1 1 180px; }
.admin-file-editor { width: 100%; min-height: 260px; resize: vertical; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.admin-detail-card { width:min(1120px,96vw); height:min(900px,94vh); max-height:94vh; overflow:auto; }
.admin-detail-body { margin-top:12px; }
.admin-detail-summary { display:grid; grid-template-columns:repeat(6,minmax(120px,1fr)); gap:9px; }
.admin-metric { min-width:0; padding:12px; border:1px solid var(--line); border-radius:11px; background:var(--bg2); }
.admin-metric span { display:block; color:var(--dim); font-size:11px; }
.admin-metric strong { display:block; margin:5px 0 2px; font-size:21px; overflow-wrap:anywhere; }
.admin-metric small { display:block; color:var(--dim); font-size:10px; line-height:1.45; }
.admin-detail-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; margin-top:10px; }
.admin-detail-section { padding:13px; border:1px solid var(--line); border-radius:11px; background:var(--panel); min-width:0; }
.admin-detail-section h3 { margin-bottom:8px; font-size:13px; }
.admin-detail-section p { margin:5px 0; color:var(--dim); line-height:1.65; }
.admin-detail-section ul { padding-left:18px; color:var(--dim); line-height:1.7; }
.admin-detail-section-head { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.admin-detail-list { display:flex; flex-direction:column; gap:6px; }
.admin-detail-list-row { display:flex; align-items:flex-start; justify-content:space-between; gap:10px; padding:7px 0; border-top:1px solid var(--line); color:var(--dim); font-size:12px; }
.admin-detail-list-row:first-child { border-top:0; }
.admin-detail-list-row b { color:var(--text); }
.admin-conversation-section { margin-top:10px; }
.admin-conversation-list { display:flex; flex-direction:column; gap:8px; max-height:340px; overflow:auto; }
.admin-conversation-row { padding:9px 10px; border-radius:9px; background:var(--bg2); border:1px solid var(--line); }
.admin-conversation-meta { display:flex; justify-content:space-between; gap:10px; margin-bottom:4px; color:var(--dim); font-size:10px; }
.admin-conversation-meta b { color:var(--text); font-size:11px; }
.admin-conversation-text { white-space:pre-wrap; overflow-wrap:anywhere; color:var(--text); font-size:12px; line-height:1.65; }

@media (max-width: 680px) {
  .admin-create-grid, .student-admin-row, .inline-form { grid-template-columns: 1fr; }
  .admin-access-controls { align-items:stretch; flex-direction:column; }
  .admin-access-controls select { min-width:0; width:100%; font-size:16px; }
  .student-admin-actions { justify-content:flex-start; }
  .admin-detail-card { width:calc(100vw - 16px); height:auto; max-height:none; padding:17px 13px; }
  .admin-detail-summary { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .admin-detail-grid { grid-template-columns:1fr; }
}

#toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 22px; border-radius: 999px; font-size: 13.5px; z-index: 60;
  box-shadow: 0 8px 30px rgba(47,52,72,.18);
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #bfc5d4; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 820px) {
  .modal {
    align-items: flex-start;
    padding: max(14px, env(safe-area-inset-top)) 0 max(14px, env(safe-area-inset-bottom));
    overflow-y: auto;
  }
  .modal-card { width: calc(100vw - 22px); max-height: none; padding: 20px 17px; border-radius: 15px; }
}

@media (max-width: 430px) {
  #toast {
    bottom: 18px; width: max-content; max-width: calc(100vw - 24px);
    padding: 9px 15px; text-align: center;
  }
}
