:root {
  --primary: #1E3A5F; --accent: #F97316; --accent2: #2E86AB;
  --bg: #FAF7F2; --card: #fff; --text: #1f2937; --muted: #6B7280; --border: #E5E7EB;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "PingFang SC","微软雅黑",sans-serif; background: var(--bg); color: var(--text); }
button { cursor: pointer; border: none; border-radius: 8px; font-size: 14px; padding: 8px 14px; background: #eee; }
button.primary { background: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
button:disabled { opacity: .5; cursor: not-allowed; }
input, textarea { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 15px; width: 100%; outline: none; }
input:focus, textarea:focus { border-color: var(--accent2); }

.topbar { position: sticky; top: 0; z-index: 10; background: var(--primary); color: #fff; display: flex; align-items: center; gap: 10px; padding: 10px 14px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs button { background: transparent; color: #cbd5e1; padding: 6px 12px; }
.tabs button.active { background: rgba(255,255,255,.15); color: #fff; font-weight: 600; }
.userbox { font-size: 13px; color: #cbd5e1; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 860px; margin: 0 auto; padding: 16px 14px 60px; }
.tab { display: none; } .tab.active { display: block; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 14px; }

/* 教材浏览 */
.book-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.book-picker button { background: #fff; border: 1px solid var(--border); }
.book-picker button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.toc-tree { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 10px; }
.toc-unit { margin-bottom: 4px; }
.toc-unit > .u-head { display:flex; justify-content: space-between; padding: 10px 12px; background: #f1f5f9; border-radius: 8px; cursor: pointer; font-weight: 600; }
.toc-lessons { display: none; padding: 4px 8px; }
.toc-unit.open .toc-lessons { display: block; }
.lesson { margin: 8px 0 2px; font-weight: 600; color: var(--primary); padding: 4px 8px; }
.frames { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 8px 8px 20px; }
.frames button { background: #eef6fb; color: var(--accent2); font-weight: 500; }

/* 检索 */
.search-bar { display: flex; gap: 8px; }
.search-bar input { flex: 1; }
.search-bar button { background: var(--primary); color: #fff; }
.sr-item { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.sr-item .where { color: var(--accent); font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.sr-item .ctx { font-size: 14px; line-height: 1.6; }
.sr-item .ctx mark { background: #fde68a; padding: 0 2px; border-radius: 3px; }
.sr-item .goto { color: var(--accent2); font-size: 13px; background: none; padding: 4px 0; text-decoration: underline; }

/* 答题助手 */
.qa-box { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.qa-method { background: #fff7ed; border-left: 4px solid var(--accent); padding: 8px 12px; border-radius: 6px; font-size: 13.5px; margin-bottom: 12px; line-height: 1.7; }
.qa-actions { display: flex; gap: 10px; margin-top: 12px; }
.qa-output { margin-top: 16px; border-top: 1px dashed var(--border); padding-top: 14px; white-space: pre-wrap; line-height: 1.9; font-size: 15px; }
.qa-output .cite { background: #eef6fb; color: var(--accent2); border-radius: 6px; padding: 1px 6px; font-size: 13px; }
.qa-output .cite-link { border: 1px solid #cfe3ef; cursor: pointer; font-family: inherit; margin: 2px 2px; }
.qa-output .cite-link:hover { background: var(--accent2); color: #fff; border-color: var(--accent2); }
.qa-history { margin-top: 18px; }

/* 我的 */
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; max-width: 420px; margin: 0 auto; }
.login-card h3 { font-size: 15px; color: var(--primary); margin-bottom: 14px; }
.login-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.login-tabs button { flex: 1; }
.login-tabs button.active { background: var(--primary); color: #fff; }
#phoneLogin .code-row { display: flex; gap: 8px; margin: 10px 0; }
#phoneLogin .code-row button { white-space: nowrap; }
#phoneLoginBtn, .wechat-btn { width: 100%; margin-top: 4px; }
.wechat-btn { background: #07c160; color: #fff; font-weight: 600; padding: 11px; }
.login-msg { color: #dc2626; font-size: 13px; margin-top: 10px; min-height: 18px; }
.me-head { display: flex; justify-content: space-between; align-items: center; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; font-weight: 600; }
.fav-list .sr-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.fav-list .sr-item .ctx { flex: 1; }
.teacher-stats { margin-top: 20px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; }
.teacher-stats summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.teacher-stats .stat-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(140px,1fr)); gap: 10px; margin: 12px 0; }
.stat-card { background: #f1f5f9; border-radius: 10px; padding: 12px; text-align: center; }
.stat-card b { display: block; font-size: 22px; color: var(--accent); }
.stat-card span { font-size: 12px; color: var(--muted); }
.stat-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stat-table th, .stat-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; }
.stat-table th { background: #f8fafc; }

/* 页面查看器 */
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 100; display: flex; flex-direction: column; }
.viewer-top { display: flex; justify-content: space-between; align-items: center; color: #fff; padding: 10px 14px; gap: 10px; }
.viewer-top button { background: rgba(255,255,255,.15); color: #fff; margin-left: 6px; }
.viewer-body { flex: 1; overflow: auto; text-align: center; padding: 0 8px 20px; }
.viewer-body img { max-width: 100%; border-radius: 6px; }
