:root {
  --brand: #3B6EF6; --brand-deep: #2C56CC; --brand-soft: #E9F0FF;
  --accent: #FF8A3D; --accent-soft: #FFF1E5;
  --success: #22B573; --success-soft: #E3F7EE;
  --danger: #F0544F;
  --ink: #1F2A44; --muted: #7A86A6; --line: #E4EAF6;
  --bg: #F3F7FF; --card: #FFFFFF;
  --radius: 16px;
  --shadow: 0 4px 16px rgba(31, 42, 68, .07);
}
* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: -apple-system, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, #EAF1FF 0%, var(--bg) 240px);
  color: var(--ink); min-height: 100vh;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(84px + env(safe-area-inset-bottom));
}
#app { max-width: 560px; margin: 0 auto; }
.hidden { display: none !important; }

/* ===== 卡片与文字 ===== */
.card {
  background: var(--card); border-radius: var(--radius); padding: 20px 18px;
  box-shadow: var(--shadow); border: 1px solid #fff;
}
h1 { font-size: 22px; letter-spacing: .5px; }
h2.sec { font-size: 15px; margin: 18px 0 8px; display: flex; align-items: center; gap: 6px; }
h2.sec::before { content: ""; width: 4px; height: 14px; border-radius: 2px; background: var(--brand); }
.sub { color: var(--muted); font-size: 13px; }

/* ===== 吉祥物 ===== */
.mascot { display: block; }
.mascot .cap { fill: var(--brand); }
.mascot .face { fill: #FFE08A; }
.mascot .cheek { fill: #FFB37E; opacity: .55; }
.mascot.big { animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ===== 登录 / 引导 ===== */
#view-login, #view-onboarding { text-align: center; }
#view-login .card, #view-onboarding .card { text-align: left; margin-top: 14px; }
.brand-line { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 6vh; }
.brand-line h1 { font-size: 26px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
input, select {
  width: 100%; padding: 13px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  font-size: 16px; background: #FBFCFF; color: var(--ink); min-height: 48px;
}
input:focus, select:focus { outline: none; border-color: var(--brand); background: #fff; }
button {
  width: 100%; min-height: 48px; border: none; border-radius: 12px; font-size: 16px;
  font-weight: 600; cursor: pointer; margin-top: 10px; transition: transform .06s ease, filter .15s;
}
button:active { transform: scale(.98); }
button.primary { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(59,110,246,.35); }
button.plain { background: var(--brand-soft); color: var(--brand-deep); }
.msg { font-size: 13px; color: var(--muted); margin-top: 10px; min-height: 1.2em; }
.consent { display: flex; gap: 8px; align-items: flex-start; margin: 14px 0 2px; font-size: 12px; line-height: 1.5; }
.consent input { width: 18px; height: 18px; min-height: 0; flex: none; margin-top: 1px; }

/* 年级选择（引导页） */
.grades { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 6px; }
.grade {
  min-height: 48px; margin: 0; border-radius: 12px; background: #FBFCFF;
  border: 1.5px solid var(--line); color: var(--muted); font-size: 15px;
}
.grade.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ===== 对话页 ===== */
.chat-head { display: flex; align-items: center; gap: 10px; }
.chat-head .title { flex: 1; }
.chat-head h1 { font-size: 18px; }
.state-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700;
  background: var(--brand-soft); color: var(--brand-deep); border-radius: 999px; padding: 5px 13px;
}
.state-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
button.mini { width: auto; min-height: 36px; margin: 0; padding: 0 14px; font-size: 13px; background: var(--brand-soft); color: var(--brand-deep); }

.sessions-label select { margin-top: 2px; }
#chat-log { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 8px; max-height: 52vh; overflow-y: auto; padding: 2px; }
.bubble {
  padding: 12px 14px; border-radius: 16px; font-size: 15px; line-height: 1.6; max-width: 86%;
  white-space: pre-wrap; word-break: break-word;
}
.bubble.child { background: var(--brand); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.coach { background: #EDF2FF; color: var(--ink); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.typing { display: flex; gap: 5px; align-items: center; padding: 14px 16px; }
.bubble.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.bubble.typing i:nth-child(2) { animation-delay: .2s; }
.bubble.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }

.chips { display: flex; gap: 8px; margin: 4px 0 6px; overflow-x: auto; padding-bottom: 2px; }
button.chip {
  width: auto; min-height: 38px; margin: 0; padding: 0 16px; font-size: 14px; font-weight: 500;
  border-radius: 999px; background: #fff; color: var(--brand-deep);
  border: 1.5px solid var(--line); flex: none;
}
.row { display: flex; gap: 8px; }
.row input { flex: 1; }
.row button { width: auto; margin: 0; padding: 0 20px; }
.sel { width: auto; min-width: 96px; }

/* 提醒开启横幅 */
.notif-banner {
  display: flex; align-items: center; gap: 10px; background: var(--accent-soft);
  border-radius: 12px; padding: 10px 12px; margin-top: 10px; font-size: 13px; color: #B4531A;
}
.notif-banner button { width: auto; min-height: 34px; margin: 0; padding: 0 14px; font-size: 13px; background: var(--accent); color: #fff; }

/* ===== 工作台 ===== */
.weekly-card { background: linear-gradient(135deg, #3B6EF6 0%, #5E8BFF 100%); color: #fff; border-radius: var(--radius); padding: 16px 18px; margin-top: 14px; box-shadow: 0 6px 18px rgba(59,110,246,.3); }
.weekly-card .num { font-size: 30px; font-weight: 700; }
.weekly-card .bar { height: 8px; background: rgba(255,255,255,.25); border-radius: 4px; margin-top: 10px; overflow: hidden; }
.weekly-card .bar i { display: block; height: 100%; background: #fff; border-radius: 4px; transition: width .5s; }
.plan-item { display: flex; align-items: center; gap: 10px; padding: 12px 4px; border-bottom: 1px dashed var(--line); font-size: 14px; }
.plan-item .box { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); flex: none; display: flex; align-items: center; justify-content: center; font-size: 14px; color: #fff; }
.plan-item.done .box { background: var(--success); border-color: var(--success); }
.plan-item .meta { flex: 1; min-width: 0; }
.plan-item .meta small { color: var(--muted); font-size: 12px; display: block; margin-top: 2px; }
.plan-item button { width: auto; min-height: 36px; margin: 0; padding: 0 14px; font-size: 13px; }
.record-item { padding: 12px 4px; border-bottom: 1px dashed var(--line); font-size: 14px; }
.record-item .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.record-item small { color: var(--muted); font-size: 12px; display: block; margin-top: 4px; }
.mastery-dots { display: inline-flex; gap: 4px; }
.mastery-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.mastery-dots i.on { background: var(--success); }
#plan-list, #record-list { max-height: 42vh; overflow-y: auto; }
.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 18px 0; }

/* ===== 底部导航 ===== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; gap: 10px;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.tabbar .tab {
  width: 150px; margin: 0; min-height: 44px; border-radius: 999px; font-size: 15px;
  background: transparent; color: var(--muted);
}
.tabbar .tab.active { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(59,110,246,.35); }

/* ===== 奖励弹窗 ===== */
.modal-mask { position: fixed; inset: 0; background: rgba(21,30,55,.45); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal { background: #fff; border-radius: 20px; padding: 28px 24px; text-align: center; max-width: 320px; width: 100%; position: relative; overflow: hidden; }
.modal .mascot { margin: 12px auto 10px; }
.modal h3 { font-size: 18px; margin: 6px 0; }
.modal p { color: var(--muted); font-size: 14px; line-height: 1.6; }
.confetti { position: absolute; top: -8px; font-size: 16px; animation: fall 1.8s ease-in forwards; }
@keyframes fall { to { transform: translateY(340px) rotate(220deg); opacity: 0; } }

/* ===== Toast ===== */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(16px); bottom: calc(96px + env(safe-area-inset-bottom));
  background: rgba(31,42,68,.92); color: #fff; font-size: 14px; border-radius: 999px;
  padding: 10px 18px; z-index: 60; opacity: 0; transition: all .25s; pointer-events: none; max-width: 86vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
