* { box-sizing: border-box; margin: 0; padding: 0; }

/* 荣誉图片墙 */
.honor-intro { display:flex; align-items:center; justify-content:space-between; gap:16px; background:linear-gradient(120deg,#fff8e7,#fffdf7); border-color:#efdfb5; }
.honor-intro h2 { font-size:21px; overflow-wrap:anywhere; }
.honor-intro .btn { flex-shrink:0; min-height:44px; }
.honor-grid { columns:3; column-gap:16px; }
.honor-card { padding:0; overflow:hidden; min-width:0; break-inside:avoid; -webkit-column-break-inside:avoid; page-break-inside:avoid; margin:0 0 16px; }
.honor-cover { display:block; width:100%; border:0; background:#faf7ef; cursor:pointer; padding:0; line-height:0; }
.honor-cover img { display:block; width:100%; height:auto; }
.honor-cover:focus-visible { outline:3px solid var(--primary); outline-offset:-3px; }
.honor-info { padding:14px; }
.honor-info h3 { font-size:16px; overflow-wrap:anywhere; }
.honor-note { font-size:14px; line-height:1.6; white-space:pre-wrap; overflow-wrap:anywhere; margin-top:8px; }
.honor-full { display:block; width:100%; max-height:55dvh; object-fit:contain; margin:12px auto; border-radius:8px; background:#faf7ef; }
.honor-upload-preview { min-height:60px; padding:8px; border:1px dashed var(--line); border-radius:10px; }
.honor-upload-preview .honor-full { max-height:220px; }
.honor-goals { display:flex; flex-wrap:wrap; gap:8px; }
.honor-goals .btn { white-space:normal; text-align:left; overflow-wrap:anywhere; min-height:44px; }
.honor-empty-icon { font-size:56px; margin-bottom:12px; }
#hf-image { width:100%; min-width:0; font-size:14px; }
#hf-note { width:100%; resize:vertical; font:inherit; border:1px solid var(--line); border-radius:10px; padding:10px; }
@media (max-width:600px) {
  .honor-intro { align-items:flex-start; flex-direction:column; gap:10px; }
  .honor-intro h2 { font-size:19px; }
  .honor-grid { columns:2; column-gap:10px; }
  .honor-card { margin-bottom:10px; }
  .honor-info { padding:10px; }
  .honor-info h3 { font-size:14px; }
  .honor-info .hint { font-size:12px; }
  #hf-note { font-size:16px; }
}

/* 积分记录 */
.points-overview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: center; }
.points-overview b { display: block; font-size: 24px; overflow-wrap: anywhere; }
.points-overview span { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.points-income { color: #16834d; }
.points-expense { color: #c33939; }
.points-filters .btn, .points-pagination .btn { min-height: 44px; }
.points-hint { margin: 10px 4px 14px; }
.points-record .task-deadline { overflow-wrap: anywhere; }
.points-pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px; margin: 16px 0; font-size: 13px; }

:root {
  --primary: #5b8cff;
  --primary-dark: #3f6ff0;
  --line: #e4e7ec;
  --panel: #f3f5f7;
  --green: #2ecc71;
  --amber: #ffb020;
  --red: #ff6b6b;
  --ink: #2d3340;
  --muted: #8a93a6;
  --card: #ffffff;
  --bg1: #eef4ff;
  --bg2: #fdf0ff;
  --radius: 16px;
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #fff;
  color: var(--ink);
  min-height: 100vh;
}

/* ---------- 顶栏 / 标签页 ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50; background: #fff;
}
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 18px; }
.wallet {
  background: #fff; border: 1px solid var(--line); color: var(--ink);
  font-weight: 700; padding: 6px 14px; border-radius: 999px; font-size: 14px;
}
.wallet b { font-size: 17px; }

.tabs {
  display: flex; background: #fff; border-bottom: 1px solid var(--line);
  padding: 6px 8px; gap: 4px; overflow-x: auto;
}
.tabs button {
  flex: 1; min-width: 62px; border: 0; background: transparent; color: var(--muted);
  font-size: 15px; font-weight: 600; padding: 10px 4px; border-radius: 12px; cursor: pointer;
  transition: .15s; font-family: inherit; white-space: nowrap;
}
.tabs button.active {
  background: #edf3ff; color: var(--primary-dark);
}

/* ---------- 成长目标顶部横幅 ---------- */
#goalBar { padding: 0 8px; }
#goalBar:empty { display: none; }
.goal-banner {
  display: flex; align-items: center; gap: 10px; width: 100%;
  margin: 8px 0 6px; padding: 10px 12px; text-align: left; cursor: pointer;
  font-family: inherit; color: #6a3d00;
  background: linear-gradient(90deg, #fff6e0, #ffeed2);
  border: 1px solid #ffd68a; border-radius: 12px;
}
.goal-banner.achieved { background: linear-gradient(90deg, #e6fbef, #d5f6e4); border-color: #9fe0bd; color: #12643c; }
.countdown-banner { display:flex; align-items:center; gap:10px; width:100%; margin:6px 0; padding:8px 12px; border:1px solid #f3cf7a; border-radius:12px; background:linear-gradient(90deg,#fff8e5,#fff2c7); color:#74510a; box-sizing:border-box; }
.countdown-flag { font-size:22px; flex:0 0 auto; }
.goal-banner:focus-visible { outline: 3px solid #ffc94d; outline-offset: 2px; }
.goal-flag { font-size: 20px; line-height: 1; flex: none; }
.goal-body { min-width: 0; display: grid; gap: 2px; }
.goal-title { font-weight: 800; font-size: 15px; color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-meta { font-size: 12px; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-arrow { margin-left: auto; font-size: 20px; opacity: .6; flex: none; }

/* ---------- 每日小知识横条 ---------- */
.tip-banner {
  display: flex; align-items: stretch; gap: 8px; width: 100%; box-sizing: border-box;
  margin: 8px 0 6px; padding: 0;
}
.tip-main {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
  padding: 10px 12px; text-align: left; cursor: pointer; font-family: inherit;
  color: #0b4a8f; background: linear-gradient(90deg, #e8f3ff, #d9ecff);
  border: 1px solid #a8ccf5; border-radius: 12px;
}
.tip-main:focus-visible { outline: 3px solid #7fb8f5; outline-offset: 2px; }
.tip-flag { font-size: 20px; line-height: 1; flex: none; }
.tip-refresh {
  flex: none; align-self: center; width: 40px; height: 40px;
  background: #fff; border: 1px solid #a8ccf5; border-radius: 10px;
  font-size: 17px; cursor: pointer; transition: .15s;
}
.tip-refresh:active { transform: rotate(180deg); }
.tip-refresh:disabled { opacity: .5; cursor: wait; }

main { max-width: 980px; margin: 0 auto; padding: 24px 16px 90px; }

/* ---------- 首页：学生端 / 家长端 ---------- */
.home-board {
  display: grid; grid-template-columns: minmax(0, .55fr) minmax(0, 1.45fr);
  gap: 14px; align-items: stretch; max-width: 720px; margin: 0 auto;
}
.home-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px; min-width: 0;
}
.home-panel-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 8px 8px 10px;
}
.home-panel-head span { font-size: 18px; font-weight: 800; color: #1f1f1f; }
.home-panel-head small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.home-list { display: grid; gap: 8px; }
.tile-card {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 14px 12px; min-height: 48px; text-align: left; cursor: pointer;
  font-family: inherit; color: inherit; transition: border-color .15s, background .15s;
}
.tile-card:hover, .tile-card:focus-visible { border-color: #9fb8ff; background: #fbfdff; }
.tile-card:focus-visible,
.tabs button:focus-visible,
.btn:focus-visible,
.icon-btn:focus-visible {
  outline: 3px solid #9fb8ff; outline-offset: 2px;
}
.tile-icon { font-size: 22px; line-height: 1; flex: none; }
.tile-body { min-width: 0; display: grid; gap: 2px; }
.tile-title { font-weight: 750; font-size: 15px; color: #1f1f1f; }
.tile-desc { font-size: 12px; color: var(--muted); }
.tile-arrow { margin-left: auto; color: var(--muted); font-size: 20px; line-height: 1; flex: none; }

/* ---------- 通用 ---------- */
.sec { font-size: 16px; margin: 18px 6px 10px; color: var(--muted); font-weight: 700; }
.card {
  background: var(--card); border-radius: 12px; border: 1px solid var(--line);
  box-shadow: none; padding: 14px; margin-bottom: 12px;
}
.empty { text-align: center; color: var(--muted); padding: 30px 14px; line-height: 1.8; }
.muted { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.7; }
.hidden { display: none !important; }

/* ---------- 今日页 ---------- */
.hero {
  background: #fff; color: var(--ink); text-align: center; padding: 22px 14px;
  border: 1px solid var(--line);
}
.hero-date { font-size: 14px; color: var(--muted); }
.hero-greet { font-size: 22px; font-weight: 800; margin: 6px 0; color: #1f1f1f; }
.hero-week {
  font-size: 13px; color: var(--primary-dark); background: #edf3ff;
  border-radius: 999px;
  padding: 5px 14px; display: inline-block; margin-top: 4px;
}
.hero-sm { padding: 16px; }
.hero-balance { font-size: 36px; font-weight: 900; margin-top: 2px; color: #1f1f1f; }

.task-card { display: flex; align-items: center; gap: 12px; }
.task-card.expired { opacity: .62; }
.task-card.done { background: #f4fff7; border: 1.5px solid #b8ecd0; }
.task-emoji { font-size: 30px; width: 44px; text-align: center; flex: none; }
.task-mid { flex: 1; min-width: 0; }
.task-name { font-weight: 700; font-size: 16px; word-break: break-all; }
.task-deadline { font-size: 13px; color: var(--muted); margin-top: 3px; }
.task-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: none; }
.task-points { font-weight: 800; color: var(--green); font-size: 15px; }
.task-points.minus { color: var(--red); }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line); cursor: pointer; font-weight: 700; font-size: 15px;
  font-family: inherit; background: #fff; color: var(--ink);
  padding: 9px 16px; border-radius: 8px; transition: .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary-dark); color: #fff; }
.btn-primary:active { transform: scale(.96); }
.btn-ghost { background: #f6f8fa; color: var(--ink); }
.btn-warn { background: #fff; border-color: #ffd76a; color: #9a6b00; }
.btn-danger { background: #ffecec; color: var(--red); }
.btn-sm { font-size: 13px; padding: 6px 12px; }
.icon-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 34px; height: 34px;
  cursor: pointer; font-size: 15px;
}
a.btn { text-decoration: none; display: inline-block; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: #eef1f8; border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--muted); }

.toolbar { display: flex; align-items: center; gap: 10px; margin: 6px 2px 4px; flex-wrap: wrap; }
.toolbar-note { font-size: 12px; color: var(--muted); }
.task-row { display: flex; align-items: center; gap: 12px; }

/* ---------- 表单 ---------- */
.row2 { display: flex; gap: 12px; }
.row2 .fld { flex: 1; }
.fld { display: block; margin-bottom: 14px; font-size: 14px; color: #556; font-weight: 600; }
.fld input, .fld select {
  display: block; width: 100%; margin-top: 6px; padding: 11px 12px;
  border: 1.5px solid #dfe4f0; border-radius: 12px; font-size: 15px;
  font-family: inherit; background: #fafbff;
}
.fld input:focus, .fld select:focus { outline: none; border-color: var(--primary); background: #fff; }
.fld-label { margin-bottom: 8px; }
.wd-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.wd-chip {
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  border-radius: 12px; background: #eef1f8; font-weight: 700; cursor: pointer;
  user-select: none; border: 2px solid transparent;
}
.wd-chip.on { background: var(--primary); color: #fff; border-color: var(--primary-dark); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; margin-bottom: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- 图标选择器 ---------- */
.icon-picker { margin-top: 6px; }
.icon-preview-row { display: flex; align-items: center; gap: 10px; }
.icon-preview {
  flex: 0 0 auto; width: 46px; height: 46px; display: flex; align-items: center; justify-content: center;
  font-size: 26px; line-height: 1; background: #f3f6ff; border: 1.5px solid #dfe4f0; border-radius: 12px;
  user-select: none;
}
.fld .icon-input { flex: 1 1 auto; min-width: 0; margin-top: 0; }
.icon-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.icon-cat {
  font: inherit; font-size: 12px; font-weight: 700; color: var(--muted); background: #eef1f8;
  border: 1.5px solid transparent; border-radius: 999px; padding: 5px 11px; cursor: pointer;
}
.icon-cat.on { background: var(--primary); border-color: var(--primary-dark); color: #fff; }
.icon-panels { margin-top: 8px; }
.icon-grid[hidden] { display: none; }
.icon-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px;
  max-height: 210px; overflow-y: auto; padding: 2px; background: #fafbff; border: 1.5px solid #eef1f8; border-radius: 12px;
}
.icon-cell {
  font: inherit; font-size: 22px; line-height: 1; height: 42px; display: flex; align-items: center; justify-content: center;
  background: #fff; border: 2px solid transparent; border-radius: 10px; cursor: pointer; padding: 0;
}
.icon-cell:hover { background: #eef1f8; }
.icon-cell.on { border-color: var(--primary); background: #eaf0ff; }

/* ---------- 商城 ---------- */
.reward-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.reward-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 0; }
.reward-emoji { font-size: 40px; line-height: 1; }
.reward-name { font-weight: 700; min-height: 2.6em; display: flex; align-items: center; justify-content: center; line-height: 1.3; }
.reward-cost { color: #9a6b00; font-weight: 700; }
.reward-admin { display: flex; gap: 6px; }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 999px; font-weight: 700; vertical-align: 2px; }
.badge-pending { background: #fff3d6; color: #9a6b00; }
.badge-done { background: #d8f5e4; color: #1e8e4e; }

/* ---------- 总结 ---------- */
.summary-title { font-weight: 800; font-size: 17px; }
.achievement-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px;
}
.achievement-item {
  background: #f6f8fa; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 8px; text-align: center;
}
.achievement-item b { display: block; font-size: 22px; color: #1f1f1f; }
.achievement-item span { font-size: 12px; color: var(--muted); }
.summary-comment {
  font-size: 15px; margin: 10px 0; padding: 10px 14px;
  background: #f6f8fa; border: 1px solid var(--line); border-radius: 8px; line-height: 1.6;
}
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.stat { background: #f6f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 12px 6px; text-align: center; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }
.summary-best { font-size: 14px; color: #9a6b00; font-weight: 700; margin-bottom: 8px; }
.sum-details { margin-top: 10px; background: #f6f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.sum-details summary { cursor: pointer; font-weight: 700; font-size: 14px; }
.sum-line { display: flex; justify-content: space-between; font-size: 14px; padding: 5px 2px; border-bottom: 1px dashed #dfe4f0; gap: 12px; }
.sum-line:last-child { border-bottom: 0; }

/* ---------- 设置 ---------- */
.settings-overview h2 { font-size: 20px; margin: 0; }
.settings-overview > .hint { margin: 6px 0 14px; }
.settings-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.settings-nav a {
  display: flex; align-items: center; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #f6f8fa;
  color: var(--ink); font-size: 14px; font-weight: 600; text-decoration: none;
  overflow-wrap: anywhere;
}
.settings-nav a:hover { background: #edf3ff; border-color: #9fb8ff; }
.settings-nav a:focus-visible { outline: 3px solid #9fb8ff; outline-offset: 2px; }
.settings-card { margin-bottom: 18px; scroll-margin-top: 220px; }
.settings-card h3 {
  margin: 0 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line);
  font-size: 17px; line-height: 1.5;
}
.settings-card > .hint:last-child { margin-bottom: 0; }
.settings-card > h3 + .hint { margin: 0 0 14px; }
.settings-save-bar {
  position: sticky; bottom: 12px; z-index: 10; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; margin-bottom: 0;
  box-shadow: 0 4px 20px #1b234014;
}
.settings-save-bar .hint { margin: 0; }
.settings-save-bar .btn { flex: none; }

/* ---------- 弹窗 / 提示 ---------- */
#modal, #pinBox { position: fixed; inset: 0; z-index: 100; }
#pinBox { z-index: 300; }
.modal-mask { position: absolute; inset: 0; background: #1b2340aa; }
.modal-box {
  position: relative; margin: 10vh auto 0; width: min(92vw, 520px);
  max-height: 78vh; overflow: auto; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: var(--modal-pad, 20px); box-shadow: 0 18px 50px #0000001a;
  --modal-pad: 20px;
}
.modal-box h3 { margin-bottom: 14px; }
.pin-box { width: min(92vw, 380px); text-align: center; }
.pin-box input {
  width: 100%; margin: 14px 0 6px; padding: 12px;
  border: 1.5px solid #dfe4f0; border-radius: 12px; font-size: 16px; text-align: center;
}
.pin-box .modal-actions { justify-content: center; }

.toast {
  position: fixed; left: 50%; bottom: 36px; transform: translateX(-50%) translateY(16px);
  background: #333c; color: #fff; padding: 12px 22px; border-radius: 999px;
  font-size: 15px; opacity: 0; pointer-events: none; transition: .25s;
  z-index: 400; max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: #e05252e6; }

.confetti-piece {
  position: fixed; top: -14px; width: 10px; height: 14px; border-radius: 3px;
  z-index: 500; animation: confetti-fall linear forwards; pointer-events: none;
}
@keyframes confetti-fall { to { transform: translateY(108vh) rotate(720deg); opacity: .55; } }

/* ---------- 小屏幕 ---------- */
@media (max-width: 480px) {
  .home-board { grid-template-columns: 1fr; gap: 14px; }
  .home-panel { padding: 8px; }
  .home-panel-head { padding: 6px 4px 8px; }
  .tile-card { padding: 12px 10px; }
}

@media (min-width: 481px) and (max-width: 760px) {
  .home-board { grid-template-columns: 1fr; }
}

/* ---------- 角色分离 / 商城改版 ---------- */
.top-actions { display: flex; align-items: center; gap: 8px; }
.top-actions .wallet { white-space: nowrap; }
.role-btn { padding: 6px 12px; min-height: 0; border-radius: 999px; font-size: 13px; font-weight: 600; }

.progress { height: 8px; background: var(--panel); border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, #ffd93d, #ffb020); border-radius: 999px; transition: width .3s; }
.progress-note { font-size: 12px; color: var(--muted); margin-bottom: 8px; }

.reward-meta { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; min-height: 22px; align-items: center; justify-content: center; }
.reward-meta .badge { font-size: 11px; }
.reward-soldout { opacity: .6; }
.reward-card .btn { width: 100%; }
.reward-card .progress { width: 100%; }
.wish-btn { margin-top: 6px; }
.archived { opacity: .55; }

/* 管理列表紧凑行：操作按钮横排，减少行高与留白 */
.row-compact { padding: 8px 12px; }
.row-compact .task-side { flex-direction: row; align-items: center; gap: 6px; }
.row-compact .task-emoji { font-size: 24px; width: 32px; }
.row-compact .task-name { font-size: 15px; }
.row-compact .task-deadline { margin-top: 2px; }


/* ---------- 周总结按周选择 ---------- */
.week-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.week-chip {
  border: 1.5px solid #dfe4f0; background: #fff; color: var(--muted); font-weight: 700; font-size: 13px;
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-family: inherit; transition: .15s;
}
.week-chip.on { background: var(--primary); border-color: var(--primary-dark); color: #fff; }

/* 多孩子切换器 */
.kid-switch{margin-right:8px;padding:6px 10px;border-radius:10px;border:1px solid #e3e8f0;background:#fff;font-size:14px;color:#333;cursor:pointer}


/* ================= 响应式布局：电脑 + 手机 ================= */

/* 顶栏与主内容共用 980px 居中轴 */
.topbar { display: block; padding: 0; }
.topbar-inner {
  max-width: 980px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 800; font-size: 18px; }
.brand-icon { flex: none; line-height: 1; }
.brand-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.tabs-wrap { background: #fff; border-bottom: 1px solid var(--line); }
.tabs { max-width: 980px; margin: 0 auto; padding: 6px 16px; border-bottom: 0; }

#goalBar { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.goal-body { flex: 1 1 auto; }

/* 长文本不撑破容器 */
.sum-line { flex-wrap: wrap; align-items: baseline; }
.sum-line > span { min-width: 0; word-break: break-word; }
.sum-line b { white-space: nowrap; }
.reward-name { word-break: break-word; }

/* 弹窗：动态视口高度 + 打开时锁滚动 */
body.modal-open { overflow: hidden; }
.modal-box {
  margin: 8vh auto 0;
  max-height: 78vh; max-height: 78dvh;
  overscroll-behavior: contain;
}
/* 表单弹窗底部操作栏常驻可见：图标网格等内部滚动时，也能随时点到「保存」 */
#modal .modal-actions {
  position: sticky; bottom: calc(-1 * var(--modal-pad, 20px)); z-index: 2;
  margin: 18px calc(-1 * var(--modal-pad, 20px)) calc(-1 * var(--modal-pad, 20px));
  padding: 12px var(--modal-pad, 20px) var(--modal-pad, 20px);
  background: #fff; border-top: 1px solid var(--line);
  border-radius: 0 0 12px 12px;
}
.modal-actions { flex-wrap: wrap; }

@media (max-width: 600px) {
  main { padding: 16px 12px 84px; }
  #goalBar { padding: 0 12px; }
  .tip-banner { margin: 8px 0 6px; }
  .tip-main { padding: 9px 10px; }
  .tip-refresh { width: 44px; height: 44px; }
  .settings-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-nav a { font-size: 13px; padding: 10px; }
  .settings-card { scroll-margin-top: 260px; }
  .settings-save-bar { bottom: calc(8px + env(safe-area-inset-bottom)); }

  /* 顶栏两行：品牌/积分 + 切换孩子/角色，文字不再被压成竖排 */
  .topbar-inner {
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand wallet" "switch role";
    gap: 6px 8px; padding: 8px 12px;
  }
  .brand { grid-area: brand; font-size: 17px; }
  .top-actions { display: contents; }
  .wallet { grid-area: wallet; justify-self: end; padding: 4px 11px; font-size: 13px; }
  .wallet b { font-size: 16px; }
  .kid-switch { grid-area: switch; justify-self: start; margin: 0; max-width: 100%; min-height: 44px; padding: 5px 8px; font-size: 15px; }
  .role-btn { grid-area: role; justify-self: end; min-height: 44px; padding: 7px 13px; font-size: 14px; }

  .tabs { padding: 2px 8px; }
  .tabs button { min-height: 44px; font-size: 14px; padding: 7px 2px; }

  /* 卡片行：操作区换到下一行，避免挤压名称或横向溢出 */
  .task-row {
    display: grid; grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "emoji mid" "side side";
    column-gap: 12px; row-gap: 8px; align-items: center;
  }
  .task-row > .task-emoji { grid-area: emoji; }
  .task-row > .task-mid { grid-area: mid; }
  .task-row > .task-side {
    grid-area: side; width: 100%; flex-direction: row; flex-wrap: wrap;
    align-items: center; justify-content: flex-end; gap: 8px;
  }
  .row-compact { row-gap: 6px; }
  .points-overview b { font-size: 21px; }

  .task-card { flex-wrap: wrap; }
  .task-card > .task-side {
    width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center;
    justify-content: space-between; gap: 10px;
  }

  /* 触控目标与表单 */
  .btn, .icon-btn, .tile-card { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; font-size: 17px; }
  .btn-sm { min-height: 44px; }
  .row2 { flex-wrap: wrap; }
  .row2 .fld { flex: 1 1 150px; min-width: 0; }
  .fld input, .fld select { font-size: 16px; }
  .wd-chip { width: 44px; height: 44px; font-size: 15px; }
  .icon-grid { grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); max-height: min(240px, 38dvh); }
  .icon-cell { height: 46px; font-size: 24px; }
  .icon-cat { min-height: 44px; padding: 8px 12px; }
  .week-chip { min-height: 44px; padding: 8px 14px; }
  .check { min-height: 44px; margin-bottom: 10px; }
  .check input { width: 24px; height: 24px; }

  /* 成长目标横幅在手机上收紧，减少常驻高度 */
  .goal-banner { margin: 6px 0 5px; padding: 8px 10px; gap: 8px; }
  .badge { font-size: 12px; padding: 3px 8px; }
  .reward-meta .badge { font-size: 12px; }
  .goal-flag { font-size: 18px; }
  .goal-title { font-size: 14px; }
  .goal-meta { font-size: 12.5px; }

  /* 商城 / 成就 / 总结 */
  .reward-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { padding: 12px; }
  .hero-balance { font-size: 30px; }
  .achievement-grid { grid-template-columns: repeat(3, 1fr); }

  /* 弹窗 */
  .modal-box { width: min(94vw, 520px); margin: 6vh auto 0; max-height: 86dvh; --modal-pad: 16px; }
  .modal-actions .btn { flex: 1 1 auto; min-height: 44px; }
  .toast { bottom: calc(20px + env(safe-area-inset-bottom)); }
}

/* 触屏设备（含平板）：无论宽度都保证 44px 触控目标，鼠标桌面保持紧凑 */
@media (pointer: coarse) {
  .btn, .btn-sm, .role-btn, .week-chip, .icon-cat, .check { min-height: 44px; }
  .kid-switch { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .wd-chip { width: 44px; height: 44px; }
  .check input { width: 24px; height: 24px; }
  .tabs button { min-height: 44px; }
  .fld input, .fld select { font-size: 16px; }
}

@media (max-width: 380px) {
  .brand { font-size: 16px; }
  .wallet-unit { display: none; }
  .achievement-grid { grid-template-columns: repeat(2, 1fr); }
  .reward-grid { gap: 8px; }
  .reward-emoji { font-size: 34px; }
  .card { padding: 11px; }
}

/* ---------- 孩子头像 ---------- */
.kid-avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none;
  border: 1.5px solid #e3e8f0; background: #eef1f8; display: inline-flex;
  align-items: center; justify-content: center; vertical-align: middle;
}
.kid-avatar-emoji { font-size: 18px; line-height: 1; }
.kid-avatar-xs { width: 22px; height: 22px; border-width: 1px; }
.kid-avatar-xs.kid-avatar-emoji { font-size: 12px; }
.kid-avatar-sm { width: 28px; height: 28px; border-width: 1px; }
.kid-avatar-sm.kid-avatar-emoji { font-size: 15px; }
.kid-avatar-md { width: 40px; height: 40px; }
.kid-avatar-md.kid-avatar-emoji { font-size: 20px; }
.kid-avatar-lg { width: 34px; height: 34px; }
.kid-avatar-lg.kid-avatar-emoji { font-size: 17px; }
.kid-avatar-xl { width: 76px; height: 76px; }
.kid-avatar-xl.kid-avatar-emoji { font-size: 38px; }
.kid-avatar-wrap { display: inline-flex; align-items: center; flex: none; }
.kid-avatar-slot { flex: none; display: flex; align-items: center; }
.kid-now { font-weight: 700; font-size: 14px; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-greet { display: flex; align-items: center; justify-content: center; gap: 10px; }
.hero-greet-text { min-width: 0; }

/* ---------- 头像上传 ---------- */
.avatar-edit { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.avatar-preview { flex: none; }
.avatar-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.avatar-edit .hint { flex-basis: 100%; margin-top: 2px; }

/* ---------- 奖励适用范围 ---------- */
.scope-block { border: 1.5px solid #e6eaf3; border-radius: 12px; padding: 12px; margin-bottom: 14px; background: #fafbff; }
.scope-title { font-weight: 800; font-size: 14px; color: #556; margin-bottom: 10px; }
.scope-kids { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 2px 4px; }
.scope-kid { font-weight: 600; font-size: 14px; margin-bottom: 0; }
.scope-kids.disabled { opacity: .45; }
.scope-block .hint { margin-top: 8px; }

/* 手机端顶栏是两行网格（brand wallet / switch role），头像会打乱栅格，
   因此小屏只在正文问候语里显示头像，顶栏隐藏 */
@media (max-width: 600px) {
  .kid-now { max-width: 64px; }
  .top-actions .kid-avatar-wrap { display: none; }
  .avatar-edit { gap: 10px; }
  .scope-kids { margin-left: 0; }
}

/* 周导航与每日记录 */
.week-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.week-controls strong { text-align: center; font-size: 14px; }
.week-jump { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.week-jump label { font-size: 14px; color: var(--muted); }
.week-jump input { min-width: 0; max-width: 100%; min-height: 44px; padding: 8px; border: 1px solid #dfe4f0; border-radius: 10px; font: inherit; font-size: 16px; }
.history-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.history-day { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; min-height: 44px; padding: 12px 4px; border: 1.5px solid #dfe4f0; border-radius: 14px; background: #fff; color: var(--muted); font: inherit; cursor: pointer; }
.history-day b { font-size: 13px; }
.history-day span { font-size: 14px; }
.history-day small { font-size: 12px; }
.history-day.on { color: #fff; background: var(--primary); border-color: var(--primary-dark); }
.history-day:focus-visible { outline: 3px solid var(--primary-dark); outline-offset: 2px; }
@media (max-width: 600px) {
  .week-controls strong { order: -1; flex-basis: 100%; }
  .history-days { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
