/* =============================================================================
   劍橋幼兒英語模擬平台 — 全站樣式
   設計取向：幼兒端明亮圓潤、大按鈕大字；教師／家長／管理端沉穩專業。
   ============================================================================= */

:root {
  --starters: #F5A623;
  --movers:   #4A90D9;
  --flyers:   #7B61C9;

  --brand:      #2F6FB2;
  --brand-dark: #1F4E82;
  --accent:     #FF8A3D;
  --success:    #2FA36B;
  --danger:     #E05A47;
  --warning:    #E8A317;

  --ink:        #1E2A38;
  --ink-2:      #4A5A6B;
  --ink-3:      #8194A6;
  --line:       #DDE5EC;
  --bg:         #F4F7FA;
  --card:       #FFFFFF;

  --r-s:  8px;
  --r-m:  14px;
  --r-l:  22px;
  --r-xl: 32px;

  --shadow-s: 0 1px 3px rgba(30,42,56,.08);
  --shadow-m: 0 4px 16px rgba(30,42,56,.10);
  --shadow-l: 0 12px 32px rgba(30,42,56,.14);

  --font: "PingFang HK", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-en: "Nunito", "Quicksand", "Segoe UI", var(--font);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- 版面 */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
  height: 62px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar .logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 17px; color: var(--brand-dark);
}
.topbar .logo-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff; display: grid; place-items: center;
  font-family: var(--font-en); font-weight: 800; font-size: 14px;
}
.topbar .spacer { flex: 1; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  padding: 8px 14px; border-radius: var(--r-s);
  color: var(--ink-2); font-size: 14px; font-weight: 600;
}
.topbar nav a:hover { background: var(--bg); text-decoration: none; }
.topbar nav a.active { background: var(--brand); color: #fff; }

.userchip {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 12px 5px 5px; border-radius: 999px;
  background: var(--bg); font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--line);
}
.userchip .av {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}

.main { flex: 1; padding: 24px 20px 60px; max-width: 1240px; margin: 0 auto; width: 100%; }
.main.narrow { max-width: 880px; }

/* ---------------------------------------------------------------- 元件 */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-m); padding: 20px; box-shadow: var(--shadow-s);
}
.card + .card { margin-top: 16px; }
.card h2 { margin: 0 0 4px; font-size: 17px; }
.card h3 { margin: 0 0 12px; font-size: 15px; color: var(--ink-2); }
.card .sub { color: var(--ink-3); font-size: 13px; margin: 0 0 16px; }

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: var(--r-s);
  border: 1px solid transparent; background: var(--brand); color: #fff;
  font-family: var(--font); font-size: 14px; font-weight: 700;
  cursor: pointer; transition: transform .08s, box-shadow .15s, background .15s;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn.ghost:hover { background: var(--bg); }
.btn.accent { background: var(--accent); }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); }
.btn.lg { padding: 15px 32px; font-size: 16px; border-radius: var(--r-m); }
.btn.sm { padding: 7px 13px; font-size: 13px; }
.btn.block { width: 100%; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--ink-2); }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: var(--r-s);
  font-family: var(--font); font-size: 14px; background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,111,178,.14);
}
.field .hint { font-size: 12px; color: var(--ink-3); margin-top: 5px; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; padding: 10px 12px; background: var(--bg);
  font-size: 12px; font-weight: 700; color: var(--ink-2);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--line); }
table.data tr:hover td { background: #FAFCFE; }

.tag {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: var(--bg); color: var(--ink-2);
}
.tag.ok    { background: #E4F5EC; color: var(--success); }
.tag.warn  { background: #FDF3DE; color: #A9760A; }
.tag.err   { background: #FCE9E6; color: var(--danger); }
.tag.info  { background: #E7F0F9; color: var(--brand); }

.stat { text-align: center; padding: 18px 12px; }
.stat .n { font-size: 30px; font-weight: 800; font-family: var(--font-en); line-height: 1; }
.stat .l { font-size: 12px; color: var(--ink-3); margin-top: 7px; font-weight: 600; }

.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty .big { font-size: 40px; margin-bottom: 10px; }

.toast-wrap { position: fixed; top: 78px; right: 20px; z-index: 999; display: grid; gap: 10px; }
.toast {
  background: var(--ink); color: #fff; padding: 12px 18px;
  border-radius: var(--r-s); font-size: 14px; box-shadow: var(--shadow-l);
  animation: slidein .2s ease;
}
.toast.err { background: var(--danger); }
.toast.ok  { background: var(--success); }
@keyframes slidein { from { opacity: 0; transform: translateX(16px); } }

/* ---------------------------------------------------------------- 登入頁 */
.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(150deg, #E8F1FA 0%, #F6F0E6 60%, #F2EAF6 100%);
}
.login-box {
  width: 100%; max-width: 420px; background: #fff;
  border-radius: var(--r-xl); padding: 40px 34px; box-shadow: var(--shadow-l);
}
.login-box .brand { text-align: center; margin-bottom: 26px; }
.login-box .brand .mark {
  width: 66px; height: 66px; margin: 0 auto 14px; border-radius: 20px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff; display: grid; place-items: center;
  font-family: var(--font-en); font-weight: 800; font-size: 24px;
}
.login-box .brand h1 { margin: 0 0 5px; font-size: 21px; }
.login-box .brand p { margin: 0; color: var(--ink-3); font-size: 13px; }

/* ---------------------------------------------------------------- 幼兒端 */
.kid { --kid-accent: var(--starters); }
.kid .main { max-width: 1080px; }

.kid-hero {
  border-radius: var(--r-xl); padding: 26px 30px; color: #fff;
  background: linear-gradient(120deg, var(--kid-accent), var(--accent));
  display: flex; align-items: center; gap: 22px; box-shadow: var(--shadow-m);
}
.kid-hero .mascot {
  width: 78px; height: 78px; border-radius: 50%; background: rgba(255,255,255,.25);
  display: grid; place-items: center; font-size: 40px; flex-shrink: 0;
}
.kid-hero h1 { margin: 0 0 6px; font-size: 25px; }
.kid-hero p { margin: 0; opacity: .92; font-size: 15px; }
.kid-hero .stars { margin-left: auto; text-align: center; }
.kid-hero .stars .n { font-size: 34px; font-weight: 800; font-family: var(--font-en); }
.kid-hero .stars .l { font-size: 12px; opacity: .9; }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.tile {
  background: #fff; border: 2px solid var(--line); border-radius: var(--r-l);
  padding: 22px 18px; text-align: center; cursor: pointer;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.tile:hover { transform: translateY(-3px); border-color: var(--kid-accent); box-shadow: var(--shadow-m); }
.tile .ico { font-size: 38px; margin-bottom: 10px; }
.tile .t { font-weight: 800; font-size: 16px; margin-bottom: 4px; }
.tile .d { font-size: 12px; color: var(--ink-3); }

/* 作答區 */
.q-stage {
  background: #fff; border-radius: var(--r-xl); padding: 28px;
  box-shadow: var(--shadow-m); min-height: 380px;
}
.q-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 20px; }
.q-num {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: var(--kid-accent); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
  font-family: var(--font-en);
}
.q-prompt { font-size: 20px; font-weight: 700; line-height: 1.5; }
.q-prompt-zh { font-size: 14px; color: var(--ink-3); margin-top: 5px; font-weight: 500; }
.q-instruction {
  background: #FFF8EC; border-left: 4px solid var(--warning);
  padding: 11px 15px; border-radius: var(--r-s); font-size: 13px;
  color: #7A5A12; margin-bottom: 18px;
}

.opt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.opt {
  border: 3px solid var(--line); border-radius: var(--r-l); padding: 14px;
  cursor: pointer; text-align: center; background: #fff;
  transition: transform .1s, border-color .1s, background .1s;
  position: relative;
}
.opt:hover { transform: translateY(-2px); border-color: var(--kid-accent); }
.opt.sel  { border-color: var(--kid-accent); background: #FFF7EC; }
.opt.ok   { border-color: var(--success); background: #EDF9F2; }
.opt.no   { border-color: var(--danger);  background: #FDF0EE; }
.opt img  { width: 100%; max-height: 140px; object-fit: contain; border-radius: var(--r-s); }
.opt .k {
  position: absolute; top: 8px; left: 8px;
  width: 26px; height: 26px; border-radius: 50%; background: var(--bg);
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
  font-family: var(--font-en); color: var(--ink-2);
}
.opt .lbl { font-size: 17px; font-weight: 700; margin-top: 8px; }

.big-input {
  font-size: 26px; font-weight: 700; text-align: center; letter-spacing: 3px;
  padding: 16px; border: 3px solid var(--line); border-radius: var(--r-m);
  font-family: var(--font-en); width: 100%; max-width: 360px;
}
.big-input:focus { outline: none; border-color: var(--kid-accent); }

.letter-pool { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 18px 0; }
.letter {
  width: 54px; height: 54px; border-radius: var(--r-m);
  border: 3px solid var(--line); background: #fff;
  font-size: 24px; font-weight: 800; font-family: var(--font-en);
  cursor: pointer; text-transform: uppercase;
}
.letter:hover { border-color: var(--kid-accent); }
.letter.used { opacity: .3; pointer-events: none; }

.yesno { display: flex; gap: 18px; justify-content: center; margin-top: 20px; }
.yesno button {
  width: 120px; height: 90px; border-radius: var(--r-l);
  border: 3px solid var(--line); background: #fff;
  font-size: 34px; cursor: pointer;
}
.yesno button.sel { border-color: var(--kid-accent); background: #FFF7EC; }

.scene { position: relative; display: inline-block; max-width: 100%; }
.scene img { max-width: 100%; border-radius: var(--r-m); display: block; }
.hot {
  position: absolute; transform: translate(-50%, -50%);
  width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid rgba(47,111,178,.65); background: rgba(255,255,255,.55);
  cursor: pointer; display: grid; place-items: center;
  font-weight: 800; font-size: 13px; color: var(--brand-dark);
}
.hot:hover { background: rgba(255,255,255,.9); }
.hot.sel { border-color: var(--accent); background: var(--accent); color: #fff; }

.colour-pick { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.swatch {
  width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
  border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line);
}
.swatch.sel { box-shadow: 0 0 0 4px var(--ink); }

.audio-bar {
  display: flex; align-items: center; gap: 14px;
  background: #EEF4FA; border-radius: var(--r-m); padding: 14px 18px; margin-bottom: 18px;
}
.audio-bar .play {
  width: 52px; height: 52px; border-radius: 50%; border: none;
  background: var(--brand); color: #fff; font-size: 22px; cursor: pointer;
}
.audio-bar .play:disabled { background: var(--ink-3); cursor: not-allowed; }
.audio-bar .meta { font-size: 13px; color: var(--ink-2); font-weight: 600; }

.rec-btn {
  width: 96px; height: 96px; border-radius: 50%; border: none;
  background: var(--danger); color: #fff; font-size: 36px; cursor: pointer;
  box-shadow: 0 6px 20px rgba(224,90,71,.35);
}
.rec-btn.recording { animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { transform: scale(1.07); box-shadow: 0 6px 30px rgba(224,90,71,.55); } }

.feedback {
  margin-top: 20px; padding: 16px 20px; border-radius: var(--r-m); font-weight: 700;
}
.feedback.ok { background: #EDF9F2; color: var(--success); border: 2px solid #BFE8D2; }
.feedback.no { background: #FDF0EE; color: var(--danger);  border: 2px solid #F3C9C2; }
.feedback .exp { font-weight: 500; font-size: 13px; color: var(--ink-2); margin-top: 8px; }

.progress { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--kid-accent); transition: width .3s; }

.shields { display: flex; gap: 5px; }
.shields span { font-size: 22px; filter: grayscale(1); opacity: .3; }
.shields span.on { filter: none; opacity: 1; }

.timer {
  font-family: var(--font-en); font-weight: 800; font-size: 18px;
  padding: 7px 15px; border-radius: 999px; background: var(--bg); color: var(--ink-2);
}
.timer.warn { background: #FDF3DE; color: #A9760A; }
.timer.danger { background: #FCE9E6; color: var(--danger); }

/* 圖表 */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; }
.bars .b { flex: 1; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 3px; position: relative; }
.bars .b:hover { background: var(--brand-dark); }
.barlist { display: grid; gap: 10px; }
.barlist .item { display: grid; grid-template-columns: 130px 1fr 50px; gap: 10px; align-items: center; font-size: 13px; }
.barlist .track { height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; }
.barlist .track i { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.barlist .track i.low  { background: var(--danger); }
.barlist .track i.mid  { background: var(--warning); }
.barlist .track i.high { background: var(--success); }

@media (max-width: 860px) {
  .grid.c4 { grid-template-columns: repeat(2, 1fr); }
  .grid.c3, .grid.c2 { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar nav a { padding: 7px 9px; font-size: 13px; }
  .main { padding: 16px 12px 48px; }
  .kid-hero { flex-direction: column; text-align: center; }
  .kid-hero .stars { margin-left: 0; }
  .barlist .item { grid-template-columns: 90px 1fr 44px; }
}
