:root {
  --bg1: #fff0f5;
  --bg2: #ffe4ee;
  --ink: #5a3d4a;
  --muted: #a07f8e;
  --card: #ffffff;
  --line: #ffd3e2;
  --primary: #ff5c8a;
  --primary-dark: #e0406f;
  --good: #3cc4a0;
  --bad: #ff6b81;
  --gold: #ffc94d;
  --chinese: #ff8fab;
  --english: #8ec5ff;
  --math: #c9a7ff;
  --science: #7fdcbf;
  --review: #ffc27a;
  --boss: #ff5c8a;
  --radius: 24px;
  --shadow: 0 6px 0 rgba(255, 92, 138, 0.12), 0 14px 30px rgba(255, 92, 138, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Noto Sans TC", system-ui, -apple-system, "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background-color: var(--bg1);
  background-image:
    radial-gradient(circle, rgba(255, 143, 171, 0.22) 3px, transparent 3.5px),
    radial-gradient(circle, rgba(255, 143, 171, 0.22) 3px, transparent 3.5px),
    linear-gradient(170deg, #fff7fa 0%, var(--bg1) 50%, var(--bg2) 100%);
  background-size: 34px 34px, 34px 34px, 100% 100%;
  background-position: 0 0, 17px 17px, 0 0;
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.7;
}
button { font: inherit; cursor: pointer; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--line);
}
.brand {
  border: 0; background: none; font-size: 1.25rem; font-weight: 900; color: var(--ink);
  display: flex; align-items: center; gap: 6px; padding: 4px 6px;
}
.stats { display: flex; align-items: center; gap: 10px; }
.stat {
  display: flex; align-items: center; gap: 4px;
  background: #fff; border: 2px solid var(--line); border-radius: 999px;
  padding: 2px 12px; font-size: 0.95rem;
}
.stat.level { gap: 8px; }
.xpbar { width: 80px; height: 10px; border-radius: 99px; background: #eee9f5; overflow: hidden; }
#xpfill { height: 100%; width: 0; background: linear-gradient(90deg, #ffb347, #ff7a59); transition: width 0.6s; }

.stat, .brand { white-space: nowrap; }
@media (max-width: 520px) {
  .topbar { padding: 8px 10px; }
  .brand span { display: none; }
  .stats { gap: 6px; }
  .stat { padding: 2px 8px; font-size: 0.85rem; }
  .xpbar { width: 44px; }
  .hero { padding: 14px; gap: 10px; }
  .owl { font-size: 2.6rem; }
  .hero h1 { font-size: 1.1rem; }
}

main { max-width: 860px; margin: 0 auto; padding: 18px 16px 80px; }

/* ---------- hero ---------- */
.hero {
  display: flex; gap: 16px; align-items: center;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 22px;
}
.owl { font-size: 3.4rem; animation: bob 2.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-4deg); } }
.bubble { position: relative; background: #fff8e8; border: 2px solid #ffe3a8; border-radius: 14px; padding: 10px 14px; }
.bubble b { color: var(--primary-dark); }
.hero h1 { font-size: 1.35rem; margin: 0 0 2px; }

/* ---------- map ---------- */
.week {
  background: rgba(255, 255, 255, 0.7); border-radius: var(--radius); padding: 16px; margin-bottom: 18px;
  border: 2px dashed var(--line);
}
.week.current { border: 2px solid var(--primary); background: rgba(255, 255, 255, 0.92); }
.week-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.week-head h2 { margin: 0; font-size: 1.1rem; }
.week-head small { color: var(--muted); }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
@media (max-width: 640px) { .days { grid-template-columns: repeat(4, 1fr); } }

.node {
  position: relative; border: 0; border-radius: 16px; padding: 10px 4px 8px; min-height: 96px;
  background: #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.08);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: transform 0.15s;
  color: var(--ink);
}
.node:not(:disabled):hover { transform: translateY(-3px) scale(1.03); }
.node:not(:disabled):active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08); }
.node .ico { font-size: 1.7rem; line-height: 1.2; }
.node .nm { font-weight: 700; font-size: 0.92rem; }
.node .dt { font-size: 0.75rem; color: var(--muted); }
.node .stars { font-size: 0.8rem; letter-spacing: 1px; min-height: 1.1em; }
.node.today { outline: 3px solid var(--primary); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(255, 122, 89, 0.18); } }
.node.cleared { background: linear-gradient(180deg, #f2fff8, #fff); }
.node:disabled { cursor: not-allowed; opacity: 0.55; filter: grayscale(0.6); }
.node .lock { position: absolute; top: 4px; right: 6px; font-size: 0.8rem; }
.node[data-kind="boss"] .ico { animation: wobble 1.8s infinite; }
@keyframes wobble { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
.tag-chinese { border-top: 6px solid var(--chinese) !important; }
.tag-english { border-top: 6px solid var(--english) !important; }
.tag-math { border-top: 6px solid var(--math) !important; }
.tag-science { border-top: 6px solid var(--science) !important; }
.tag-review { border-top: 6px solid var(--review) !important; }
.tag-boss { border-top: 6px solid var(--boss) !important; }

.badges { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 20px; }
.badge { background: #fff; border-radius: 999px; padding: 4px 12px; border: 2px solid var(--line); font-size: 0.9rem; }
.badge.off { opacity: 0.35; }

/* 全部關卡開放開關（整張卡片都可以按） */
.unlock-all {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: #fff; border: 3px solid #ffc9da; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 18px; margin-bottom: 18px; cursor: pointer; user-select: none;
}
.unlock-text { display: flex; flex-direction: column; }
.unlock-text small { color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
.unlock-all input {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; margin: 0;
  width: 60px; height: 34px; border-radius: 99px; background: #d9ccd2; cursor: pointer; transition: background 0.2s;
}
.unlock-all input::before {
  content: ""; position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); transition: transform 0.2s;
}
.unlock-all input:checked { background: var(--primary); }
.unlock-all input:checked::before { transform: translateX(26px); }
.unlock-all input:focus-visible { outline: 3px solid var(--primary-dark); outline-offset: 3px; }

/* ---------- quiz ---------- */
.quiz-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.back { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 4px 12px; }
.progress { flex: 1; height: 14px; border-radius: 99px; background: #fff; border: 2px solid var(--line); overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, #6ee7b7, #22b07d); transition: width 0.4s; }
.hearts { font-weight: 700; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.qmeta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; font-size: 0.82rem; }
.chip { border-radius: 999px; padding: 2px 10px; background: #f3f0fa; color: #5a4f7c; font-weight: 500; }
.chip.hot { background: #fff0e8; color: #d8481f; }
.chip.type { background: #e8f4ff; color: #2a6fb5; }
.stem { font-size: 1.08rem; white-space: pre-wrap; }
.passage { background: #fafaf5; border-left: 5px solid #e0d6b8; padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; white-space: pre-wrap; font-size: 1rem; }
.options { display: grid; gap: 10px; margin-top: 14px; }
.opt {
  text-align: left; border: 2px solid var(--line); background: #fff; border-radius: 14px; padding: 10px 14px;
  display: flex; gap: 10px; align-items: flex-start; transition: background 0.15s, border-color 0.15s;
  color: var(--ink);
}
.opt:hover:not(:disabled) { border-color: #c9bff0; background: #faf8ff; }
.opt .letter { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #f0edf8; font-weight: 700; }
.opt.selected { border-color: var(--math); background: #f4efff; }
.opt.selected .letter { background: var(--math); color: #fff; }
.opt.correct { border-color: var(--good); background: #eafaf3; }
.opt.correct .letter { background: var(--good); color: #fff; }
.opt.wrong { border-color: var(--bad); background: #fff0f2; }
.opt.wrong .letter { background: var(--bad); color: #fff; }
.fill { width: 100%; font-size: 1.1rem; padding: 10px 14px; border: 2px solid var(--line); border-radius: 14px; margin-top: 12px; }

.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.btn {
  border: 0; border-radius: 14px; padding: 10px 22px; font-weight: 700; color: #fff;
  background: var(--primary); box-shadow: 0 4px 0 var(--primary-dark); transition: transform 0.1s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--primary-dark); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--ink); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line); }
.btn.green { background: var(--good); box-shadow: 0 4px 0 #168a61; }

.verdict { font-size: 1.15rem; font-weight: 900; margin-bottom: 8px; }
.verdict.ok { color: var(--good); }
.verdict.no { color: var(--bad); }
.explain h4 { margin: 14px 0 4px; font-size: 0.98rem; color: #5a4f7c; }
.explain ol { padding-left: 1.3em; margin: 4px 0; }
.explain li { margin-bottom: 4px; }
.trap { background: #fff6f0; border-radius: 12px; padding: 8px 12px; margin-top: 10px; }
.why-hot { background: #fffbe8; border-radius: 12px; padding: 8px 12px; margin-top: 10px; font-size: 0.92rem; }

/* tutor */
.tutor { border-top: 2px dashed var(--line); margin-top: 16px; padding-top: 14px; }
.tutor-title { font-weight: 900; margin-bottom: 8px; }
.msg { border-radius: 14px; padding: 10px 14px; margin: 8px 0; }
.msg.me { background: #eef6ff; margin-left: 15%; }
.msg.ai { background: #fff8e8; border: 2px solid #ffe3a8; }
.msg.ai p { margin: 6px 0; }
.msg.ai h1, .msg.ai h2, .msg.ai h3, .msg.ai h4 { font-size: 1rem; margin: 10px 0 4px; }
.msg.err { background: #fff0f2; color: var(--bad); }
.tutor-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.tutor-row input { flex: 1; min-width: 200px; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); font: inherit; }
.typing::after { content: "貓頭鷹老師思考中"; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: "貓頭鷹老師思考中"; } 25% { content: "貓頭鷹老師思考中．"; } 50% { content: "貓頭鷹老師思考中．．"; } 75% { content: "貓頭鷹老師思考中．．．"; } }

/* result */
.result { text-align: center; }
.result .big { font-size: 3rem; font-weight: 900; }
.result .stars-big { font-size: 2.6rem; letter-spacing: 6px; }
.summary { text-align: left; margin-top: 14px; }
.summary li { margin: 4px 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; transition: transform 0.3s; z-index: 20;
}
.toast.show { transform: translateX(-50%) translateY(0); }

.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.pop { animation: pop 0.35s; }
@keyframes pop { 50% { transform: scale(1.04); } }

.muted { color: var(--muted); }
.footer-note { text-align: center; color: var(--muted); font-size: 0.85rem; margin-top: 26px; }


/* ================= 甜美粉紅主題（原創風格） ================= */
.topbar { background: rgba(255, 255, 255, 0.9); border-bottom: 3px dotted var(--line); }
.brand { color: var(--primary-dark); }
.stat { border-color: var(--line); color: var(--ink); }
#xpfill { background: linear-gradient(90deg, #ffb3c8, #ff5c8a); }
.xpbar { background: #ffe8f0; }

.hero { position: relative; border: 3px solid #ffe0eb; }
.hero::after {
  content: "♡ ♡ ♡"; position: absolute; right: 18px; top: 10px;
  color: #ffb3c8; letter-spacing: 4px; font-size: 0.9rem;
}
.owl { position: relative; }
.owl::before {
  content: "🎀"; position: absolute; top: -10px; right: -12px; font-size: 1.6rem;
  transform: rotate(18deg);
}
.bubble { background: #fff5f8; border-color: #ffc9da; }
.bubble b { color: var(--primary-dark); }

.week { background: rgba(255, 255, 255, 0.75); border: 3px dashed var(--line); }
.week.current { border: 3px solid #ff8fab; background: rgba(255, 255, 255, 0.95); }
.week-head h2::before { content: "🎀 "; }
.node { border-radius: 22px; box-shadow: 0 5px 0 rgba(255, 92, 138, 0.15); }
.node.cleared { background: linear-gradient(180deg, #fff0f6, #fff); }
.node.today { outline-color: var(--primary); }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px rgba(255, 92, 138, 0.2); } }
.node.cleared::after { content: "♥"; position: absolute; top: 4px; left: 8px; color: var(--primary); font-size: 0.85rem; }

.badge { border-color: var(--line); background: #fff; }
.badge:not(.off) { background: #fff0f6; border-color: #ff8fab; }

.card { border: 3px solid #ffe6ef; }
.chip { background: #fff0f6; color: #b8577a; }
.chip.type { background: #f1ecff; color: #7b5cc9; }
.chip.hot { background: #ffe8ee; color: #e0406f; }
.opt { border-radius: 18px; }
.opt:hover:not(:disabled) { border-color: #ffb3c8; background: #fff7fa; }
.opt .letter { background: #ffeef4; color: #c04a75; }
.opt.selected { border-color: var(--primary); background: #fff0f6; }
.opt.selected .letter { background: var(--primary); color: #fff; }
.progress > div { background: linear-gradient(90deg, #ffb3c8, #ff5c8a); }
.passage { background: #fffafc; border-left-color: #ffc9da; }

.btn { border-radius: 999px; }
.btn.green { background: #ff8fab; box-shadow: 0 4px 0 #e66f90; }
.btn.ghost { border-radius: 999px; }
.trap { background: #fff3f6; }
.why-hot { background: #fffaf0; }
.msg.ai { background: #fff7fa; border-color: #ffc9da; }
.msg.me { background: #f3efff; }
.explain h4 { color: #c04a75; }
.verdict.ok { color: #e0406f; }
.toast { background: #e0406f; }
.result .stars-big { color: var(--gold); }
details { background: #fff0f6; border-radius: 12px; padding: 6px 12px; margin-top: 6px; }
summary { cursor: pointer; font-weight: 700; color: #c04a75; }

/* ================= 貓咪插畫素材（images/ 內的裁切圖） ================= */
.mascot {
  width: 110px; height: auto; flex: none;
  filter: drop-shadow(0 6px 10px rgba(255, 92, 138, 0.18));
  animation: bob 2.6s ease-in-out infinite;
}
@media (max-width: 520px) { .mascot { width: 80px; } }

.result { position: relative; }
.result-mascot {
  display: block; width: 130px; height: auto; margin: -8px auto 2px;
  filter: drop-shadow(0 6px 10px rgba(255, 92, 138, 0.18));
  animation: bob 2.6s ease-in-out infinite;
}
@media (max-width: 520px) { .result-mascot { width: 100px; } }
.result::before, .result::after {
  content: ""; position: absolute; width: 46px; height: 46px; pointer-events: none;
  background: center / contain no-repeat;
}
.result::before { top: 14px; left: 14px; background-image: url(images/deco-star.png); transform: rotate(-12deg); }
.result::after { top: 18px; right: 14px; width: 60px; height: 58px; background-image: url(images/deco-sparkle.png); }
.result .big {
  display: inline-block; min-width: 230px; padding: 10px 52px 14px;
  background: url(images/deco-ribbon.png) center / 100% 100% no-repeat;
}

.node.cleared::after {
  content: ""; width: 16px; height: 16px; font-size: 0;
  background: url(images/deco-heart.png) center / contain no-repeat;
}

.result { position: relative; overflow: hidden; }

/* 非選題、圖表 */
textarea.write { font: inherit; resize: vertical; min-height: 120px; }
.write-review { margin-top: 14px; background: #fffafc; border: 2px dashed #ffc9da; border-radius: 16px; padding: 12px 16px; }
.write-review h4 { margin: 8px 0 4px; color: #c04a75; }
.figure { margin: 10px 0; overflow-x: auto; }
.figure table, .msg.ai table, .model table { border-collapse: collapse; margin: 6px 0; font-size: 0.95rem; }
.figure th, .figure td, .msg.ai th, .msg.ai td, .model th, .model td { border: 1px solid #ffc9da; padding: 4px 10px; text-align: center; }
.figure th, .msg.ai th, .model th { background: #fff0f6; }
.exam-links { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); border: 3px solid #ffe6ef; padding: 14px 18px; margin-bottom: 18px; }
.exam-links h2 { margin: 0 0 6px; font-size: 1.05rem; }
.exam-links a { color: var(--primary-dark); font-weight: 700; }
.exam-links ul { margin: 6px 0 0; padding-left: 1.2em; }
