:root {
  --bg: #F6F4EF;
  --card: #FFFFFF;
  --ink: #1F2430;
  --muted: #6B7280;
  --line: #E7E3DA;
  --brand: #FF7A45;
  --brand-ink: #C2410C;
  --brand-soft: #FFF1E8;
  --blue: #3B6FE0;
  --blue-soft: #EAF0FD;
  --ok: #15803D;
  --ok-soft: #E7F6EC;
  --bad: #B91C1C;
  --bad-soft: #FDECEC;
  --lv-none: #ECEAE4;
  --lv-start: #DCE3FA;
  --lv-weak: #F9C9C3;
  --lv-mid: #FBE29A;
  --lv-good: #A8E5BF;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(31, 36, 48, .06), 0 4px 16px rgba(31, 36, 48, .05);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 16px; line-height: 1.6; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
.boot { padding: 80px 20px; text-align: center; color: var(--muted); }

.wrap { max-width: 760px; margin: 0 auto; padding: 16px 16px 96px; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 4px 0 12px; }
.topbar h1 { font-size: 20px; margin: 0; flex: 1; min-width: 0; }
.topbar .back { font-size: 15px; padding: 6px 10px 6px 0; color: var(--muted); background: none; border: 0; cursor: pointer; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--brand-soft); color: var(--brand-ink); border-radius: 999px; padding: 4px 12px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }
.pre { white-space: pre-wrap; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card, .card + .section, .section + .card, .section + .section { margin-top: 14px; }
.card h2, .section h2 { font-size: 17px; margin: 0 0 10px; }
.section h2 { margin: 22px 4px 10px; }
.card h3 { font-size: 15px; margin: 0 0 6px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 600; cursor: pointer; background: var(--ink); color: #fff; min-height: 44px; transition: transform .08s, opacity .15s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.brand { background: var(--brand); }
.btn.blue { background: var(--blue); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.soft { background: var(--brand-soft); color: var(--brand-ink); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.sm { padding: 6px 12px; min-height: 34px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.big { font-size: 18px; min-height: 54px; border-radius: 14px; }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; outline: none; min-height: 44px;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { min-height: 96px; resize: vertical; }
label.field { display: block; }
label.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

/* 登录 */
.login { max-width: 380px; margin: 10vh auto 0; padding: 16px; }
.login .logo { width: 64px; height: 64px; margin: 0 auto 12px; display: block; }
.login h1 { text-align: center; margin: 0 0 4px; font-size: 26px; }

/* 孩子首页 */
.hello { font-size: 22px; font-weight: 700; }
.goal-dots { display: flex; gap: 8px; margin: 6px 0; }
.goal-dots i { width: 28px; height: 28px; border-radius: 50%; background: var(--lv-none); display: inline-flex; align-items: center; justify-content: center; font-style: normal; font-size: 15px; }
.goal-dots i.on { background: var(--brand); color: #fff; }
.start-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
@media (max-width: 480px) { .start-grid { grid-template-columns: 1fr; } }
.start { position: relative; text-align: left; border: 0; border-radius: var(--radius); padding: 18px 16px; cursor: pointer; box-shadow: var(--shadow); background: var(--card); min-height: 120px; }
.start .kind { font-size: 14px; font-weight: 600; color: var(--muted); }
.start .what { font-size: 19px; font-weight: 700; margin: 4px 0 6px; }
.start.school { background: linear-gradient(135deg, #FFF1E8, #FFE2CF); }
.start.olym { background: linear-gradient(135deg, #EAF0FD, #D9E4FB); }
.start .tag { position: absolute; top: 12px; right: 12px; background: var(--ink); color: #fff; font-size: 12px; border-radius: 999px; padding: 2px 8px; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 480px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { border: 0; border-radius: 14px; padding: 14px 10px; text-align: center; cursor: pointer; background: var(--card); box-shadow: var(--shadow); font-weight: 600; font-size: 15px; position: relative; }
.tile .ico { font-size: 24px; display: block; line-height: 1.2; }
.badge { position: absolute; top: 6px; right: 8px; background: var(--bad); color: #fff; font-size: 12px; border-radius: 999px; min-width: 20px; padding: 0 6px; }
.banner { background: var(--ink); color: #fff; border-radius: var(--radius); padding: 16px; margin-top: 14px; }
.banner p { margin: 4px 0 12px; opacity: .85; font-size: 15px; }

/* 知识地图 */
.unit { margin-top: 14px; }
.unit-name { font-size: 14px; color: var(--muted); margin: 0 4px 6px; }
.map-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.node { border: 0; border-radius: 12px; padding: 10px 12px; text-align: left; cursor: pointer; font-size: 14px; font-weight: 600; min-height: 64px; display: flex; flex-direction: column; justify-content: space-between; }
.node .lv { font-size: 12px; font-weight: 500; opacity: .75; }
.lv-none { background: var(--lv-none); color: #6B675E; }
.lv-start { background: var(--lv-start); }
.lv-weak { background: var(--lv-weak); }
.lv-mid { background: var(--lv-mid); }
.lv-good { background: var(--lv-good); }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 13px; color: var(--muted); margin: 6px 4px 0; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -1px; margin-right: 4px; }

/* 闯关 */
.steps { display: flex; gap: 6px; margin: 2px 0 14px; }
.steps span { flex: 1; text-align: center; font-size: 13px; padding: 6px 0; border-radius: 999px; background: var(--lv-none); color: var(--muted); }
.steps span.on { background: var(--brand); color: #fff; font-weight: 600; }
.steps span.done { background: var(--brand-soft); color: var(--brand-ink); }
.progress { height: 8px; background: var(--lv-none); border-radius: 999px; overflow: hidden; margin-bottom: 12px; }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .3s; }
.q-meta { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.stars-d { color: #F59E0B; letter-spacing: 1px; }
.question { font-size: 19px; line-height: 1.7; font-weight: 500; margin: 0 0 16px; white-space: pre-wrap; }
.answers { display: grid; gap: 10px; }
.answers .blank { display: flex; align-items: center; gap: 10px; }
.answers .blank b { min-width: 3em; font-weight: 600; }
.answers input { font-size: 20px; text-align: center; max-width: 220px; }
.answers input.ok { border-color: var(--ok); background: var(--ok-soft); }
.answers input.no { border-color: var(--bad); background: var(--bad-soft); }
.choices { display: grid; gap: 8px; }
.choice { text-align: left; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 14px; cursor: pointer; font-size: 17px; }
.choice.sel { border-color: var(--brand); background: var(--brand-soft); }
.choice.ok { border-color: var(--ok); background: var(--ok-soft); }
.choice.no { border-color: var(--bad); background: var(--bad-soft); }
.hint { background: #FFF8DB; border-radius: 12px; padding: 10px 12px; font-size: 15px; white-space: pre-wrap; }
.hint b { color: #92400E; }
.feedback { border-radius: 12px; padding: 12px 14px; margin-top: 14px; }
.feedback.ok { background: var(--ok-soft); color: #14532D; }
.feedback.no { background: var(--bad-soft); color: #7F1D1D; }
.feedback.retry { background: #FFF4E5; color: #7C2D12; }
.feedback .big { font-size: 18px; font-weight: 700; }
.solution { background: #F8F7F3; border-radius: 12px; padding: 12px 14px; margin-top: 10px; white-space: pre-wrap; font-size: 15px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.lesson { font-size: 17px; line-height: 1.85; white-space: pre-wrap; }
.result-stars { font-size: 48px; letter-spacing: 6px; color: #F59E0B; text-align: center; line-height: 1.2; }
.result-stars .off { color: var(--lv-none); }
.change { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 15px; }
.change .arrow { color: var(--muted); }
.chip { display: inline-block; font-size: 12px; border-radius: 999px; padding: 2px 8px; font-weight: 600; }

/* 聊天 */
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 86%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; font-size: 16px; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: #fff; box-shadow: var(--shadow); border-bottom-left-radius: 4px; }
.msg img { max-width: 100%; border-radius: 10px; display: block; margin-bottom: 6px; }
.composer { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; }
.composer textarea { min-height: 48px; height: 48px; }
.composer .btn { flex: none; white-space: nowrap; }
.btn { white-space: nowrap; }
.typing { color: var(--muted); font-size: 14px; }

/* 家长 */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 560px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: var(--card); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .v { font-size: 24px; font-weight: 700; line-height: 1.2; }
.kpi .l { font-size: 13px; color: var(--muted); }
.bars { display: flex; gap: 12px; align-items: flex-end; height: 110px; padding-top: 8px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.bar i { display: block; width: 100%; max-width: 44px; background: var(--brand); border-radius: 6px 6px 2px 2px; min-height: 3px; }
.bar.now i { background: var(--ink); }
.list { display: flex; flex-direction: column; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); cursor: default; }
.item:first-child { border-top: 0; }
.item.link { cursor: pointer; }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 600; }
.item .s { font-size: 13px; color: var(--muted); }
.ok-t { color: var(--ok); font-weight: 600; }
.no-t { color: var(--bad); font-weight: 600; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tabs a { flex: 1; max-width: 140px; text-align: center; padding: 10px 0 8px; font-size: 13px; color: var(--muted); }
.tabs a .ico { display: block; font-size: 20px; line-height: 1.2; }
.tabs a.on { color: var(--brand-ink); font-weight: 600; }
.seg { display: inline-flex; background: var(--lv-none); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.seg button.on { background: #fff; box-shadow: var(--shadow); font-weight: 600; }
.prob { padding: 12px 0; border-top: 1px solid var(--line); }
.prob:first-child { border-top: 0; }
.prob .q { white-space: pre-wrap; }
.prob.off { opacity: .5; }
.tag { display: inline-block; font-size: 12px; border-radius: 6px; padding: 1px 6px; background: var(--lv-none); color: #555; }
.tag.ai { background: var(--blue-soft); color: var(--blue); }
.tag.me { background: var(--brand-soft); color: var(--brand-ink); }
.tag.warn { background: #FFF4E5; color: #9A3412; }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { width: 20px; height: 20px; margin-top: 3px; flex: none; }
.report { white-space: pre-wrap; font-size: 15px; line-height: 1.8; }
.att { padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }
.att:first-child { border-top: 0; }

/* 弹窗与提示 */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 22, 28, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.modal { background: #fff; width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .modal-bg { align-items: center; } .modal { border-radius: 20px; } }
.modal h2 { margin: 0 0 10px; font-size: 19px; }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 15px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 60; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .7s linear infinite; vertical-align: -3px; }
@keyframes sp { to { transform: rotate(360deg); } }
.pop { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: scale(.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- 适配：iPad 和电脑 ---------- */
.wrap.wide { max-width: 760px; }
.cols { display: block; }
.cols > * + * { margin-top: 14px; }
@media (hover: hover) {
  .btn:hover { opacity: .9; }
  .start:hover, .tile:hover, .node:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(31, 36, 48, .08), 0 8px 24px rgba(31, 36, 48, .08); }
  .item.link:hover { background: #FAF8F4; }
  .start, .tile, .node { transition: transform .12s, box-shadow .12s; }
}
/* iPad 竖屏及以上 */
@media (min-width: 700px) {
  body { font-size: 17px; }
  .wrap { padding: 24px 24px 110px; max-width: 820px; }
  .wrap.wide { max-width: 960px; }
  .topbar h1 { font-size: 22px; }
  .hello { font-size: 26px; }
  .start { min-height: 150px; padding: 22px 20px; }
  .start .what { font-size: 22px; }
  .question { font-size: 21px; }
  .answers input { font-size: 22px; }
  .map-row { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .kpi .v { font-size: 28px; }
  .tabs a { font-size: 14px; }
}
/* 横屏 iPad 和电脑：家长端导航放到顶部，看板两栏 */
@media (min-width: 1000px) {
  .wrap { max-width: 860px; }
  .wrap.wide { max-width: 1120px; padding-top: 84px; padding-bottom: 40px; }
  .wrap.wide .tabs { top: 0; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); justify-content: center; gap: 4px; padding: 0; }
  .wrap.wide .tabs a { max-width: none; flex: none; display: flex; align-items: center; gap: 6px; padding: 16px 18px; font-size: 15px; }
  .wrap.wide .tabs a .ico { display: inline; font-size: 17px; }
  .wrap.wide .tabs a.on { box-shadow: inset 0 -3px 0 var(--brand); }
  .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  .cols > * + * { margin-top: 0; }
  .cols > .card + .card, .cols > .section + .section { margin-top: 0; }
  .cols .section h2 { margin-top: 8px; }
  .session-wrap { max-width: 760px; margin: 0 auto; }
  #toast { bottom: 40px; }
}
.bar i.zero { background: var(--lv-none); }
