/* =========================================================
   我獨自學習 視覺系統
   暖紙色底＋葡萄紫主色＋各科代表色；大字標題、圓角卡片、
   有按壓感的按鈕、答對答錯的小動畫。
   ========================================================= */
:root {
  --bg: #fbf7f0;
  --bg-2: #f3ede2;
  --card: #ffffff;
  --ink: #1d1b33;
  --muted: #6e6a85;
  --line: #ebe4d6;

  --brand: #5b4cf0;
  --brand-2: #8a7cff;
  --brand-deep: #3d30c4;
  --brand-ink: #ffffff;
  --brand-soft: #eeebff;

  --sun: #ffbf2e;
  --coral: #ff6b5b;
  --mint: #16b07a;
  --sky: #2f97ff;
  --teal: #0fa3a3;
  --orange: #ff8a3d;
  --pink: #f05bb0;

  --ok: #12a06e;
  --ok-soft: #e3f7ee;
  --bad: #e5484d;
  --bad-soft: #fdeceb;
  --warn: #d97a06;
  --warn-soft: #fff3dc;
  --tip: #1f86e0;
  --tip-soft: #e6f2ff;
  --story-soft: #f2efff;

  --shadow-sm: 0 1px 2px rgba(40, 30, 90, .06);
  --shadow: 0 1px 2px rgba(40, 30, 90, .05), 0 10px 30px -14px rgba(40, 30, 90, .22);
  --shadow-lg: 0 2px 4px rgba(40, 30, 90, .06), 0 24px 48px -20px rgba(40, 30, 90, .35);
  --radius: 22px;
  --radius-sm: 14px;

  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-display: "Nunito", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1022;
    --bg-2: #171a33;
    --card: #181b34;
    --ink: #ecebfa;
    --muted: #a3a1c2;
    --line: #2b2f50;
    --brand: #8b7dff;
    --brand-2: #b0a6ff;
    --brand-deep: #5546e0;
    --brand-ink: #0e1022;
    --brand-soft: #25234e;
    --ok: #3fd69c;
    --ok-soft: #12322a;
    --bad: #ff7b7f;
    --bad-soft: #3a1c22;
    --warn: #ffc14d;
    --warn-soft: #3a2e14;
    --tip: #6cb8ff;
    --tip-soft: #14294a;
    --story-soft: #221f46;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px -14px rgba(0, 0, 0, .6);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .3), 0 24px 48px -20px rgba(0, 0, 0, .7);
  }
}

/* 各科代表色（卡片用 --c 取色） */
.c-chinese, .c-history { --c: var(--coral); }
.c-english { --c: var(--sky); }
.c-math { --c: var(--brand); }
.c-science, .c-biology, .c-life { --c: var(--mint); }
.c-physics, .c-chemistry { --c: var(--teal); }
.c-social, .c-geography, .c-earth { --c: var(--orange); }
.c-civics { --c: var(--pink); }
.c-tech { --c: var(--teal); }

/* ===== 基礎 ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 500px at -10% -10%, color-mix(in srgb, var(--brand) 9%, transparent), transparent 60%),
    radial-gradient(700px 420px at 110% 0%, color-mix(in srgb, var(--sun) 12%, transparent), transparent 60%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
button, input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; }
::selection { background: color-mix(in srgb, var(--brand) 25%, transparent); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; border-radius: 8px; }

h1, h2, h3 { font-family: var(--font-display); color: var(--ink); letter-spacing: -.01em; }
h1 { font-size: clamp(1.65rem, 1.2rem + 1.8vw, 2.35rem); font-weight: 900; line-height: 1.3; margin: .35em 0 .3em; }
h2 { font-size: 1.28em; font-weight: 800; line-height: 1.4; margin: .7em 0 .35em; }
h3 { font-size: 1.08em; font-weight: 800; margin: .4em 0 .15em; }
.muted { color: var(--muted); }
.small { font-size: .88em; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

/* ===== 頂部列 ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 12px max(20px, calc((100vw - 1040px) / 2));
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.topbar .logo {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 900; font-size: 1.12em;
  text-decoration: none; color: var(--ink); white-space: nowrap;
}
.logo-mark {
  display: grid; place-items: center;
  width: 36px; height: 36px; padding: 3px; border-radius: 11px;
  background: linear-gradient(145deg, var(--brand-2), var(--brand) 52%, var(--brand-deep));
  color: #fff;
  box-shadow: 0 3px 0 var(--brand-deep), 0 8px 18px -8px var(--brand);
  transition: transform .25s, box-shadow .25s;
}
.logo-svg { width: 100%; height: 100%; display: block; }
.logo-svg .lg-aura { fill: rgba(255, 255, 255, .28); }
.logo-svg .lg-page-l { fill: rgba(255, 255, 255, .94); }
.logo-svg .lg-page-r { fill: rgba(220, 232, 255, .82); }
.logo-svg .lg-chevron { fill: none; stroke: #6ef3ff; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.logo-svg .lg-blade-l { fill: #ffffff; }
.logo-svg .lg-blade-r { fill: rgba(210, 224, 255, .85); }
.logo-svg .lg-star { fill: #6ef3ff; }
.logo:hover .logo-mark { transform: translateY(-1px) scale(1.06); }
.topbar nav { display: flex; gap: 4px; margin-left: auto; }
.topbar nav a {
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; color: var(--muted); font-weight: 700;
  padding: 7px 14px; border-radius: 999px; white-space: nowrap;
  transition: background .15s, color .15s;
}
.topbar nav a:hover { color: var(--ink); background: var(--bg-2); }
.topbar nav a.active { background: var(--ink); color: var(--bg); }
.topbar nav .ni { font-size: 1.05em; }
.who {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--ink); white-space: nowrap;
  padding: 4px 12px 4px 4px; border-radius: 999px;
  background: var(--card); box-shadow: var(--shadow-sm); border: 1px solid var(--line);
}
.who .avatar {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--sun), var(--orange)); color: #fff; font-size: 14px;
}
main { max-width: 1040px; margin: 0 auto; padding: 20px 20px 110px; }

/* 手機：導覽列變成底部浮動膠囊 */
@media (max-width: 720px) {
  body { font-size: 16px; }
  /* backdrop-filter 會讓裡面 position:fixed 的導覽列改以頂部列定位，手機上要拿掉 */
  .topbar { padding: 10px 16px; gap: 10px; backdrop-filter: none; -webkit-backdrop-filter: none; background: color-mix(in srgb, var(--bg) 94%, transparent); }
  .topbar .who { margin-left: auto; }
  .topbar nav {
    position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom));
    margin: 0; justify-content: space-around; gap: 2px;
    background: color-mix(in srgb, var(--card) 88%, transparent);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--line); border-radius: 22px;
    padding: 6px; box-shadow: var(--shadow-lg);
  }
  .topbar nav a { flex: 1; flex-direction: column; gap: 0; font-size: 12px; padding: 6px 4px; border-radius: 16px; line-height: 1.3; }
  .topbar nav .ni { font-size: 20px; }
  main { padding: 14px 16px 120px; }
}

/* ===== 卡片 ===== */
.card {
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin: 14px 0;
  box-shadow: var(--shadow);
}
a.card { color: inherit; text-decoration: none; transition: transform .2s cubic-bezier(.2,.8,.3,1.2), box-shadow .2s; }
a.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
a.card:active { transform: translateY(-1px); }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card.note { border-left: 6px solid var(--c, var(--brand)); }
.card.note.ok { --c: var(--ok); }
.card.note.bad { --c: var(--bad); }
.card.note.warn { --c: var(--warn); }

/* ===== 按鈕：有按壓感 ===== */
.btn {
  --b: var(--card); --bi: var(--ink); --bd: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 9px 20px;
  border-radius: var(--radius-sm); border: 2px solid var(--bd);
  background: var(--b); color: var(--bi);
  box-shadow: 0 3px 0 var(--bd);
  cursor: pointer; text-decoration: none; font-weight: 800; line-height: 1.3;
  transition: transform .08s, box-shadow .08s, background .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { --bd: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--bd); }
.btn.primary { --b: var(--brand); --bi: var(--brand-ink); --bd: var(--brand-deep); }
.btn.primary:hover { --b: color-mix(in srgb, var(--brand) 88%, #fff); }
.btn.ok { --b: var(--ok); --bi: #fff; --bd: color-mix(in srgb, var(--ok) 70%, #000); }
.btn.ghost { --b: transparent; --bd: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--bg-2); }
.btn.sm { min-height: 36px; padding: 5px 13px; font-size: .9em; border-radius: 11px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ===== 標籤 ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 800; line-height: 1;
  padding: 5px 10px; border-radius: 999px; white-space: nowrap;
  background: var(--bg-2); color: var(--muted);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.learning { background: var(--brand-soft); color: var(--brand); }
.badge.weak { background: var(--bad-soft); color: var(--bad); }
.badge.mastered { background: var(--ok-soft); color: var(--ok); }
.badge.due { background: var(--warn-soft); color: var(--warn); }
.badge.ai { background: var(--story-soft); color: var(--brand); }

/* ===== 進度條 ===== */
.bar { height: 10px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.bar > i {
  display: block; height: 100%; min-width: 0; border-radius: 99px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c, var(--mint)) 70%, #fff), var(--c, var(--mint)));
  transition: width .6s cubic-bezier(.2,.8,.2,1);
}

/* ===== 表單 ===== */
input[type=text], input[type=password], input[type=number], input[type=email], input[type=url], input[type=date], textarea, select {
  width: 100%; padding: 11px 14px; min-height: 48px;
  border: 2px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg); transition: border-color .15s, box-shadow .15s, background .15s;
}
input:hover, textarea:hover, select:hover { border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand); background: var(--card);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent);
}
textarea { min-height: 96px; resize: vertical; }
label { font-weight: 700; display: block; margin: 14px 0 6px; font-size: .95em; }

/* ===== 登入頁 ===== */
.auth { display: grid; grid-template-columns: 1.05fr 1fr; gap: 28px; align-items: start; margin-top: 12px; }
.auth-hero {
  position: relative; overflow: hidden;
  border-radius: 28px; padding: 40px 36px; min-height: 480px;
  color: #fff;
  background:
    radial-gradient(420px 300px at 85% 10%, rgba(255, 191, 46, .55), transparent 60%),
    radial-gradient(380px 300px at 0% 100%, rgba(255, 107, 91, .45), transparent 60%),
    linear-gradient(150deg, #7a6bff, #5b4cf0 45%, #3d30c4);
  box-shadow: var(--shadow-lg);
}
.auth-hero h1 { color: #fff; font-size: clamp(2rem, 1.4rem + 2.4vw, 3rem); line-height: 1.2; margin: .2em 0 .4em; }
.auth-hero .eyebrow { display: inline-block; font-weight: 800; font-size: 13px; letter-spacing: .12em; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.18); }
.auth-hero p { color: rgba(255,255,255,.88); max-width: 30em; }
.auth-hero ul { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 12px; }
.auth-hero li { display: flex; gap: 12px; align-items: center; font-weight: 700; }
.auth-hero li .ic { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.18); font-size: 20px; }
.auth-hero .float { position: absolute; font-size: 44px; filter: drop-shadow(0 8px 12px rgba(0,0,0,.2)); animation: bob 5s ease-in-out infinite; pointer-events: none; }
.auth-hero .f1 { right: 34px; bottom: 34px; }
.auth-hero .f2 { right: 120px; bottom: 96px; font-size: 30px; animation-delay: -1.6s; }
.auth-hero .f3 { right: 40px; top: 120px; font-size: 32px; animation-delay: -3s; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-12px) rotate(4deg); } }
.auth-side .card { margin-top: 12px; }
.auth-side #loginBox .row .btn.primary { flex: 1; }
.or-line {
  display: flex; align-items: center; gap: 10px; margin: 16px 0 12px;
  color: var(--muted); font-size: .86em; font-weight: 700;
}
.or-line::before, .or-line::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.g-btn-wrap { display: flex; justify-content: center; min-height: 44px; }
.seg {
  display: flex; gap: 4px; padding: 5px; border-radius: 18px;
  background: var(--bg-2); border: 1px solid var(--line); overflow-x: auto;
}
.seg a {
  flex: 1; text-align: center; white-space: nowrap;
  padding: 9px 12px; border-radius: 13px; font-weight: 800; font-size: .92em;
  color: var(--muted); text-decoration: none; transition: background .15s, color .15s;
}
.seg a:hover { color: var(--ink); }
.seg a.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm), 0 2px 8px -4px rgba(40,30,90,.25); }
@media (max-width: 820px) {
  .auth { grid-template-columns: 1fr; gap: 14px; }
  .auth-hero { min-height: 0; padding: 26px 22px; border-radius: 24px; }
  .auth-hero ul { display: none; }
  .auth-hero .f2, .auth-hero .f3 { display: none; }
  .auth-hero .f1 { right: 18px; bottom: 14px; font-size: 36px; }
}

/* ===== 首頁 ===== */
.hello {
  position: relative; overflow: hidden;
  border-radius: 28px; padding: 28px 30px; margin: 6px 0 18px;
  background:
    radial-gradient(360px 220px at 100% 0%, color-mix(in srgb, var(--sun) 35%, transparent), transparent 70%),
    linear-gradient(135deg, var(--brand-soft), color-mix(in srgb, var(--brand-soft) 40%, var(--card)));
  border: 1px solid color-mix(in srgb, var(--brand) 14%, var(--line));
}
.hello h1 { margin: 0 0 6px; max-width: 80%; }
.hello p { margin: 0; }
.hello .mascot { position: absolute; right: 26px; top: 50%; transform: translateY(-50%); font-size: 64px; animation: bob 5s ease-in-out infinite; }
@media (max-width: 560px) { .hello { padding: 22px 20px; } .hello .mascot { font-size: 44px; right: 14px; top: 26px; transform: none; } }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.stat { display: flex; gap: 16px; align-items: center; margin: 0; }
.stat .num {
  display: grid; place-items: center; flex: none;
  width: 64px; height: 64px; border-radius: 20px;
  font-family: var(--font-display); font-size: 30px; font-weight: 900;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--card));
}
.stat.due { --c: var(--warn); }
.stat.weak { --c: var(--bad); }
.stat b { display: block; font-size: 1.02em; }
@media (max-width: 560px) {
  .stats { gap: 10px; }
  .stat { flex-direction: column; align-items: flex-start; gap: 8px; padding: 16px; }
  .stat .num { width: 52px; height: 52px; font-size: 24px; border-radius: 16px; }
}

.section-title { display: flex; align-items: baseline; gap: 10px; margin: 30px 0 4px; }
.section-title h2 { margin: 0; }

.subject-card { display: flex; flex-direction: column; gap: 4px; margin: 0; position: relative; overflow: hidden; }
.subject-card::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%;
  background: color-mix(in srgb, var(--c, var(--brand)) 10%, transparent); transition: transform .3s;
}
.subject-card:hover::after { transform: scale(1.3); }
.subject-card .icon {
  display: grid; place-items: center; width: 54px; height: 54px; border-radius: 17px; font-size: 28px;
  background: color-mix(in srgb, var(--c, var(--brand)) 15%, var(--card));
  margin-bottom: 6px; position: relative; z-index: 1;
}
.subject-card h3 { margin: 0; font-size: 1.15em; }
.subject-card .bar { margin-top: 12px; }
.subject-card.todo { opacity: .6; }
.subject-card.todo:hover { opacity: .85; }

/* ===== 課本 / 章節 ===== */
.crumb { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .92em; text-decoration: none; color: var(--muted); padding: 4px 12px 4px 8px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.crumb:hover { color: var(--ink); border-color: var(--brand); }
.chap { display: flex; gap: 18px; align-items: flex-start; }
.chap .no {
  display: grid; place-items: center; flex: none; width: 52px; height: 52px; border-radius: 16px;
  font-family: var(--font-display); font-weight: 900; font-size: 22px;
  color: var(--c, var(--brand)); background: color-mix(in srgb, var(--c, var(--brand)) 13%, var(--card));
}
.chap .body { flex: 1; min-width: 0; }
.chap h2 { margin: 2px 0 4px; }
.chap.todo { opacity: .65; }

.kp-list { display: grid; gap: 8px; margin: 10px 0 4px; }
.kp-row {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 12px 14px; border-radius: 16px; background: var(--bg); border: 1px solid var(--line);
}
.kp-row .letter {
  display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 11px;
  font-family: var(--font-display); font-weight: 900; background: var(--card); border: 1px solid var(--line);
}
.kp-row .t { flex: 1; min-width: 160px; font-weight: 700; line-height: 1.5; }
.kp-row .t .badge { margin-top: 4px; }
.kp-row .acts { display: flex; gap: 6px; }

.chapter-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.ring {
  --p: 0; flex: none;
  width: 76px; height: 76px; border-radius: 50%;
  background: conic-gradient(var(--c, var(--mint)) calc(var(--p) * 1%), var(--bg-2) 0);
  display: grid; place-items: center;
}
.ring span {
  display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; background: var(--card);
  font-family: var(--font-display); font-weight: 900; font-size: 18px;
}

/* ===== 教學區塊 ===== */
.kp { scroll-margin-top: 80px; }
.kp-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.block { margin: 16px 0; }
.block.story {
  background: linear-gradient(135deg, var(--story-soft), color-mix(in srgb, var(--story-soft) 40%, var(--card)));
  border-radius: 18px; padding: 16px 20px; border: 1px solid color-mix(in srgb, var(--brand) 12%, transparent);
}
.block.tip, .block.warn {
  border-radius: 16px; padding: 12px 16px 12px 18px; position: relative;
}
.block.tip { background: var(--tip-soft); box-shadow: inset 5px 0 0 var(--tip); }
.block.warn { background: var(--warn-soft); box-shadow: inset 5px 0 0 var(--warn); }
.block.summary {
  background: var(--ok-soft); border-radius: 18px; padding: 14px 20px;
  border: 2px dashed color-mix(in srgb, var(--ok) 35%, transparent);
}
.block.example, .block.fade, .block.check, .block.explain, .block.widget {
  background: var(--bg); border: 1px solid var(--line); border-radius: 18px; padding: 16px 20px;
}
.block .label {
  display: inline-block; font-size: 12px; font-weight: 900; letter-spacing: .08em;
  color: var(--muted); text-transform: uppercase; margin-bottom: 4px;
}
.steps { padding-left: 1.3em; margin: 6px 0; }
.steps li { margin: 5px 0; }
.steps li::marker { color: var(--brand); font-weight: 900; }
.locked {
  text-align: center; color: var(--muted); padding: 18px; font-weight: 700;
  border: 2px dashed var(--line); border-radius: 18px; background: repeating-linear-gradient(-45deg, transparent 0 10px, color-mix(in srgb, var(--bg-2) 60%, transparent) 10px 20px);
}

.big-num { font-family: var(--font-display); font-size: 2em; font-weight: 900; line-height: 1.1; }
table.simple { width: 100%; border-collapse: collapse; font-size: .95em; }
table.simple th { font-size: .85em; color: var(--muted); font-weight: 800; }
table.simple th, table.simple td { border-bottom: 1px solid var(--line); padding: 10px 8px; text-align: left; vertical-align: top; }
table.simple tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* ===== 測驗 ===== */
.quiz-top { display: flex; align-items: center; gap: 12px; margin: 6px 0 4px; }
.quiz-top .count { font-family: var(--font-display); font-weight: 900; white-space: nowrap; }
.q-stem { font-size: 1.15em; font-weight: 700; line-height: 1.7; margin: 4px 0 14px; }
.options { display: grid; gap: 10px; }
.option {
  display: flex; gap: 12px; align-items: center; text-align: left;
  min-height: 56px; padding: 10px 16px; width: 100%;
  border: 2px solid var(--line); border-radius: 16px; background: var(--card); cursor: pointer;
  box-shadow: 0 3px 0 var(--line);
  transition: transform .08s, border-color .15s, background .15s, box-shadow .08s;
}
.option:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.option:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.option .key {
  display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 10px;
  font-family: var(--font-display); font-weight: 900; color: var(--muted); background: var(--bg-2);
}
.option.selected { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 3px 0 var(--brand); }
.option.selected .key { background: var(--brand); color: var(--brand-ink); }
.option.correct { border-color: var(--ok); background: var(--ok-soft); box-shadow: 0 3px 0 var(--ok); animation: pop .35s; }
.option.correct .key { background: var(--ok); color: #fff; }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); box-shadow: 0 3px 0 var(--bad); animation: shake .4s; }
.option.wrong .key { background: var(--bad); color: #fff; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.03); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }

.feedback { border-radius: 16px; padding: 14px 18px; margin-top: 14px; animation: rise .3s both; }
.feedback.ok { background: var(--ok-soft); box-shadow: inset 5px 0 0 var(--ok); }
.feedback.bad { background: var(--bad-soft); box-shadow: inset 5px 0 0 var(--bad); }
.feedback.info { background: var(--tip-soft); box-shadow: inset 5px 0 0 var(--tip); }
details.work { margin-top: 14px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); padding: 10px 14px; }
details.work summary { cursor: pointer; color: var(--muted); font-weight: 700; }
details.work[open] summary { margin-bottom: 8px; }
.progress-dots { display: flex; gap: 4px; flex: 1; }
.progress-dots i { flex: 1; max-width: 40px; height: 8px; border-radius: 99px; background: var(--bg-2); transition: background .2s; }
.progress-dots i.ok { background: var(--ok); }
.progress-dots i.bad { background: var(--bad); }
.progress-dots i.cur { background: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.thumb { max-height: 160px; border-radius: 12px; border: 1px solid var(--line); margin-top: 8px; }

/* ===== 數線 ===== */
.numberline svg { width: 100%; height: auto; touch-action: none; }
.numberline .readout { font-family: var(--font-display); font-size: 1.35em; font-weight: 900; text-align: center; }
.numberline input[type=range] { width: 100%; accent-color: var(--brand); }

/* ===== AI 小老師 ===== */
/* 機器人圖示（SVG），顏色可以被各皮膚覆寫 */
.tutor-ico { width: 100%; height: 100%; display: block; overflow: visible; }
.tutor-ico .ti-head { fill: #fff; }
.tutor-ico .ti-ear { fill: #dfe4ff; }
.tutor-ico .ti-visor { fill: #1f1b4d; }
.tutor-ico .ti-eye { fill: #6ef3ff; }
.tutor-ico .ti-eyes { transform-origin: 16px 15.8px; animation: tiBlink 4.5s infinite; }
.tutor-ico .ti-mouth { fill: none; stroke: #1f1b4d; stroke-width: 1.5; stroke-linecap: round; }
.tutor-ico .ti-ant { stroke: #fff; stroke-width: 1.6; stroke-linecap: round; }
.tutor-ico .ti-spark { fill: #ffd166; }
.tutor-ico .ti-star { fill: #ffd166; transform-origin: 27px 5px; animation: tiTwinkle 2.4s ease-in-out infinite; }
@keyframes tiBlink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.12); } }
@keyframes tiTwinkle { 0%, 100% { opacity: .35; transform: scale(.7); } 50% { opacity: 1; transform: scale(1.1); } }
/* 小型 AI 圖示：放在標題、按鈕、說明文字前面 */
.ai-ico {
  display: inline-block; vertical-align: -.28em; width: 1.35em; height: 1.35em; padding: .14em; margin-right: .15em;
  border-radius: 50%; box-sizing: border-box;
  background: linear-gradient(135deg, var(--brand-2), var(--brand) 55%, var(--brand-deep));
}
.btn .ai-ico, .auth-hero .ai-ico { background: rgba(255, 255, 255, .2); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35); }
.auth-hero li .ic .ai-ico { width: 30px; height: 30px; padding: 3px; margin: 0; vertical-align: middle; background: none; box-shadow: none; }

.tutor-fab {
  position: fixed; right: 18px; bottom: 98px; z-index: 30;
  border-radius: 999px; --b: var(--brand); --bi: #fff; --bd: var(--brand-deep);
  box-shadow: 0 4px 0 var(--brand-deep), var(--shadow-lg);
  gap: 8px; padding-left: 8px; padding-right: 18px;
}
.tutor-fab-ico {
  flex: none; width: 34px; height: 34px; padding: 3px; border-radius: 50%;
  background: rgba(255, 255, 255, .18); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35);
}
.tutor-fab:hover .tutor-fab-ico { animation: tiBob .8s ease-in-out infinite; }
@keyframes tiBob { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-2px) rotate(-6deg); } }
@media (min-width: 721px) { .tutor-fab { bottom: 28px; right: 28px; } }

.tutor-panel {
  position: fixed; right: 16px; bottom: 156px; z-index: 31;
  width: min(460px, calc(100vw - 32px)); height: min(640px, calc(100vh - 190px)); min-height: 380px;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow-lg);
  animation: rise .25s both;
}
@media (min-width: 721px) { .tutor-panel { bottom: 96px; right: 28px; height: min(660px, calc(100vh - 130px)); } }
/* 手機：改成從下方滑出的大面板，幾乎佔滿螢幕 */
@media (max-width: 720px) {
  .tutor-panel { left: 0; right: 0; bottom: 0; width: 100%; height: 88vh; height: 88dvh; min-height: 0; border-radius: 22px 22px 0 0; }
}
.tutor-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 14%, transparent), transparent 70%);
}
.tutor-title { flex: 1; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.tutor-title b { font-size: 1.05em; }
.tutor-avatar {
  flex: none; width: 42px; height: 42px; padding: 5px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-2), var(--brand) 55%, var(--brand-deep));
  box-shadow: 0 3px 10px -3px var(--brand);
}
.tutor-avatar.sm { width: 30px; height: 30px; padding: 3px; margin-top: 2px; box-shadow: none; }
.tutor-log { overflow-y: auto; padding: 14px 14px 6px; flex: 1; min-height: 0; overscroll-behavior: contain; }
.msg-row { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0; }
.msg-row.user { justify-content: flex-end; }
.msg { margin: 0; padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; line-height: 1.65; max-width: 85%; overflow-wrap: anywhere; }
.msg.user { background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 6px; }
.msg.ai { background: var(--bg-2); border-top-left-radius: 6px; }
.tutor-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px 38px; }
.tutor-chip {
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: .9em;
  background: var(--brand-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent);
  transition: background .15s, transform .1s;
}
.tutor-chip:hover { background: color-mix(in srgb, var(--brand) 22%, transparent); }
.tutor-chip:active { transform: scale(.96); }
.tutor-input { padding: 10px 12px 12px; border-top: 1px solid var(--line); background: var(--card); }
.tutor-input textarea {
  display: block; width: 100%; box-sizing: border-box; resize: none;
  min-height: 84px; max-height: 200px; overflow-y: auto; line-height: 1.6;
}
.tutor-bar { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
@media (max-width: 720px) { .tutor-bar .muted { display: none; } }

/* ===== 其他 ===== */
.toast {
  position: fixed; left: 50%; top: 76px; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--bg); padding: 10px 20px; border-radius: 999px;
  font-size: 15px; font-weight: 700; box-shadow: var(--shadow-lg); animation: drop .3s both;
}
@keyframes drop { from { opacity: 0; transform: translate(-50%, -10px); } }
.spin { display: inline-block; width: 16px; height: 16px; border: 2.5px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -3px; }
@keyframes sp { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* 換頁時內容淡入上浮 */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
main > * { animation: rise .4s cubic-bezier(.2,.8,.2,1) both; }
main > *:nth-child(2) { animation-delay: .04s; }
main > *:nth-child(3) { animation-delay: .08s; }
main > *:nth-child(4) { animation-delay: .12s; }
main > *:nth-child(n+5) { animation-delay: .16s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ===== 註冊選項 ===== */
.seg-sm a { padding: 7px 10px; font-size: .85em; }
.choice { display: grid; gap: 8px; }
.choice .opt {
  display: flex; gap: 12px; align-items: flex-start; margin: 0; cursor: pointer; font-weight: 400; line-height: 1.55;
  padding: 12px 14px; border: 2px solid var(--line); border-radius: 16px; background: var(--card);
  transition: border-color .15s, background .15s;
}
.choice .opt:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.choice .opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice input { margin-top: 5px; accent-color: var(--brand); width: 18px; height: 18px; flex: none; }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 700; margin-top: 16px; cursor: pointer; }
label.check input { width: 18px; height: 18px; accent-color: var(--brand); }

/* 教材裡的表格 */
.block .tbl { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: .95em; display: block; overflow-x: auto; }
.block .tbl th, .block .tbl td { border: 1px solid var(--line, #e6e0d4); padding: 6px 10px; text-align: left; vertical-align: top; }
.block .tbl th { background: color-mix(in srgb, var(--c, var(--brand)) 10%, transparent); font-weight: 700; white-space: nowrap; }
.block .tbl tr:nth-child(even) td { background: color-mix(in srgb, var(--c, var(--brand)) 4%, transparent); }

/* ===== 手機防偏移 =====
   任何元素（旋轉的表情符號、陰影、很長的 Email 或網址）只要比螢幕寬一點點，
   手機就能左右滑動，整頁看起來會偏一邊。這裡把水平方向鎖住，並讓長文字自動換行。 */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* 只在 html 用 hidden（會交給整個視窗處理），body 用 clip，頂部列的 sticky 才不會壞掉 */
html { overflow-x: hidden; }
@supports (overflow: clip) { html, body { overflow-x: clip; } }
main, .card, .block { overflow-wrap: anywhere; min-width: 0; }
@media (max-width: 720px) {
  /* 瀏海、圓角螢幕：左右安全區域一樣寬，內容才會置中 */
  .topbar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  main { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
}

/* 登入頁：分頁不能撐寬版面（iPhone 字比較寬，四個分頁一排會超出螢幕） */
.auth > * { min-width: 0; }
@media (max-width: 820px) { .auth { grid-template-columns: minmax(0, 1fr); } }
.seg a { min-width: 0; }
@media (max-width: 480px) {
  .seg:not(.seg-sm) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .seg a { white-space: normal; padding: 9px 6px; }
}

/* 家長：已存的 AI 金鑰 */
.fa-key { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin: 8px 0; background: var(--card); }
.fa-key.on { border-color: var(--ok); background: var(--ok-soft); }
.fa-key-main { min-width: 0; overflow-wrap: anywhere; }
.fa-key-btns { margin-top: 8px; gap: 6px; flex-wrap: wrap; }
.fa-edit { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }

/* 自繪示意圖（顏色跟著深淺色主題） */
.block.fig { margin: 14px 0; padding: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); text-align: center; }
.block.fig svg { width: 100%; min-width: 500px; height: auto; max-width: 680px; display: block; margin: 0 auto; overflow: visible; }
.block.fig figcaption { font-size: .85rem; color: var(--muted); margin-top: 8px; }
.fig text { fill: var(--ink); font-size: 14px; font-family: inherit; }
.fig text.tm { fill: var(--muted); font-size: 12px; }
.fig text.tb { font-weight: 700; }
.fig .ln { stroke: var(--ink); fill: none; stroke-width: 1.5; }
.fig .lm { stroke: var(--muted); fill: none; stroke-width: 1; }
.fig .ar { stroke: var(--ink); fill: none; stroke-width: 2; }
.fig .ah { fill: var(--ink); }
.fig .f-card { fill: var(--card); }
.fig .f-ok { fill: var(--ok-soft); } .fig .f-brand { fill: var(--brand-soft); } .fig .f-warn { fill: var(--warn-soft); }
.fig .f-bad { fill: var(--bad-soft); } .fig .f-tip { fill: var(--tip-soft); } .fig .f-story { fill: var(--story-soft); }
.fig .f-mint { fill: var(--mint); } .fig .f-sun { fill: var(--sun); } .fig .f-coral { fill: var(--coral); }
.fig .f-sky { fill: var(--sky); } .fig .f-pur { fill: var(--brand); } .fig .f-orange { fill: var(--orange); }
.fig .s-mint { stroke: var(--mint); } .fig .s-coral { stroke: var(--coral); } .fig .s-pur { stroke: var(--brand); } .fig .s-sky { stroke: var(--sky); } .fig .s-orange { stroke: var(--orange); }
@media (max-width: 560px) { .block.fig figcaption::after { content: "（↔ 圖可以左右滑動）"; display: block; font-size: .78rem; } }
/* 分數（直式） */
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: .92em; line-height: 1.15; margin: 0 .12em; }
.frac > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 .2em; }
.frac > span:last-child { padding: 0 .2em; }
/* 題目附圖 */
.block.fig.qfig { margin: 10px 0; padding: 8px; }
.block.fig.qfig svg { min-width: 0; max-width: 580px; }

/* =========================================================
   網站皮膚：<html data-skin="...">（沒設定＝原本的「暖紙紫」，會跟著系統深淺色）
   shadow：暗影覺醒（深夜紫底 #0d0924、藍紫光暈 #6f86d6 的系統視窗）
   pink：粉嫩少女　macaron：馬卡龍
   ========================================================= */
/* 皮膚選單 */
.skin-btn {
  margin-left: auto; flex: none; display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font-size: 18px; padding: 0;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.topbar nav ~ .skin-btn { margin-left: 4px; }
.skin-pop {
  position: absolute; right: max(16px, calc((100vw - 1040px) / 2)); top: calc(100% + 6px); z-index: 40;
  width: min(330px, calc(100vw - 32px)); padding: 12px; border-radius: 18px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
}
html[data-skin="shadow"] .skin-pop { background: #150f33; }
.skin-pop h3 { margin: 0 0 8px; font-size: 1em; }
.skin-opt {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; margin-top: 4px;
  border-radius: 12px; border: 2px solid transparent; background: none; cursor: pointer; text-align: left;
}
.skin-opt:hover { background: var(--bg-2); }
.skin-opt.on { border-color: var(--brand); background: var(--brand-soft); }
.skin-opt .sw { flex: none; display: flex; width: 54px; height: 30px; border-radius: 9px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.skin-opt .sw i { flex: 1; }
.skin-opt b { display: block; line-height: 1.3; }
.skin-opt .small { line-height: 1.3; }
@media (max-width: 760px) { .topbar nav ~ .skin-btn { margin-left: auto; } }

/* ---------- 暗影覺醒 ---------- */
html[data-skin="shadow"] {
  color-scheme: dark;
  --bg: #0d0924; --bg-2: #171035; --card: #110b2c;
  --ink: #f4f7ff; --muted: #a9b4d6; --line: rgba(255, 255, 255, .55);
  --brand: #6f9bff; --brand-2: #b7c9ff; --brand-deep: #2f4fd6; --brand-ink: #ffffff; --brand-soft: rgba(255, 255, 255, .1);
  --sun: #ffd166; --coral: #ff6b8a; --mint: #3ee6b0; --sky: #4fc3ff; --teal: #2ee6e6; --orange: #ff9a52; --pink: #e57bff;
  --ok: #3ee6b0; --ok-soft: rgba(62, 230, 176, .12); --bad: #ff5c7a; --bad-soft: rgba(255, 92, 122, .13);
  --warn: #ffc14d; --warn-soft: rgba(255, 193, 77, .12); --tip: #4fc3ff; --tip-soft: rgba(79, 195, 255, .12);
  --story-soft: rgba(255, 255, 255, .06);
  --glow: 0 0 6px rgba(111, 134, 214, .9), 0 0 18px rgba(111, 134, 214, .55), 0 0 40px rgba(111, 134, 214, .35);
  --shadow-sm: 0 0 0 1px rgba(111, 134, 214, .35), 0 0 10px -2px rgba(111, 134, 214, .45);
  --shadow: 0 0 0 1px rgba(111, 134, 214, .7), 0 0 14px rgba(111, 134, 214, .45), 0 0 38px -6px rgba(111, 134, 214, .55), inset 0 0 22px -8px rgba(111, 134, 214, .35);
  --shadow-lg: 0 0 0 1px rgba(111, 134, 214, .85), 0 0 20px rgba(111, 134, 214, .55), 0 0 60px -6px rgba(111, 134, 214, .6), inset 0 0 30px -10px rgba(111, 134, 214, .4);
  --radius: 6px; --radius-sm: 4px;
}
html[data-skin="shadow"] body {
  background-color: #0d0924;
  background-image:
    radial-gradient(900px 520px at 50% -18%, rgba(111, 134, 214, .28), transparent 62%),
    radial-gradient(600px 600px at 100% 100%, rgba(111, 134, 214, .16), transparent 60%),
    linear-gradient(rgba(255, 255, 255, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px);
  background-size: auto, auto, 40px 40px, 40px 40px;
}
html[data-skin="shadow"] .card { border: 1px solid rgba(255, 255, 255, .8); background: linear-gradient(180deg, rgba(30, 24, 70, .55), rgba(13, 9, 36, .9)); }
html[data-skin="shadow"] main h1, html[data-skin="shadow"] main h2 {
  background: none; color: #fff; text-shadow: none; letter-spacing: .04em;
}
html[data-skin="shadow"] .auth-hero h1 { background: none; color: #fff; text-shadow: none; }
html[data-skin="shadow"] .logo-mark { background: linear-gradient(145deg, #241b5e, #0d0924); box-shadow: 0 0 0 1px rgba(255, 255, 255, .8), var(--glow); }
html[data-skin="shadow"] .topbar { background: rgba(13, 9, 36, .85); border-bottom: 1px solid rgba(255, 255, 255, .7); box-shadow: 0 0 18px rgba(111, 134, 214, .25); }
html[data-skin="shadow"] .topbar nav a.active { background: rgba(255, 255, 255, .1); color: #fff; box-shadow: 0 0 0 1px #fff, 0 0 14px rgba(111, 134, 214, .7); text-shadow: none; }
html[data-skin="shadow"] .auth-hero {
  background:
    radial-gradient(420px 260px at 50% 0%, rgba(111, 134, 214, .3), transparent 65%),
    radial-gradient(380px 300px at 0% 100%, rgba(111, 134, 214, .3), transparent 60%),
    linear-gradient(160deg, #1a1442, #0d0924 55%, #07051a);
  border: 1px solid #fff;
  box-shadow: 0 0 0 1px rgba(111, 134, 214, .4), 0 0 24px rgba(111, 134, 214, .6), 0 0 70px -10px rgba(111, 134, 214, .7), inset 0 0 40px -10px rgba(111, 134, 214, .45);
}
html[data-skin="shadow"] .hello { border: 1px solid rgba(255, 255, 255, .8); background: linear-gradient(135deg, rgba(255, 255, 255, .1), rgba(90, 120, 255, .08)); box-shadow: var(--shadow); }
html[data-skin="shadow"] .btn { border-color: rgba(255, 255, 255, .7); }
html[data-skin="shadow"] .btn.primary { background: linear-gradient(180deg, #4f7cff, #2340c8); color: #fff; border: 1px solid #fff; box-shadow: 0 0 10px rgba(111, 134, 214, .8), 0 0 28px -4px rgba(111, 134, 214, .9); text-shadow: none; }
html[data-skin="shadow"] .btn.primary:hover { box-shadow: 0 0 14px #6f86d6, 0 0 40px -2px rgba(111, 134, 214, 1); }
@media (max-width: 760px) { html[data-skin="shadow"] .topbar nav { background: rgba(13, 9, 36, .96); } }

/* ---------- 粉嫩少女 ---------- */
html[data-skin="pink"] {
  color-scheme: light;
  --bg: #fff4f8; --bg-2: #ffe7f0; --card: #ffffff;
  --ink: #4a2338; --muted: #9a6a82; --line: #f7d5e3;
  --brand: #f0589a; --brand-2: #ff9cc5; --brand-deep: #c93a7a; --brand-ink: #ffffff; --brand-soft: #ffe4ef;
  --sun: #ffb84d; --coral: #ff7a8a; --mint: #2fb98a; --sky: #5b9dff; --teal: #26a9a9; --orange: #ff9257; --pink: #f0589a;
  --ok: #1ea672; --ok-soft: #e4f7ee; --bad: #e0457a; --bad-soft: #ffe8ef; --warn: #d9800a; --warn-soft: #fff1dc;
  --tip: #c35bd8; --tip-soft: #f8eaff; --story-soft: #fff0f6;
  --shadow-sm: 0 1px 2px rgba(200, 60, 120, .08);
  --shadow: 0 1px 2px rgba(200, 60, 120, .06), 0 10px 30px -14px rgba(220, 80, 140, .35);
  --shadow-lg: 0 2px 4px rgba(200, 60, 120, .08), 0 24px 48px -20px rgba(220, 80, 140, .45);
  --radius: 26px; --radius-sm: 16px;
}
html[data-skin="pink"] body {
  background-image:
    radial-gradient(800px 480px at -10% -10%, rgba(255, 150, 195, .3), transparent 60%),
    radial-gradient(700px 420px at 110% 0%, rgba(210, 160, 255, .25), transparent 60%),
    radial-gradient(circle at 12px 12px, rgba(240, 88, 154, .09) 2px, transparent 2.5px);
  background-size: auto, auto, 26px 26px;
}
html[data-skin="pink"] .auth-hero {
  background:
    radial-gradient(420px 300px at 85% 10%, rgba(255, 220, 120, .55), transparent 60%),
    radial-gradient(380px 300px at 0% 100%, rgba(200, 140, 255, .55), transparent 60%),
    linear-gradient(150deg, #ff9cc5, #f0589a 50%, #c93a7a);
}
html[data-skin="pink"] .topbar nav a.active { background: var(--brand); color: #fff; }
html[data-skin="pink"] .who .avatar { background: linear-gradient(135deg, #ffb3d1, #f0589a); }

/* ---------- 馬卡龍 ----------
   四種口味分工：薄荷＝主色（按鈕、連結、進度）、草莓＝目前頁籤／提醒、
   檸檬＝頭像／重點、薰衣草＝一般按鈕邊框／分段選單。底色是淡薄荷奶霜。 */
html[data-skin="macaron"] {
  color-scheme: light;
  --mac-straw: #f7b6c2; --mac-mint: #a8e6e1; --mac-lemon: #fbe7a1; --mac-lav: #c9b8f5;
  --bg: #f2faf8; --bg-2: #e4f4f1; --card: #ffffff;
  --ink: #4a4058; --muted: #8b8299; --line: #eadff0;
  --brand: #2f9f92; --brand-2: #a8e6e1; --brand-deep: #23857a; --brand-ink: #ffffff; --brand-soft: #e0f5f2;
  --sun: #e2b12f; --coral: #e3778d; --mint: #3db39f; --sky: #5fa8e0; --teal: #36a7b3; --orange: #ec9a62; --pink: #d77fb6;
  --ok: #2f9e74; --ok-soft: #e3f5ec; --bad: #de5f72; --bad-soft: #fde9ec; --warn: #c98a12; --warn-soft: #fdf3d6;
  --tip: #8a72e0; --tip-soft: #f1ecff; --story-soft: #fdeef1;
  --shadow-sm: 0 1px 2px rgba(120, 90, 140, .07);
  --shadow: 0 1px 2px rgba(120, 90, 140, .06), 0 10px 28px -14px rgba(160, 120, 180, .32);
  --shadow-lg: 0 2px 4px rgba(120, 90, 140, .07), 0 24px 48px -20px rgba(160, 120, 180, .42);
  --radius: 24px; --radius-sm: 16px;
}
html[data-skin="macaron"] body {
  background-color: var(--bg);
  background-image:
    radial-gradient(560px 400px at 0% 0%, rgba(247, 182, 194, .7), transparent 65%),
    radial-gradient(560px 400px at 100% 0%, rgba(251, 231, 161, .75), transparent 65%),
    radial-gradient(640px 460px at 100% 100%, rgba(201, 184, 245, .65), transparent 65%),
    radial-gradient(640px 460px at 0% 100%, rgba(168, 230, 225, .8), transparent 65%),
    radial-gradient(circle at 14px 14px, rgba(201, 184, 245, .35) 2px, transparent 2.6px);
  background-size: auto, auto, auto, auto, 28px 28px;
  background-attachment: fixed;
}
/* 頂部列：四色彩虹奶霜條 */
html[data-skin="macaron"] .topbar {
  background: linear-gradient(90deg, rgba(247, 182, 194, .78), rgba(251, 231, 161, .78) 35%, rgba(168, 230, 225, .78) 68%, rgba(201, 184, 245, .78));
  border-bottom: 3px solid #fff;
  box-shadow: 0 6px 18px -10px rgba(160, 120, 180, .45);
}
html[data-skin="macaron"] .topbar nav a { color: #5d5470; }
html[data-skin="macaron"] .topbar nav a:hover { background: rgba(255, 255, 255, .6); color: var(--ink); }
html[data-skin="macaron"] .topbar nav a.active { background: #fff; color: #c2566f; box-shadow: 0 3px 0 var(--mac-straw); }
@media (max-width: 720px) {
  html[data-skin="macaron"] .topbar nav { background: rgba(255, 255, 255, .92); border: 2px solid var(--mac-lav); }
  html[data-skin="macaron"] .topbar nav a.active { background: var(--mac-straw); color: #6a2d3d; box-shadow: none; }
}
html[data-skin="macaron"] .who { background: rgba(255, 255, 255, .85); border-color: #fff; }
html[data-skin="macaron"] .who .avatar { background: linear-gradient(135deg, var(--mac-lemon), var(--mac-straw)); color: #5a3b45; }
html[data-skin="macaron"] .logo-mark { background: linear-gradient(135deg, var(--mac-straw), var(--mac-lav) 50%, var(--mac-mint)); color: #45405a; box-shadow: 0 3px 0 #fff, 0 8px 18px -8px #b9a6ef; }
html[data-skin="macaron"] .logo-svg .lg-star, html[data-skin="macaron"] .logo-svg .lg-chevron { fill: #4a4058; stroke: #4a4058; }
html[data-skin="macaron"] .logo-svg .lg-chevron { fill: none; }

/* 登入頁大框 */
html[data-skin="macaron"] .auth-hero {
  color: #45405a;
  background:
    radial-gradient(420px 300px at 85% 10%, var(--mac-lemon), transparent 60%),
    radial-gradient(380px 300px at 0% 100%, var(--mac-mint), transparent 60%),
    linear-gradient(150deg, var(--mac-straw), var(--mac-lav) 55%, #b8e0c2);
}
html[data-skin="macaron"] .auth-hero h1 { color: #45405a; }
html[data-skin="macaron"] .auth-hero p { color: #5d5470; }
html[data-skin="macaron"] .auth-hero .eyebrow, html[data-skin="macaron"] .auth-hero li .ic { background: rgba(255,255,255,.6); }

/* 卡片：白色奶油夾心＋輪流換口味的上緣 */
html[data-skin="macaron"] .card { border: 2px solid #fff; box-shadow: var(--shadow), 0 0 0 1px var(--line); }
html[data-skin="macaron"] .grid > .card { border-top: 7px solid var(--mac-straw); }
html[data-skin="macaron"] .grid > .card:nth-child(4n+1) { border-top-color: var(--mac-straw); background: linear-gradient(170deg, #fde7ec, #fff 60%); }
html[data-skin="macaron"] .grid > .card:nth-child(4n+2) { border-top-color: var(--mac-mint); background: linear-gradient(170deg, #ddf5f2, #fff 60%); }
html[data-skin="macaron"] .grid > .card:nth-child(4n+3) { border-top-color: var(--mac-lemon); background: linear-gradient(170deg, #fdf3cf, #fff 60%); }
html[data-skin="macaron"] .grid > .card:nth-child(4n+4) { border-top-color: var(--mac-lav); background: linear-gradient(170deg, #ece5fd, #fff 60%); }
html[data-skin="macaron"] .card.note { border-left: 7px solid var(--c, var(--mac-straw)); }
html[data-skin="macaron"] .hello { background: linear-gradient(120deg, #fde7ec, #fdf3cf 40%, #ddf5f2 75%, #ece5fd); border: 2px solid #fff; }

/* 標題：檸檬色螢光筆底線 */
html[data-skin="macaron"] main h1 {
  text-decoration: underline; text-decoration-color: rgba(251, 231, 161, .95); text-decoration-thickness: .32em;
  text-underline-offset: -.14em; text-decoration-skip-ink: none;
}

/* 按鈕：主要＝薄荷馬卡龍；一般＝薰衣草邊 */
html[data-skin="macaron"] .btn { --bd: #ddd2f7; }
html[data-skin="macaron"] .btn:hover { --bd: var(--mac-lav); }
html[data-skin="macaron"] .btn.primary { --b: #8fdcd3; --bi: #1f4f49; --bd: #5fbfb5; background: linear-gradient(180deg, #bdeee8, #8fdcd3); }
html[data-skin="macaron"] .btn.primary:hover { background: linear-gradient(180deg, #ccf3ee, #9de2da); }
html[data-skin="macaron"] .btn.ok { --b: #f7b6c2; --bi: #6a2d3d; --bd: #e48aa0; }
html[data-skin="macaron"] .btn.primary .ai-ico, html[data-skin="macaron"] .tutor-fab-ico { background: rgba(255, 255, 255, .6); }

/* 分段選單、進度條、標籤 */
html[data-skin="macaron"] .seg { background: #f1ecff; border-color: #e3daf9; }
html[data-skin="macaron"] .seg a.on { background: #fff; color: #6a54cc; box-shadow: 0 3px 0 var(--mac-lav); }
html[data-skin="macaron"] .bar { background: #f3eef8; }
html[data-skin="macaron"] .badge.learning { background: #ddf5f2; color: #23857a; }
html[data-skin="macaron"] .badge.due { background: #fdf3cf; color: #9a6b00; }
html[data-skin="macaron"] .badge.ai { background: #f1ecff; color: #6a54cc; }

/* 輸入框與選項 */
html[data-skin="macaron"] input[type=text], html[data-skin="macaron"] input[type=password], html[data-skin="macaron"] input[type=number],
html[data-skin="macaron"] input[type=email], html[data-skin="macaron"] input[type=url], html[data-skin="macaron"] input[type=date],
html[data-skin="macaron"] textarea, html[data-skin="macaron"] select { background: #fbf9ff; border-color: #e6ddf6; }
html[data-skin="macaron"] .option { border-color: #e6ddf6; box-shadow: 0 3px 0 #e6ddf6; }
html[data-skin="macaron"] .option:hover { border-color: var(--mac-lav); }

/* AI 小老師 */
html[data-skin="macaron"] .tutor-avatar, html[data-skin="macaron"] .ai-ico { background: linear-gradient(135deg, var(--mac-straw), var(--mac-lav) 55%, var(--mac-mint)); }
html[data-skin="macaron"] .tutor-head { background: linear-gradient(90deg, #fde7ec, #fdf3cf 40%, #ddf5f2 75%, #ece5fd); }
html[data-skin="macaron"] .msg.user { background: #bdeee8; color: #1f4f49; }
html[data-skin="macaron"] .msg.ai { background: #f6f1ff; }
html[data-skin="macaron"] .tutor-chip { background: #fdf3cf; border-color: #f1dc8f; }

/* =========================================================
   升級系統：狀態視窗、+EXP、系統提示
   ========================================================= */
.sys-window {
  position: relative; overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--brand) 35%, var(--line));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--brand) 9%, var(--card)), var(--card) 60%);
}
.sys-window::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--brand), var(--brand-2), transparent);
}
.sys-title {
  font-family: var(--font-display); font-weight: 900; font-size: 12px; letter-spacing: .22em;
  color: var(--brand); margin-bottom: 6px;
}
.sys-lv { font-family: var(--font-display); font-weight: 900; color: var(--muted); line-height: 1; }
.sys-lv b { font-size: 44px; color: var(--ink); margin-left: 2px; }
.rank-badge {
  display: inline-block; padding: 1px 10px; border-radius: 999px; font-weight: 900; font-size: 13px;
  color: #fff; background: var(--rk, var(--brand)); box-shadow: 0 0 12px -2px var(--rk, var(--brand));
}
.xp-bar { height: 12px; margin: 8px 0 2px; border-radius: 99px; overflow: hidden; background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--line); }
.xp-bar i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--brand-deep), var(--brand), var(--brand-2));
  box-shadow: 0 0 10px var(--brand); transition: width .6s;
}
.sys-quests { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.quest { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: .95em; }
.quest.done span:first-child { color: var(--muted); text-decoration: line-through; }
.lv-chip {
  margin-left: 6px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 900;
  color: var(--brand-ink); background: linear-gradient(135deg, var(--brand-2), var(--brand));
}
.xp-float {
  position: fixed; left: 50%; top: 38%; z-index: 90; transform: translateX(-50%);
  font-family: var(--font-display); font-weight: 900; font-size: 28px; color: var(--brand);
  text-shadow: 0 0 12px color-mix(in srgb, var(--brand) 60%, transparent), 0 2px 0 var(--card);
  pointer-events: none; animation: xpUp 1.6s ease-out forwards;
}
@keyframes xpUp { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -60px) scale(1); } }
.sys-pop-bg {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: rgba(5, 6, 20, .55); backdrop-filter: blur(3px); animation: fadeIn .2s;
}
.sys-pop {
  width: min(420px, 100%); text-align: center; padding: 22px 24px; border-radius: 16px;
  background: var(--card); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--brand) 60%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 15%, transparent), 0 0 50px -6px var(--brand);
  animation: sysIn .35s cubic-bezier(.2, 1.4, .4, 1);
}
.sys-pop h2 { margin: 4px 0 10px; }
.sys-pop .btn { margin-top: 12px; min-width: 120px; }
.sys-big { font-family: var(--font-display); font-weight: 900; font-size: 34px; color: var(--brand); text-shadow: 0 0 16px color-mix(in srgb, var(--brand) 50%, transparent); }
@keyframes sysIn { from { opacity: 0; transform: scale(.85) translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
html[data-skin="shadow"] .sys-pop { background: linear-gradient(180deg, #1a1442, #0d0924); border: 1px solid #fff; border-radius: 6px; box-shadow: 0 0 0 1px rgba(255,255,255,.4), 0 0 26px rgba(111, 134, 214, .7), 0 0 80px -10px rgba(111, 134, 214, .8), inset 0 0 36px -10px rgba(111, 134, 214, .5); }
html[data-skin="shadow"] .sys-big, html[data-skin="shadow"] .sys-pop h2 { color: #fff; text-shadow: none; }
/* 暗影覺醒：文字一律不發光，避免字糊掉 */
html[data-skin="shadow"] .xp-float { text-shadow: none; }
@media (max-width: 760px) { .lv-chip { display: none; } }

/* =========================================================
   段考：倒數卡片、衝刺頁、模擬段考、管理介面範圍勾選
   ========================================================= */
.exam-card {
  display: block; text-decoration: none; color: var(--ink); margin-bottom: 16px;
  border: 1px solid color-mix(in srgb, var(--coral) 45%, var(--line));
  background: linear-gradient(135deg, color-mix(in srgb, var(--coral) 12%, var(--card)), var(--card) 65%);
}
.exam-card:hover { transform: translateY(-1px); }
.exam-big { font-family: var(--font-display); font-size: 1.15em; }
.exam-big span { font-size: 1.5em; color: var(--coral); }
.exam-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.exam-chip { padding: 2px 10px; border-radius: 999px; font-size: 13px; background: color-mix(in srgb, var(--c, var(--brand)) 13%, var(--card)); color: var(--ink); border: 1px solid var(--line); }
.exam-chip b { color: var(--c, var(--brand)); }
.mock-top {
  position: sticky; top: 64px; z-index: 15; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin-bottom: 12px; border-radius: var(--radius-sm);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.mock-timer { font-family: var(--font-display); font-weight: 900; font-variant-numeric: tabular-nums; }
.mock-timer.hurry { color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.mock-q .q-stem { margin-bottom: 8px; }
.mock-rev { padding: 10px 0; border-top: 1px solid var(--line); }
.mock-rev.bad { box-shadow: inset 4px 0 0 var(--bad); padding-left: 10px; }
.exam-subj { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }
.exam-subj input[type=text] { margin-top: 6px; }
.exam-ch { margin-top: 8px; }
.exam-secs { display: flex; flex-wrap: wrap; gap: 4px 14px; padding-left: 24px; }
.exam-chk { display: inline-flex; align-items: center; gap: 6px; font-weight: normal; margin: 2px 0; cursor: pointer; }
.exam-chk input { width: auto; margin: 0; }
@media (max-width: 760px) { .mock-top { top: 56px; } }

/* =========================================================
   考卷健檢：上傳、確認、補強清單
   ========================================================= */
.paper-entry { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink); }
.paper-entry:hover { transform: translateY(-1px); border-color: var(--brand); }
.paper-entry .pe-ic { font-size: 2em; }
.paper-entry b, .paper-entry .small { display: block; }
.paper-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.paper-thumb { position: relative; }
.paper-thumb img { width: 96px; height: 120px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); display: block; }
.paper-thumb button { position: absolute; top: 4px; right: 4px; padding: 0 7px; min-height: 0; line-height: 22px; }
.paper-item { padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); }
.paper-item.bad { box-shadow: inset 4px 0 0 var(--bad); }
.paper-item.unk { box-shadow: inset 4px 0 0 var(--warn, #e0a100); }
.paper-item input, .paper-item select { margin: 0; }
.paper-unit { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.paper-unit .exam-chk { margin-top: 2px; }
.paper-unit.done b { text-decoration: line-through; color: var(--muted); }
.paper-par { padding: 8px 0; border-top: 1px solid var(--line); }
.paper-par summary { cursor: pointer; }
