:root {
  --bg: #fff8ec;
  --card: #ffffff;
  --ink: #2b2a33;
  --muted: #6d6a78;
  --line: #eadfcc;
  --accent: #ff8a3d;
  --accent-ink: #ffffff;
  --good: #2e9e6a;
  --warn: #d9822b;
  --xp: #7c5cff;
  --food: #ff8a3d;
  --mood: #e8559a;
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1b24; --card: #282532; --ink: #f2eff8; --muted: #a9a4b8; --line: #3a3647;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 system-ui, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 960px; margin: 0 auto; padding: 16px; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h2 { font-size: 20px; margin-top: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); font-size: 14px; }
button, input, select {
  font: inherit; border-radius: 12px; border: 1px solid var(--line); padding: 10px 14px;
  background: var(--card); color: var(--ink); min-height: 44px;
}
button { cursor: pointer; font-weight: 600; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button:disabled { opacity: .5; cursor: default; }
input { flex: 1; min-width: 0; }

/* ---- học sinh ---- */
.login { max-width: 380px; margin: 12vh auto; text-align: center; }
.login input { width: 100%; text-align: center; font-size: 26px; letter-spacing: 3px; text-transform: uppercase; margin: 12px 0; }
.login input.name { font-size: 20px; letter-spacing: 0; text-transform: none; }
.pet-stage { text-align: center; padding: 24px 16px; }
.pet-art { font-size: 110px; line-height: 1.1; display: inline-block; animation: bob 2.4s ease-in-out infinite; user-select: none; }
.pet-art.sleepy { animation-duration: 5s; filter: grayscale(.5); }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-3deg); } }
.stars { color: #f5b400; font-size: 22px; letter-spacing: 2px; line-height: 1.2; }
.bar { display: grid; grid-template-columns: 90px 1fr; gap: 8px; align-items: center; margin: 6px 0; font-size: 15px; }
.track { height: 12px; background: var(--line); border-radius: 99px; overflow: hidden; }
.fill { height: 100%; background: var(--xp); border-radius: 99px; transition: width .6s; }
.bar.food .fill { background: var(--food); }
.bar.mood .fill { background: var(--mood); }
.hw { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); }
.hw:first-of-type { border-top: 0; }
.ach { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.ach div { text-align: center; font-size: 13px; padding: 8px 4px; border-radius: 12px; background: var(--bg); }
.ach div.locked { opacity: .35; filter: grayscale(1); }
.ach b { display: block; font-size: 28px; }
.celebrate { position: fixed; inset: 0; display: grid; place-items: center; background: #0008; z-index: 10; text-align: center; color: #fff; }
.celebrate .pet-art { font-size: 140px; }

/* ---- giáo viên ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stu { text-align: center; position: relative; padding: 12px 8px; }
.stu .pet-art { font-size: 44px; animation: none; }
.stu input[type=checkbox] { position: absolute; top: 8px; left: 8px; width: 22px; height: 22px; min-height: 0; flex: none; }
.stu .name { font-weight: 700; }
.pending { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); }
.pending:first-of-type { border-top: 0; }
.pending .who { flex: 1 1 200px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 99px; z-index: 20; max-width: calc(100% - 32px); }

/* In thẻ mã đăng nhập cho học sinh */
.cards { display: none; }
@media print {
  body > *:not(.cards) { display: none !important; }
  .cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .cards div { border: 1px dashed #999; padding: 14px; text-align: center; break-inside: avoid; }
  .cards b { display: block; font-size: 24px; letter-spacing: 2px; margin-top: 6px; }
}

/* ---- thanh EXP dưới hình pet ---- */
.pet-stage { position: relative; }
.exp { max-width: 320px; margin: 4px auto 10px; }
.exp-track { height: 16px; background: var(--line); border-radius: 99px; overflow: hidden; box-shadow: inset 0 1px 2px #0001; }
.exp .fill { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #ffd84a, #ffb020); transition: width .9s cubic-bezier(.3,.8,.4,1); }
.exp-label { font-size: 14px; font-weight: 700; color: var(--muted); margin-top: 3px; }
.exp.levelup .exp-track { animation: levelup .8s ease-out; }
@keyframes levelup { 30% { box-shadow: 0 0 0 4px #ffd84a, 0 0 18px #ffd84a; } }
.gain { position: absolute; left: 50%; top: 38%; transform: translateX(-50%); font-weight: 800; font-size: 22px; color: #f0a000;
  text-shadow: 0 1px 0 #fff; animation: gain 1.8s ease-out forwards; pointer-events: none; }
@keyframes gain { from { opacity: 0; transform: translate(-50%, 10px); } 20% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -50px); } }
.grad { font-weight: 700; color: #b8860b; }
.card.highlight { border: 2px solid var(--accent); }
.collection { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.collection > div { text-align: center; padding: 8px; border-radius: 12px; background: var(--bg); font-size: 14px; }
.collection b { display: block; font-size: 40px; }
details.parent summary { cursor: pointer; font-weight: 700; }
details.parent .question { font-size: 24px; }
details.parent input { max-width: 160px; font-size: 20px; }

/* ---- trang cô: hoạt động gần đây, nhập danh sách ---- */
.activity { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.activity:first-of-type { border-top: 0; }
.activity .what { flex: 1; min-width: 0; }
.activity.undone .what { text-decoration: line-through; opacity: .55; }
textarea { font: inherit; width: 100%; min-height: 120px; border-radius: 12px; border: 1px solid var(--line); padding: 10px; background: var(--card); color: var(--ink); }
.mini-exp { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 4px 8px; }
.mini-exp div { height: 100%; background: #ffc020; }
.celebrate .stars { margin-top: 10px; }

/* ---- pet SVG trong app ---- */
.main-pet { width: min(240px, 70vw); }
.celebrate-pet .pet-box { width: min(260px, 70vw); }
.stu-pet .pet-box { width: 92px; }
.collection .pet-box { width: 90px; }
.still .pet *, .pet-box.still * { animation: none !important; }
/* Thanh EXP màu xanh dương */
.exp .fill { background: linear-gradient(90deg, #7cc4ff, #3d8bff); }
.exp.levelup .exp-track { animation: levelupBlue .8s ease-out; }
@keyframes levelupBlue { 30% { box-shadow: 0 0 0 4px #7cc4ff, 0 0 18px #3d8bff; } }
.gain { color: #2f7ae5; }
.mini-exp div { background: #3d8bff; }
button.flower { font-size: 15px; }
button.mini { min-height: 0; padding: 2px 6px; font-size: 13px; }
.code { font-size: 26px; letter-spacing: 2px; }
/* Trạng thái đồng bộ */
.sync { font-size: 13px; padding: 6px 12px; border-radius: 99px; margin-bottom: 10px; display: inline-block; }
.sync.ok { background: #e5f6ec; color: #2e7d55; }
.sync.wait { background: #fff4d6; color: #8a6a00; }
.sync.off { background: #fde8e8; color: #a33; }
/* Cửa sổ hướng dẫn */
.modal { position: fixed; inset: 0; background: #0006; display: grid; place-items: center; z-index: 30; padding: 16px; }
.modal-card { background: var(--card); color: var(--ink); border-radius: var(--radius); padding: 18px; max-width: 620px; width: 100%; max-height: 90vh; overflow: auto; }
.calc { background: var(--bg); border-radius: 12px; padding: 12px; margin: 10px 0; }
.calc label, .settings label { display: inline-flex; gap: 6px; align-items: center; font-size: 15px; }
.calc input, .settings input[type=number] { max-width: 110px; flex: 0 1 110px; }
.levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.settings h3 { margin: 14px 0 6px; font-size: 16px; }
.activity-row { margin-bottom: 6px; }

/* ---- nộp bài kèm ảnh / ghi âm ---- */
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumb { position: relative; }
.thumb img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.thumb button { position: absolute; top: 2px; right: 2px; background: #fffd; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #e84545; animation: recBlink 1s infinite; display: inline-block; }
@keyframes recBlink { 50% { opacity: .3; } }
.modal audio { width: 100%; margin: 8px 0; }
.work { display: grid; gap: 10px; }
.work img { width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.work-btn { font-size: 14px; }
.warn { color: #b8600b; font-weight: 600; }
.wait { font-size: 14px; text-align: right; max-width: 60%; }
.button-like { display: inline-flex; align-items: center; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; font-weight: 600; cursor: pointer; }
select { font: inherit; border-radius: 12px; border: 1px solid var(--line); padding: 8px 10px; background: var(--card); color: var(--ink); min-height: 44px; }
.card.reward { font-weight: 700; font-size: 18px; text-align: center; }
.class-reward { background: linear-gradient(90deg, #ff9f7a, #ff7eb0); }
