:root {
  --green: #2f9e6e;
  --green-dark: #247a55;
  --green-light: #e6f6ee;
  --bg: #f2f7f4;
  --card: #ffffff;
  --text: #23332b;
  --muted: #7a8a80;
  --border: #dce8e1;
  --red: #e05d5d;
  --orange: #f0a63c;
  --shadow: 0 2px 12px rgba(47, 158, 110, .08);
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
}
.loading-page { padding: 80px; text-align: center; color: var(--muted); }

/* ---- 通用 ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 10px; padding: 9px 18px; font-size: 14px;
  cursor: pointer; background: var(--green); color: #fff; transition: .15s;
}
.btn:hover { background: var(--green-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--green); border: 1px solid var(--green); }
.btn.ghost:hover { background: var(--green-light); }
.btn.danger { background: var(--red); }
.btn.small { padding: 5px 12px; font-size: 13px; border-radius: 8px; }
.btn.big { padding: 13px 26px; font-size: 16px; border-radius: 12px; width: 100%; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
input, select, textarea {
  font: inherit; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 10px; outline: none; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); }
label { font-size: 13px; color: var(--muted); display: block; margin: 12px 0 5px; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; background: var(--green-light); color: var(--green-dark); }
.tag.negative { background: #fdeaea; color: var(--red); }
.tag.mood-happy { background: #e6f6ee; color: var(--green-dark); }
.tag.mood-normal { background: #eef2ef; color: #5c6f66; }
.tag.mood-sad { background: #fff2e2; color: #b57213; }

/* ---- 图标位（素材缺失时自动隐藏，不使用任何表情符号）---- */
.ico { width: 1.05em; height: 1.05em; vertical-align: -0.16em; margin-right: 5px; object-fit: contain; }
.ico-logo { width: 92px; height: 92px; }
.ico-logo-sm { width: 26px; height: 26px; vertical-align: -6px; margin-right: 6px; }
.ico-entry { width: 66px; height: 66px; margin: 0; }

/* ---- 提示 ---- */
#toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 22px; border-radius: 10px; color: #fff; font-size: 14px;
  background: rgba(35, 51, 43, .92); box-shadow: var(--shadow); animation: toastIn .2s;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }

/* ---- 入口页 ---- */
.entry-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.entry-logo { display: flex; align-items: center; justify-content: center; }
.entry-title { font-size: 34px; font-weight: 700; margin: 10px 0 4px; color: var(--green-dark); }
.entry-sub { color: var(--muted); margin-bottom: 36px; }
.entry-cards { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; }
.entry-card {
  width: 240px; padding: 32px 24px; text-align: center; cursor: pointer;
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow); transition: .15s;
  border: 2px solid transparent;
}
.entry-card:hover { transform: translateY(-4px); border-color: var(--green); }
.entry-card .icon { display: flex; align-items: center; justify-content: center; height: 70px; }
.entry-card h3 { margin: 12px 0 6px; font-size: 19px; }
.entry-card p { color: var(--muted); font-size: 13px; }

/* ---- 登录页 ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 380px; }
.login-card h2 { margin-bottom: 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.picker-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; max-height: 300px; overflow-y: auto; }
.picker-item {
  padding: 12px 6px; text-align: center; border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; font-size: 14px; transition: .12s;
}
.picker-item:hover { border-color: var(--green); background: var(--green-light); }
.picker-item.active { border-color: var(--green); background: var(--green); color: #fff; }
.back-link { color: var(--muted); font-size: 13px; cursor: pointer; margin-top: 14px; display: inline-block; }
.back-link:hover { color: var(--green); }

/* ---- 顶栏 ---- */
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 12px 24px;
  background: var(--card); box-shadow: var(--shadow); position: sticky; top: 0; z-index: 50;
}
.topbar .logo { font-size: 20px; font-weight: 700; color: var(--green-dark); cursor: pointer; }
.topbar .nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar .nav a {
  padding: 7px 14px; border-radius: 9px; font-size: 14px; color: var(--text);
  text-decoration: none; cursor: pointer;
}
.topbar .nav a:hover { background: var(--green-light); }
.topbar .nav a.active { background: var(--green); color: #fff; }
.topbar .user { font-size: 13px; color: var(--muted); }

/* ---- 学生端宠物家园 ---- */
.pet-home { max-width: 1000px; margin: 26px auto; padding: 0 18px; display: grid; grid-template-columns: 420px 1fr; gap: 22px; }
.pet-stage { text-align: center; }
.pet-figure {
  font-size: 110px; line-height: 1.4; margin: 18px 0 6px;
  animation: bob 2.4s ease-in-out infinite;
}
.pet-figure img { max-width: 100px; max-height: 100px; object-fit: contain; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.pet-name { font-size: 22px; font-weight: 700; }
.pet-species { color: var(--muted); font-size: 13px; margin: 3px 0 10px; }
.stat-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-size: 13px; }
.stat-row .label { width: 76px; color: var(--muted); text-align: right; }
.bar { flex: 1; height: 10px; background: #edf2ef; border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--green); transition: width .4s; }
.bar.orange > i { background: var(--orange); }
.bar.blue > i { background: #5a9cf0; }
.stat-row .val { width: 62px; font-size: 12px; color: var(--muted); }
.pet-actions { display: flex; gap: 10px; margin-top: 16px; }
.pet-actions .btn { flex: 1; }
.points-badge {
  display: inline-flex; flex-direction: column; align-items: center; margin-top: 18px;
  padding: 12px 30px; background: var(--green-light); border-radius: 14px;
}
.points-badge .num { font-size: 30px; font-weight: 800; color: var(--orange); }
.points-badge .txt { font-size: 12px; color: var(--muted); }

.home-panel h3 { margin-bottom: 12px; font-size: 16px; }
.home-panel + .home-panel { margin-top: 20px; }
.log-list { max-height: 260px; overflow-y: auto; }
.log-item { display: flex; justify-content: space-between; padding: 9px 2px; border-bottom: 1px dashed var(--border); font-size: 13px; }
.log-item .pts { font-weight: 700; color: var(--green); }
.log-item .pts.neg { color: var(--red); }
.log-item .time { color: var(--muted); font-size: 12px; }
.pet-lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 10px; }

/* ---- 金币兑换 ---- */
.redeem-note { font-size: 13px; color: var(--muted); margin-bottom: 12px; line-height: 1.6; }
.redeem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.redeem-card {
  text-align: center; padding: 14px 10px; border: 1px solid var(--border);
  border-radius: 14px; background: #fff; display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.redeem-card img { width: 76px; height: 76px; object-fit: contain; }
.redeem-card .rn { font-size: 15px; font-weight: 700; }
.redeem-card .rc { font-size: 13px; color: #d99b1c; font-weight: 600; }
.redeem-card .rd { font-size: 12px; color: var(--muted); }
.redeem-card .btn { margin-top: 4px; }
.redeem-card.locked { background: #fafbfa; }
.redeem-card.locked img { opacity: .55; }
.redeem-card.locked .rn, .redeem-card.locked .rc { color: var(--muted); }
.bar.gold > i { background: #f2b73f; }
.admin-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px 16px; }
.admin-form .field { display: flex; flex-direction: column; }
.admin-form label { margin: 0 0 5px; }
.redeem-thumb { width: 46px; height: 46px; object-fit: contain; }
/* 素材较多时的滚动容器：限高 + 可上下滚动 */
.scroll-area { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; min-height: 0; }
.scroll-area::-webkit-scrollbar { width: 8px; }
.scroll-area::-webkit-scrollbar-thumb { background: #cddcd4; border-radius: 999px; }
.scroll-area::-webkit-scrollbar-track { background: transparent; }
.pet-lib-item { text-align: center; padding: 12px 4px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; transition: .12s; }
.pet-lib-item:hover { border-color: var(--green); }
.pet-lib-item.current { border-color: var(--green); background: var(--green-light); }
.pet-lib-item .e { font-size: 34px; }
.pet-lib-item img { width: 46px; height: 46px; object-fit: contain; }
.pet-lib-item .n { font-size: 12px; margin-top: 4px; }

/* ---- 教师端 ---- */
.teacher-main { max-width: 1180px; margin: 22px auto; padding: 0 18px; }
.class-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.class-card { cursor: pointer; transition: .15s; border: 2px solid transparent; }
.class-card:hover { border-color: var(--green); transform: translateY(-3px); }
.class-card h3 { font-size: 18px; margin-bottom: 6px; }
.class-card p { color: var(--muted); font-size: 13px; }
.class-card .ops { margin-top: 14px; display: flex; gap: 8px; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar h2 { flex: 1; font-size: 20px; }

.stu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.stu-card {
  text-align: center; padding: 14px 8px; cursor: pointer; position: relative;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 2px solid transparent; transition: .13s;
}
.stu-card:hover { border-color: var(--green); }
.stu-card.selected { border-color: var(--orange); background: #fffaf0; }
.stu-card .pfig { font-size: 44px; line-height: 1.3; }
.stu-card .pfig img { width: 58px; height: 58px; object-fit: contain; }
.stu-card .sname { font-weight: 600; margin-top: 4px; }
.stu-card .pinfo { font-size: 12px; color: var(--muted); }
.stu-card .spts { position: absolute; top: 8px; right: 10px; font-size: 13px; font-weight: 700; color: var(--orange); }
.stu-card .lvl { position: absolute; top: 8px; left: 10px; }

table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.table th, table.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
table.table th { color: var(--muted); font-weight: 500; font-size: 13px; }

/* ---- 评价弹窗（还原原应用布局）---- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(30, 45, 38, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 20px; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 18px; width: 860px; max-width: 96vw;
  max-height: 92vh; display: flex; overflow: hidden; box-shadow: 0 12px 48px rgba(0,0,0,.2);
}
.modal-left {
  width: 300px; background: linear-gradient(180deg, #eefaf3, #fff);
  padding: 24px 20px; border-right: 1px solid var(--border); text-align: center; overflow-y: auto;
}
.modal-right { flex: 1; padding: 20px 24px; overflow-y: auto; display: flex; flex-direction: column; }
.modal-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.modal-tabs .tab {
  padding: 7px 18px; border-radius: 999px; cursor: pointer; font-size: 14px;
  background: #f1f5f2; border: none;
}
.modal-tabs .tab.active { background: var(--green); color: #fff; }
.cat-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.cat-tabs .cat {
  padding: 5px 14px; border-radius: 999px; font-size: 13px; cursor: pointer;
  border: 1px solid var(--border); background: #fff;
}
.cat-tabs .cat.active { background: var(--green-light); border-color: var(--green); color: var(--green-dark); font-weight: 600; }
.eval-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.eval-item {
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 4px;
  text-align: center; cursor: pointer; transition: .12s; background: #fff;
}
.eval-item:hover { border-color: var(--green); }
.eval-item.active { border-color: var(--green); background: var(--green-light); box-shadow: 0 0 0 2px var(--green) inset; }
.eval-item .ei-name { font-size: 14px; font-weight: 600; }
.eval-item .ei-pts { font-size: 12px; color: var(--green); margin-top: 3px; }
.eval-item .ei-pts.neg { color: var(--red); }
.modal-footer { margin-top: auto; padding-top: 16px; }
.manual-row { display: flex; gap: 10px; align-items: flex-end; }
.manual-row > div { flex: 1; }
.modal-close { position: absolute; top: 14px; right: 18px; font-size: 20px; color: var(--muted); cursor: pointer; background: none; border: none; }

/* ---- 大屏 ---- */
.display-body { background: linear-gradient(160deg, #e8f7ee, #f7fdf9); min-height: 100vh; padding: 26px; }
.display-head { text-align: center; margin-bottom: 22px; }
.display-head h1 { font-size: 30px; color: var(--green-dark); }
.display-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; max-width: 1400px; margin: 0 auto; }
.display-card { text-align: center; padding: 18px 10px; }
.display-card .pfig { font-size: 56px; line-height: 1.3; }
.display-card .pfig img { width: 74px; height: 74px; object-fit: contain; }
.display-card .sname { font-weight: 700; font-size: 16px; margin-top: 4px; }
.display-card .pinfo { font-size: 12px; color: var(--muted); }
.display-card .pts { font-size: 22px; font-weight: 800; color: var(--orange); }
.rank-badge { display: inline-block; min-width: 26px; padding: 1px 7px; border-radius: 999px; background: #eef2ef; font-size: 12px; color: var(--muted); }
.rank-badge.top { background: var(--orange); color: #fff; }

/* ---- 宠物图片默认尺寸（避免未指定容器时原图过大）---- */
.pfig img { width: 40px; height: 40px; object-fit: contain; }
/* 学生端宠物详情主图：100×100（更高优先级，避免被 .pfig 默认 40px 覆盖） */
.pet-figure .pfig img { width: 100px; height: 100px; object-fit: contain; }

/* ---- 宠物放大预览悬浮窗（换宠物：点击素材后弹出）---- */
.pet-preview-mask { z-index: 200; }
.pet-preview {
  display: block; width: 330px; text-align: center;
  padding: 28px 24px 22px; position: relative;
}
.pet-preview .pv-img {
  width: 210px; height: 210px; object-fit: contain;
  display: block; margin: 4px auto 12px;
}
.pet-preview .pv-name { font-size: 20px; font-weight: 800; }
.pet-preview .pv-meta { font-size: 13px; color: var(--muted); margin: 6px 0 20px; }
.pet-preview .pv-actions { display: flex; gap: 10px; }
.pet-preview .pv-actions .btn { flex: 1; padding: 10px 0; }

/* ---- 学生管理列表 ---- */
.list-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; font-size: 13px; color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.stu-list { display: flex; flex-direction: column; }
.stu-row { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.stu-row:last-child { border-bottom: none; }
.stu-row:hover { background: #fafcfb; }
.stu-pet-thumb {
  width: 46px; height: 46px; flex: 0 0 auto; border-radius: 10px;
  background: var(--green-light); display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.stu-pet-thumb img { width: 40px; height: 40px; object-fit: contain; }
.stu-pet-thumb .none { font-size: 10px; color: var(--muted); }
.stu-info { flex: 1; min-width: 0; }
.stu-line1 { display: flex; align-items: baseline; gap: 9px; }
.stu-line1 b { font-size: 15px; }
.stu-petname { font-size: 12px; color: var(--muted); }
.stu-line2 { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.stu-line2 b { color: var(--text); font-weight: 600; }
.stu-line2 b.gold { color: #d99b1c; }
.stu-ops { display: flex; gap: 6px; flex: 0 0 auto; }
.stu-empty { padding: 26px; text-align: center; color: var(--muted); font-size: 13px; }

@media (max-width: 900px) {
  .pet-home { grid-template-columns: 1fr; }
  .modal { flex-direction: column; }
  .modal-left { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .eval-grid { grid-template-columns: repeat(3, 1fr); }
  .stu-row { flex-wrap: wrap; }
  .stu-ops { width: 100%; justify-content: flex-end; }
}

/* ---- 金币素材图标（1 个 = 单枚，2+ = 一堆）---- */
.nav-select {
  appearance: none; -webkit-appearance: none;
  flex: 0 1 auto; min-width: 130px; max-width: 200px;
  padding: 9px 36px 9px 16px; border: 1.5px solid var(--border); border-radius: 12px;
  background: #fff url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%232F9E6E' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  font-size: 15px; font-weight: 700; color: var(--green-dark); cursor: pointer;
}
.nav-select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(47,158,110,.15); }

.coin-ico { width: 18px; height: 18px; object-fit: contain; vertical-align: -3px; margin-right: 4px; }
.stat-row .coin-ico { width: 20px; height: 20px; vertical-align: -4px; }
.redeem-card .coin-ico { width: 20px; height: 20px; }
.redeem-thumb + .coin-ico, .table .coin-ico { width: 18px; height: 18px; }
.pts .coin-ico { width: 16px; height: 16px; vertical-align: -2px; }

/* ---- 升级特效：金币冒出 + 彩带喷发 ---- */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 999; overflow: hidden; }
.fx-coin {
  position: absolute; left: 50%; top: 46%; width: 46px; height: 46px;
  object-fit: contain; opacity: 0;
  animation: fxCoinPop 1.6s cubic-bezier(.22, .9, .3, 1) forwards;
}
@keyframes fxCoinPop {
  0% { opacity: 0; transform: translate(-50%, 30px) scale(.35) rotate(-25deg); }
  22% { opacity: 1; transform: translate(-50%, -46px) scale(1.18) rotate(6deg); }
  45% { opacity: 1; transform: translate(-50%, -92px) scale(1) rotate(-4deg); }
  100% { opacity: 0; transform: translate(-50%, -190px) scale(.8) rotate(12deg); }
}
.fx-confetti {
  position: absolute; border-radius: 2px; opacity: 0;
  animation-name: fxConfettiBurst; animation-timing-function: ease-out; animation-fill-mode: forwards;
}
@keyframes fxConfettiBurst {
  0% { opacity: 1; transform: translate(0, 0) rotate(0deg); }
  60% { opacity: 1; transform: translate(var(--tx), var(--ty)) rotate(var(--rot)); }
  100% { opacity: 0; transform: translate(calc(var(--tx) * 1.1), calc(var(--ty) + 320px)) rotate(calc(var(--rot) + 220deg)); }
}
.fx-tip {
  position: absolute; left: 50%; top: 32%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  padding: 10px 26px; border-radius: 999px; background: rgba(255, 255, 255, .96);
  font-size: 20px; font-weight: 800; color: #d99b1c;
  border: 2px solid #ffe4a3; box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
  animation: fxTipPop 2.4s ease forwards;
}
.fx-tip .coin-ico { width: 24px; height: 24px; margin: 0; }
@keyframes fxTipPop {
  0% { opacity: 0; transform: translateX(-50%) scale(.6); }
  14% { opacity: 1; transform: translateX(-50%) scale(1.1); }
  24% { opacity: 1; transform: translateX(-50%) scale(1); }
  80% { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-18px) scale(.98); }
}

/* ---- 学生端：金币余额（放大） ---- */
.coin-balance {
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 16px; padding: 12px 34px;
  background: #fff7e6; border: 2px solid #ffe0a0; border-radius: 999px;
}
.coin-ico-xl { width: 42px; height: 42px; margin: 0; }
.coin-balance-num { font-size: 38px; font-weight: 800; color: #d99b1c; line-height: 1.1; }
.coin-balance-unit { font-size: 17px; font-weight: 700; color: #d99b1c; }

/* ---- 学生端：四宫格操作 ---- */
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.action-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 16px 8px; border-radius: 16px; cursor: pointer; text-align: center;
  background: #fff; border: 2px solid #e6efe9; font-family: inherit;
  transition: transform .15s, box-shadow .15s, border-color .15s, background .15s;
}
.action-card:hover:not(:disabled) {
  transform: translateY(-2px); border-color: var(--green); background: #f7fdfa;
  box-shadow: 0 8px 20px rgba(47, 158, 110, .16);
}
.action-card:disabled { opacity: .48; cursor: not-allowed; background: #f6f7f6; }
.action-ico { width: 44px; height: 44px; margin: 0; }
.action-name { font-size: 17px; font-weight: 700; color: #3a4a42; }
.action-cost { font-size: 12px; color: var(--muted); }
.action-hint { font-size: 12px; color: var(--muted); text-align: center; margin-top: 12px; line-height: 1.7; }

.display-card .pinfo .coin-ico { width: 22px; height: 22px; vertical-align: -5px; }
.pet-species .coin-ico { width: 20px; height: 20px; vertical-align: -4px; }

@media (max-width: 380px) {
  .action-ico { width: 38px; height: 38px; }
  .action-name { font-size: 15px; }
  .coin-balance { padding: 10px 22px; }
  .coin-balance-num { font-size: 32px; }
  .coin-ico-xl { width: 34px; height: 34px; }
}

/* ---- 内嵌弹窗（替代浏览器 alert/confirm/prompt） ---- */
.ui-mask { z-index: 300; align-items: flex-start; padding-top: 12vh; }
.ui-dialog {
  width: 400px; max-width: calc(100vw - 32px); padding: 22px 24px; display: block;
  overflow-y: auto; animation: uiDialogIn .18s ease;
}
@keyframes uiDialogIn { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.ui-dialog-title { font-size: 17px; font-weight: 800; margin-bottom: 14px; }
.ui-dialog-msg { font-size: 14px; line-height: 1.8; margin: 0 0 4px; }
.ui-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.ui-dialog-actions .btn { min-width: 84px; }
.ui-field { margin-bottom: 14px; }
.ui-field:last-child { margin-bottom: 4px; }
.ui-field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.ui-field input, .ui-field textarea { width: 100%; }
.ui-field textarea { resize: vertical; min-height: 90px; }
.ui-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- 移动端适配（≤768px：手机 / 平板竖屏） ---- */
@media (max-width: 768px) {
  /* 顶栏：导航为下拉框，不换行不滑动 */
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding: 10px 14px; }
  .topbar .logo { font-size: 17px; }
  .topbar .user { font-size: 12px; }
  .nav-select { min-width: 0; flex: 1 1 auto; padding: 8px 34px 8px 14px; font-size: 14px; }
  /* 内容区收紧 */
  .teacher-main { margin: 14px auto; padding: 0 12px; }
  .toolbar h2 { font-size: 17px; }
  .toolbar { gap: 8px; }
  /* 卡片内宽表格允许横向滚动 */
  .card { overflow-x: auto; }
  table.table { min-width: 620px; }
  /* 弹窗占满宽度 */
  .modal { max-width: calc(100vw - 24px); }
  .ui-mask { padding-top: 8vh; }
  /* 学生列表操作按钮适度缩小 */
  .stu-ops .btn.small { padding: 5px 10px; font-size: 12px; }
  .pet-home { padding: 0 12px; }
  .pet-figure img { max-width: 100px; max-height: 100px; }
}

@media (max-width: 480px) {
  .topbar .nav a { padding: 6px 10px; }
  .topbar .user { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-select { font-size: 13px; }
  .btn.small { padding: 5px 10px; font-size: 12px; }
  .ui-dialog-actions .btn { flex: 1; }
  .entry-card { width: 100%; max-width: 320px; }
}
