/* ============================================================
 *  VocabularyTraining v14 — Commercial UI (Notion/Linear 風)
 *  - 電腦版：左側 sidebar + 寬內容區
 *  - 手機版：頂部精簡 header + 底部 4 鍵導航
 *  - 商業化：頭像、暱稱、排行榜、個人資料頁
 * ============================================================ */

:root{
  --cm-ink:#1F2329;
  --cm-ink-2:#3E434D;
  --cm-ink-3:#6B7280;
  --cm-ink-4:#9CA3AF;
  --cm-surface:#FFFFFF;
  --cm-bg:#FAFAF9;
  --cm-bg-2:#F3F3F1;
  --cm-line:#E6E5E1;
  --cm-line-2:#EDECE8;
  --cm-accent:#534AB7;
  --cm-accent-soft:#EEEDFE;
  --cm-gold:#E3A008;
  --cm-silver:#9CA3AF;
  --cm-bronze:#B45309;
  --cm-green:#1D9E75;
  --cm-danger:#E24B4A;
  --cm-sidebar-w:240px;
  --cm-header-h:56px;
  --cm-bottom-nav-h:66px;
  --cm-shadow-sm:0 1px 2px rgba(15,23,42,.04);
  --cm-shadow-md:0 4px 12px rgba(15,23,42,.06);
  --cm-shadow-lg:0 8px 28px rgba(15,23,42,.08);
}

/* ============================================================
 *  整體版面重構
 * ============================================================ */

body.cm-mode{
  background: var(--cm-bg);
  color: var(--cm-ink);
}

body.cm-mode .app{
  max-width: none;
  margin: 0;
  padding: 0;
}

body.cm-mode .main-wrap{
  background: transparent;
  min-height: 100vh;
  padding: 0;
  display: grid;
  grid-template-columns: var(--cm-sidebar-w) 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar content";
}

/* ============================================================
 *  電腦版 Sidebar
 * ============================================================ */

.cm-sidebar{
  grid-area: sidebar;
  background: var(--cm-surface);
  border-right: 1px solid var(--cm-line);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 20;
}

.cm-sidebar-brand{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 14px;
  border-bottom: 1px solid var(--cm-line-2);
  margin-bottom: 10px;
}
.cm-sidebar-brand-logo{
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #6c63ff 0%, #00d2ff 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 17px;
  box-shadow: 0 4px 10px -2px rgba(108,99,255,.4);
}
.cm-sidebar-brand-name{
  font-weight: 700;
  font-size: 15px;
  color: var(--cm-ink);
  letter-spacing: -0.01em;
}
.cm-sidebar-brand-tag{
  font-size: 11px;
  color: var(--cm-ink-4);
  margin-top: 1px;
}

.cm-nav-section-title{
  font-size: 11px;
  font-weight: 600;
  color: var(--cm-ink-4);
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 14px 10px 6px;
}

/* ============================================================
 *  v14.3.2 學科切換器 (top-bar 版 + 手機滾動列版)
 *  共用：.cm-subject-btn  → active / locked / hover 行為一致
 *  差異：
 *   - .cm-subject-switcher--top      桌面 top-bar 橫向膠囊
 *   - .cm-subject-switcher--mobile   手機 top-bar 下方橫向可捲列
 * ============================================================ */
.cm-subject-btn{
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--cm-ink-3);
  font-family: inherit;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .12s ease;
  white-space: nowrap;
  flex: 0 0 auto;
}
.cm-subject-btn:hover{
  background: #fff;
  color: var(--cm-ink-2);
}
.cm-subject-btn.active{
  background: linear-gradient(135deg, #6c63ff 0%, #00d2ff 100%);
  color: #fff;
  box-shadow: 0 4px 12px -4px rgba(108,99,255,.5);
}
.cm-subject-btn.active:hover{
  background: linear-gradient(135deg, #6c63ff 0%, #00d2ff 100%);
  transform: translateY(-1px);
}
.cm-subject-btn.locked{
  color: var(--cm-ink-4);
  opacity: .65;
}
.cm-subject-btn.locked:hover{
  opacity: 1;
  background: #fff;
}
.cm-subject-icon{
  font-size: 15px;
  line-height: 1;
  font-weight: 700;
}
.cm-subject-btn.active .cm-subject-icon{
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.15));
}
.cm-subject-name{
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.cm-subject-lock{
  font-size: 10px;
  margin-left: 2px;
  opacity: .55;
}
.cm-subject-btn.active .cm-subject-lock{ opacity: .85; }

/* ── 桌面版：top-bar 內的群組容器 ───────────────────────── */
.cm-subject-switcher--top{
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin-left: 10px;
  background: var(--cm-bg-2);
  border-radius: 10px;
  border: 1px solid var(--cm-line-2);
  flex-wrap: nowrap;
  flex-shrink: 0;
}

/* ── 手機版：top-bar 下方獨立一條橫向可捲 ─────────────── */
.cm-subject-switcher--mobile{
  display: none;                       /* 桌面隱藏 */
  gap: 4px;
  padding: 8px 12px;
  background: rgba(255,255,255,.88);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--cm-line);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: sticky;
  top: 52px;                           /* 貼在手機 top-bar 下方 */
  z-index: 14;
}
.cm-subject-switcher--mobile::-webkit-scrollbar{ display: none; }
.cm-subject-switcher--mobile .cm-subject-btn{
  scroll-snap-align: start;
  border: 1px solid var(--cm-line-2);
  background: #fff;
  padding: 6px 14px;
}
.cm-subject-switcher--mobile .cm-subject-btn.active{
  border-color: transparent;
}
.cm-subject-switcher--mobile .cm-subject-btn.locked{
  background: var(--cm-bg-2);
}

/* 深色模式 */
html[data-theme="dark"] .cm-subject-switcher--top,
html[data-theme="dark"] .cm-subject-switcher--mobile{
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
}
html[data-theme="dark"] .cm-subject-switcher--mobile{
  background: rgba(24,26,35,.9);
}
html[data-theme="dark"] .cm-subject-switcher--mobile .cm-subject-btn{
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.06);
}
html[data-theme="dark"] .cm-subject-btn:hover{
  background: rgba(255,255,255,0.06);
}
/* v14.3.4: 深色模式下鎖定按鈕的色彩補齊 ──────────────────── */
html[data-theme="dark"] .cm-subject-btn.locked{
  color: rgba(255,255,255,.55);
  opacity: .7;
}
html[data-theme="dark"] .cm-subject-btn.locked:hover{
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,.75);
  opacity: 1;
}
html[data-theme="dark"] .cm-subject-switcher--mobile .cm-subject-btn.locked{
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.05);
}
html[data-theme="dark"] .cm-subject-btn.active{
  box-shadow: 0 4px 14px -4px rgba(108,99,255,.7);
}
html[data-theme="dark"] .cm-subject-lock{ opacity: .4; }

/* Coming-soon modal icon */
.cm-cs-icon{
  font-size: 48px;
  line-height: 1;
  margin: 0 auto 8px;
  width: 76px;
  height: 76px;
  border-radius: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(108,99,255,.16), rgba(0,210,255,.16));
  border: 1px solid rgba(108,99,255,.25);
}

/* 窄桌面：top-bar 塞不下五顆時，縮字 / 只顯示圖示 */
@media (max-width: 1100px){
  .cm-subject-switcher--top .cm-subject-name{ display: none; }
  .cm-subject-switcher--top .cm-subject-btn{ padding: 6px 10px; }
}

/* 手機版切換顯示 */
@media (max-width: 767.98px){
  .cm-subject-switcher--top{ display: none; }
  .cm-subject-switcher--mobile{ display: flex; }
}

.cm-nav-btn{
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--cm-ink-2);
  cursor: pointer;
  text-align: left;
  font-size: 13.5px;
  font-weight: 500;
  transition: all .12s ease;
}
.cm-nav-btn:hover{ background: var(--cm-bg-2); color: var(--cm-ink); }
.cm-nav-btn.active{
  background: var(--cm-accent-soft);
  color: var(--cm-accent);
  font-weight: 600;
}
.cm-nav-btn-icon{
  width: 18px;
  display: inline-grid; place-items: center;
  font-size: 14px;
}
.cm-nav-btn-badge{
  margin-left: auto;
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--cm-accent);
  color: #fff;
  font-weight: 600;
}

.cm-sidebar-spacer{ flex: 1; }

.cm-sidebar-user{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  background: var(--cm-bg-2);
  cursor: pointer;
  transition: background .12s;
}
.cm-sidebar-user:hover{ background: var(--cm-line-2); }
.cm-sidebar-user-info{ flex:1; min-width:0; }
.cm-sidebar-user-name{
  font-size: 13px;
  font-weight: 600;
  color: var(--cm-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cm-sidebar-user-meta{
  font-size: 11px;
  color: var(--cm-ink-4);
}

/* ============================================================
 *  電腦版 Top bar
 * ============================================================ */

.cm-topbar{
  grid-area: topbar;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--cm-line);
  height: var(--cm-header-h);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 15;
}
.cm-topbar-headings{
  min-width: 0;
  flex-shrink: 0;
}
.cm-topbar-title{
  font-size: 15px;
  font-weight: 600;
  color: var(--cm-ink);
}
.cm-topbar-sub{
  font-size: 12px;
  color: var(--cm-ink-4);
}
.cm-topbar-spacer{ flex: 1; }

/* 窄桌面：隱藏副標讓學科切換器有呼吸空間 */
@media (max-width: 1100px){
  .cm-topbar-sub{ display: none; }
}

.cm-chip{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 99px;
  background: var(--cm-bg-2);
  border: 1px solid var(--cm-line);
  font-size: 12px;
  font-weight: 600;
  color: var(--cm-ink-2);
  cursor: pointer;
  transition: all .12s;
}
.cm-chip:hover{ background: var(--cm-line-2); }
.cm-chip.streak{ background: #FFF7E6; border-color: #F6C454; color: #92400E; }
.cm-chip.level{ background: var(--cm-accent-soft); border-color: #C7C2F2; color: var(--cm-accent); }

.cm-icon-btn{
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--cm-line);
  background: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  font-size: 14px;
  color: var(--cm-ink-2);
  transition: all .12s;
}
.cm-icon-btn:hover{ background: var(--cm-bg-2); color: var(--cm-ink); }

/* ============================================================
 *  主內容區
 * ============================================================ */

.cm-content{
  grid-area: content;
  padding: 28px 32px 48px;
  max-width: 980px;
  width: 100%;
}

.cm-page-header{
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--cm-line);
}
.cm-page-title{
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--cm-ink);
}
.cm-page-desc{
  font-size: 13px;
  color: var(--cm-ink-3);
  margin-top: 3px;
}

/* 電腦版隱藏原本的 tab-bar（以 sidebar 代替） */
body.cm-mode .tab-bar{ display: none !important; }
body.cm-mode .header{ display: none !important; }

/* 所有卡片統一商業化邊框 */
body.cm-mode .card{
  background: var(--cm-surface);
  border: 1px solid var(--cm-line);
  border-radius: 12px;
  box-shadow: var(--cm-shadow-sm);
  padding: 18px 20px;
  margin-bottom: 14px;
}

/* ============================================================
 *  頭像元件
 * ============================================================ */

.cm-avatar{
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #E4E1FB 0%, #C8C2F0 100%);
  color: var(--cm-accent);
  font-weight: 700;
  overflow: hidden;
  position: relative;
  user-select: none;
}
.cm-avatar.size-xs{ width: 22px; height: 22px; font-size: 10px; }
.cm-avatar.size-sm{ width: 28px; height: 28px; font-size: 12px; }
.cm-avatar.size-md{ width: 36px; height: 36px; font-size: 15px; }
.cm-avatar.size-lg{ width: 52px; height: 52px; font-size: 22px; }
.cm-avatar.size-xl{ width: 84px; height: 84px; font-size: 36px; }
.cm-avatar img{ width:100%; height:100%; object-fit:cover; display:block; }
.cm-avatar.has-ring{ box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--cm-accent-soft); }

.cm-avatar-emoji{
  display: inline-grid; place-items: center;
  width: 100%; height: 100%;
}

/* ============================================================
 *  排行榜
 * ============================================================ */

.cm-leaderboard-hero{
  background: linear-gradient(135deg, #534AB7 0%, #7A70D9 48%, #B99CE9 100%);
  border-radius: 16px;
  padding: 20px 22px;
  color: #fff;
  position: relative;
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: 0 8px 30px rgba(83,74,183,.25);
}
.cm-leaderboard-hero::before{
  content:'';
  position:absolute;
  right:-40px; top:-40px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  pointer-events:none;
}
.cm-leaderboard-hero-title{
  font-size: 13px;
  opacity: .9;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.cm-leaderboard-hero-big{
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 2px 0 6px;
}
.cm-leaderboard-hero-meta{
  font-size: 13px;
  opacity: .92;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.cm-lb-range-tabs{
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--cm-bg-2);
  border-radius: 10px;
  border: 1px solid var(--cm-line);
  margin-bottom: 14px;
}
.cm-lb-range-btn{
  padding: 6px 16px;
  border: none;
  background: transparent;
  color: var(--cm-ink-2);
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
  transition: all .12s;
}
.cm-lb-range-btn.active{
  background: #fff;
  color: var(--cm-ink);
  box-shadow: var(--cm-shadow-sm);
}

.cm-podium{
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
  align-items: end;
}
.cm-podium-slot{
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 14px 10px 16px;
  border-radius: 14px;
  background: var(--cm-surface);
  border: 1px solid var(--cm-line);
  box-shadow: var(--cm-shadow-sm);
}
.cm-podium-slot.rank-1{
  background: linear-gradient(180deg,#FFF9E6 0%,#FFFDF5 100%);
  border-color: #F6C454;
  order: 2;
  transform: translateY(-6px);
  box-shadow: 0 6px 24px rgba(227,160,8,.18);
}
.cm-podium-slot.rank-2{ background: linear-gradient(180deg,#F3F4F6 0%,#FAFAFB 100%); border-color:#D1D5DB; order:1; }
.cm-podium-slot.rank-3{ background: linear-gradient(180deg,#FFF4ED 0%,#FFF9F5 100%); border-color:#FCBA87; order:3; }

.cm-podium-crown{
  font-size: 20px;
  margin-bottom: 4px;
}
.cm-podium-name{
  font-size: 13px;
  font-weight: 700;
  color: var(--cm-ink);
  margin-top: 8px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cm-podium-meta{
  font-size: 11px;
  color: var(--cm-ink-3);
  margin-top: 2px;
}
.cm-podium-score{
  font-size: 19px;
  font-weight: 800;
  color: var(--cm-ink);
  margin-top: 6px;
  letter-spacing: -.01em;
}
.cm-podium-score small{
  font-size: 10px;
  font-weight: 600;
  color: var(--cm-ink-4);
  margin-left: 2px;
}

.cm-lb-list{
  background: var(--cm-surface);
  border: 1px solid var(--cm-line);
  border-radius: 12px;
  overflow: hidden;
}
.cm-lb-row{
  display: grid;
  grid-template-columns: 40px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--cm-line-2);
  transition: background .12s;
}
.cm-lb-row:last-child{ border-bottom: none; }
.cm-lb-row:hover{ background: var(--cm-bg); }
.cm-lb-row.is-me{
  background: linear-gradient(90deg, var(--cm-accent-soft) 0%, rgba(238,237,254,0) 100%);
  border-left: 3px solid var(--cm-accent);
  padding-left: 13px;
}

.cm-lb-rank{
  font-size: 13px;
  font-weight: 700;
  color: var(--cm-ink-3);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.cm-lb-rank.top-1{ color: var(--cm-gold); }
.cm-lb-rank.top-2{ color: var(--cm-silver); }
.cm-lb-rank.top-3{ color: var(--cm-bronze); }

.cm-lb-user{
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.cm-lb-user-main{ min-width: 0; flex:1; }
.cm-lb-user-name{
  font-size: 13.5px;
  font-weight: 600;
  color: var(--cm-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cm-lb-user-meta{
  font-size: 11.5px;
  color: var(--cm-ink-4);
  margin-top: 1px;
}

.cm-lb-score{
  font-size: 15px;
  font-weight: 700;
  color: var(--cm-ink);
  font-variant-numeric: tabular-nums;
}
.cm-lb-score small{
  font-size: 10px;
  font-weight: 500;
  color: var(--cm-ink-4);
  margin-left: 2px;
}
.cm-lb-extra{
  font-size: 11.5px;
  font-weight: 600;
  color: var(--cm-ink-3);
  min-width: 60px;
  text-align: right;
}
.cm-lb-extra.acc-high{ color: var(--cm-green); }
.cm-lb-extra.acc-low{ color: var(--cm-danger); }

.cm-lb-empty{
  padding: 40px 20px;
  text-align: center;
  color: var(--cm-ink-4);
}
.cm-lb-empty-emoji{ font-size: 36px; margin-bottom: 8px; }

/* ============================================================
 *  個人資料頁
 * ============================================================ */

.cm-profile-hero{
  background: var(--cm-surface);
  border: 1px solid var(--cm-line);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 18px;
  box-shadow: var(--cm-shadow-sm);
}
.cm-profile-hero-avatar{
  position: relative;
  cursor: pointer;
}
.cm-profile-hero-avatar .cm-edit-badge{
  position: absolute;
  right: -2px; bottom: -2px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--cm-accent);
  color: #fff;
  display: grid; place-items: center;
  font-size: 12px;
  border: 2px solid #fff;
  box-shadow: var(--cm-shadow-sm);
}
.cm-profile-hero-info{ flex: 1; min-width: 0; }
.cm-profile-hero-name{
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--cm-ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.cm-profile-hero-username{
  font-size: 13px;
  color: var(--cm-ink-4);
  margin-top: 3px;
}
.cm-profile-hero-badges{
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.cm-badge-soft{
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--cm-bg-2);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--cm-ink-2);
  border: 1px solid var(--cm-line);
}
.cm-badge-soft.primary{ background: var(--cm-accent-soft); color: var(--cm-accent); border-color:#C7C2F2; }
.cm-badge-soft.gold{ background:#FFF7E6; color:#92400E; border-color:#F6C454; }
.cm-badge-soft.green{ background:#E1F5EE; color:#085041; border-color:#6DD4B2; }

.cm-profile-stats{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.cm-profile-stat{
  background: var(--cm-surface);
  border: 1px solid var(--cm-line);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--cm-shadow-sm);
}
.cm-profile-stat-label{
  font-size: 11.5px;
  color: var(--cm-ink-4);
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.cm-profile-stat-value{
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--cm-ink);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.cm-profile-stat-sub{
  font-size: 11.5px;
  color: var(--cm-ink-3);
  margin-top: 2px;
}

.cm-profile-section-title{
  font-size: 12.5px;
  font-weight: 700;
  color: var(--cm-ink-3);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin: 22px 0 10px;
}

.cm-list-row{
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--cm-surface);
  border: 1px solid var(--cm-line);
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all .12s;
}
.cm-list-row:hover{ background: var(--cm-bg); border-color: var(--cm-line); }
.cm-list-row-icon{
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--cm-bg-2);
  display: grid; place-items: center;
  font-size: 15px;
}
.cm-list-row-main{ flex:1; min-width:0; }
.cm-list-row-title{ font-size: 13.5px; font-weight: 600; color: var(--cm-ink); }
.cm-list-row-sub{ font-size: 11.5px; color: var(--cm-ink-4); margin-top: 2px; }
.cm-list-row-arrow{ color: var(--cm-ink-4); font-size: 16px; }

/* v14.4: 主題 segmented control ─────────────────────────── */
.cm-list-row--theme{ cursor: default; flex-wrap: wrap; row-gap: 10px; }
.cm-list-row--theme:hover{ background: var(--cm-surface); border-color: var(--cm-line); }
.cm-seg{
  display: inline-flex;
  background: var(--cm-bg-2);
  border: 1px solid var(--cm-line-2);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}
.cm-seg-btn{
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: none; border-radius: 8px;
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--cm-ink-3);
  cursor: pointer;
  transition: background .15s, color .15s, transform .12s;
  white-space: nowrap;
}
.cm-seg-btn:hover{ background: var(--cm-surface); color: var(--cm-ink); }
.cm-seg-btn.active{
  background: linear-gradient(135deg, #6c63ff 0%, #00d2ff 100%);
  color: #fff;
  box-shadow: 0 2px 8px -2px rgba(108,99,255,.5);
}
.cm-seg-btn.active:hover{ transform: translateY(-1px); }
.cm-seg-label{ display: inline; }
@media (max-width: 767.98px){
  .cm-list-row--theme{ align-items: flex-start; }
  .cm-seg{ margin-left: auto; }
  .cm-seg-label{ display: none; }  /* 手機只留 icon，節省空間 */
  .cm-seg-btn{ padding: 6px 10px; }
}
html[data-theme="dark"] .cm-seg{
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
}
html[data-theme="dark"] .cm-seg-btn:hover{ background: rgba(255,255,255,0.06); }

/* ============================================================
 * v14.4: Noesis 結算頁 (noesisShowResult)
 * ============================================================ */
.noesis-result-overlay{
  position: fixed; inset: 0;
  background: rgba(15, 17, 23, 0.62);
  backdrop-filter: blur(8px) saturate(140%);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity .22s ease;
  padding: 0;
}
.noesis-result-overlay.show{ opacity: 1; }
@media (min-width: 640px){
  .noesis-result-overlay{ align-items: center; padding: 2rem 1rem; }
}
.noesis-result-card{
  --rc-color: #6c63ff;
  --rc-accent: #00d2ff;
  position: relative;
  width: 100%;
  max-width: 460px;
  background: #fff;
  border-radius: 22px 22px 0 0;
  padding: 26px 22px 22px;
  box-shadow: 0 -12px 60px -10px rgba(0,0,0,.35);
  transform: translateY(40px);
  transition: transform .28s cubic-bezier(.2,.9,.3,1.1);
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.noesis-result-overlay.show .noesis-result-card{ transform: translateY(0); }
@media (min-width: 640px){
  .noesis-result-card{ border-radius: 22px; }
}

.noesis-result-close{
  position: absolute; top: 12px; right: 14px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--cm-bg-2, #F5F4EF);
  border: none; cursor: pointer;
  color: var(--cm-ink-3, #65615A);
  font-size: 14px;
  display: grid; place-items: center;
}
.noesis-result-close:hover{ background: var(--cm-line, #E6E3D9); color: var(--cm-ink, #2C2C2A); }

.noesis-result-hero{
  text-align: center;
  padding: 6px 0 18px;
  margin-bottom: 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--rc-color) 8%, #fff) 0%, color-mix(in srgb, var(--rc-accent) 6%, #fff) 100%);
}
/* color-mix fallback（不支援的瀏覽器走底色） */
@supports not (background: color-mix(in srgb, red, blue)){
  .noesis-result-hero{ background: linear-gradient(135deg, rgba(108,99,255,.08), rgba(0,210,255,.06)); }
}
.noesis-result-emoji{ font-size: 40px; line-height: 1; margin-top: 8px; }
.noesis-result-grade{
  position: absolute;
  top: 18px; left: 18px;
  min-width: 40px; height: 40px;
  padding: 0 10px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--rc-color), var(--rc-accent));
  color: #fff;
  font-weight: 800; font-size: 20px;
  display: grid; place-items: center;
  box-shadow: 0 6px 20px -6px color-mix(in srgb, var(--rc-color) 60%, transparent);
  letter-spacing: .03em;
}
.noesis-result-score{
  font-size: 44px; font-weight: 800;
  color: var(--rc-color);
  margin-top: 6px; line-height: 1;
  letter-spacing: -0.02em;
}
.noesis-result-score-sep{ opacity: .4; font-weight: 500; margin: 0 4px; }
.noesis-result-score-total{ opacity: .55; font-weight: 600; font-size: 30px; }
.noesis-result-stars{
  font-size: 22px; letter-spacing: 4px;
  color: var(--rc-color);
  margin: 8px 0 6px;
}
.noesis-result-pct{
  font-size: 17px; font-weight: 700; color: var(--cm-ink, #2C2C2A);
}
.noesis-result-pct-label{ font-weight: 500; color: var(--cm-ink-4, #888780); font-size: 13px; }
.noesis-result-msg{
  margin-top: 8px;
  font-size: 13px;
  color: var(--cm-ink-3, #65615A);
  padding: 0 16px;
}

.noesis-result-tip{
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  background: var(--cm-bg-2, #F5F4EF);
  border-radius: 12px;
  font-size: 13px;
  color: var(--cm-ink-2, #3F3D38);
  margin-bottom: 14px;
  line-height: 1.5;
}
.noesis-result-tip-icon{ font-size: 16px; flex-shrink: 0; }

.noesis-result-section{
  margin-bottom: 14px;
}
.noesis-result-section-title{
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--cm-ink-4, #888780);
  margin-bottom: 8px;
}

.noesis-result-wrongs{
  border-radius: 12px;
  background: var(--cm-bg-2, #F5F4EF);
  padding: 6px 10px;
  max-height: 200px;
  overflow-y: auto;
}
.noesis-result-wrong-row{
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px dashed var(--cm-line, #E6E3D9);
  font-size: 12.5px;
}
.noesis-result-wrong-row:last-child{ border-bottom: none; }
.noesis-result-wrong-q{
  font-weight: 600; color: var(--cm-ink, #2C2C2A);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.noesis-result-wrong-a{
  display: inline-flex; align-items: center; gap: 3px;
  white-space: nowrap; font-size: 12px;
  color: var(--cm-ink-3, #65615A);
}
.noesis-mark-o{ color: #1D9E75; font-weight: 700; }
.noesis-mark-x{ color: #E24B4A; font-weight: 700; }

.noesis-result-daily{
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
}
.noesis-result-daily > div{
  background: #fff;
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
  border: 1px solid var(--cm-line, #E6E3D9);
}
.noesis-result-daily-label{
  display: block;
  font-size: 11px; color: var(--cm-ink-4, #888780);
  margin-bottom: 4px;
}
.noesis-result-daily b{ font-size: 15px; font-weight: 700; color: var(--cm-ink, #2C2C2A); display: block; }
.noesis-result-daily em{ font-style: normal; font-size: 11px; color: var(--rc-color); font-weight: 600; }

.noesis-result-actions{
  display: flex; gap: 10px; margin-top: 6px;
}
.noesis-btn{
  flex: 1;
  padding: 13px 16px;
  border-radius: 12px;
  border: none;
  font-family: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer;
  transition: transform .12s, box-shadow .18s;
}
.noesis-btn:active{ transform: translateY(1px); }
.noesis-btn-primary{
  background: linear-gradient(135deg, var(--rc-color), var(--rc-accent));
  color: #fff;
  box-shadow: 0 8px 24px -8px color-mix(in srgb, var(--rc-color) 65%, transparent);
}
.noesis-btn-primary:hover{ box-shadow: 0 10px 28px -8px color-mix(in srgb, var(--rc-color) 70%, transparent); }
.noesis-btn-ghost{
  background: var(--cm-bg-2, #F5F4EF);
  color: var(--cm-ink-2, #3F3D38);
  border: 1px solid var(--cm-line, #E6E3D9);
}
.noesis-btn-ghost:hover{ background: var(--cm-line, #E6E3D9); }

/* 深色模式 */
html[data-theme="dark"] .noesis-result-card{
  background: #1a1c24;
  box-shadow: 0 -12px 60px -10px rgba(0,0,0,.7);
  color: #e8eaf2;
}
html[data-theme="dark"] .noesis-result-close{
  background: rgba(255,255,255,0.05); color: #b8bac3;
}
html[data-theme="dark"] .noesis-result-hero{
  background: linear-gradient(135deg, rgba(108,99,255,.18) 0%, rgba(0,210,255,.12) 100%);
}
html[data-theme="dark"] .noesis-result-pct{ color: #f2f2f4; }
html[data-theme="dark"] .noesis-result-pct-label{ color: #7b7e88; }
html[data-theme="dark"] .noesis-result-msg{ color: #b8bac3; }
html[data-theme="dark"] .noesis-result-tip{ background: rgba(255,255,255,0.04); color: #b8bac3; }
html[data-theme="dark"] .noesis-result-section-title{ color: #7b7e88; }
html[data-theme="dark"] .noesis-result-wrongs{ background: rgba(255,255,255,0.03); }
html[data-theme="dark"] .noesis-result-wrong-row{ border-bottom-color: rgba(255,255,255,0.06); }
html[data-theme="dark"] .noesis-result-wrong-q{ color: #e8eaf2; }
html[data-theme="dark"] .noesis-result-wrong-a{ color: #b8bac3; }
html[data-theme="dark"] .noesis-result-daily > div{ background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.05); }
html[data-theme="dark"] .noesis-result-daily b{ color: #f2f2f4; }
html[data-theme="dark"] .noesis-btn-ghost{
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.08);
  color: #e8eaf2;
}
html[data-theme="dark"] .noesis-btn-ghost:hover{ background: rgba(255,255,255,0.1); }

/* ============================================================
 * v14.4: 技能正確率 30 日趨勢圖
 * ============================================================ */
.noesis-trend-legend{
  display: flex; gap: 12px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--cm-ink-3, #65615A);
}
.noesis-trend-legend span{
  display: inline-flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.noesis-trend-legend i{
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
}
.noesis-trend-wrap{
  position: relative;
  width: 100%;
  height: 180px;
}
.noesis-trend-svg{
  width: 100%; height: 100%;
  color: var(--cm-ink, #2C2C2A);
  display: block;
}
.noesis-trend-empty{
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; color: var(--cm-ink-4, #888780);
  text-align: center; padding: 0 16px;
  background: linear-gradient(180deg, transparent, var(--cm-bg, #F1EFE8) 90%);
  pointer-events: none;
  border-radius: 0 0 12px 12px;
}
html[data-theme="dark"] .noesis-trend-legend{ color: #b8bac3; }
html[data-theme="dark"] .noesis-trend-svg{ color: #e8eaf2; }
html[data-theme="dark"] .noesis-trend-empty{ color: #7b7e88; background: linear-gradient(180deg, transparent, rgba(24,26,35,.9) 90%); }

/* ── v14.5 弱點雷達圖 ─────────────────────────────────────── */
.noesis-radar-card{ padding-bottom: 14px; }
.noesis-radar-wrap{
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: 4px auto 10px;
  aspect-ratio: 1 / 1;
}
.noesis-radar-svg{
  width: 100%; height: 100%;
  color: var(--cm-ink, #2C2C2A);
  display: block;
}
.noesis-radar-empty{
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; color: var(--cm-ink-4, #888780);
  text-align: center; padding: 0 22px;
  pointer-events: none;
}
.noesis-weak-suggest{
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 6px;
}
.noesis-weak-chip{
  display: inline-flex; align-items: center; gap: 6px;
  background: #FCEBEB !important; color: #A32D2D !important;
  border: 1px solid #E9B4B4 !important;
  font-weight: 600;
}
.noesis-weak-chip span{
  background: rgba(217,76,76,.12);
  color: #A32D2D;
  padding: 1px 6px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 700;
}
html[data-theme="dark"] .noesis-radar-svg{ color: #e8eaf2; }
html[data-theme="dark"] .noesis-weak-chip{
  background: rgba(217,76,76,.15) !important;
  color: #f4b6b6 !important;
  border-color: rgba(217,76,76,.4) !important;
}
html[data-theme="dark"] .noesis-weak-chip span{
  background: rgba(217,76,76,.28);
  color: #f4b6b6;
}

/* ── v14.6 拼字模式切換器 + 聽寫模式 UI ───────────────────── */
.cm-seg--spell{
  gap: 0;
  background: #F1EFE8;
  border: 1px solid #D3D1C7;
  border-radius: 99px;
  padding: 3px;
  display: inline-flex;
}
.cm-seg--spell .cm-seg-btn{
  padding: 5px 12px;
  font-size: 12.5px;
  border: none;
  background: transparent;
  color: #6e6b63;
  border-radius: 99px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  transition: all .18s ease;
}
.cm-seg--spell .cm-seg-btn.active{
  background: linear-gradient(135deg, #6c63ff 0%, #00d2ff 100%);
  color: #fff;
  box-shadow: 0 1px 4px rgba(108,99,255,.25);
}
html[data-theme="dark"] .cm-seg--spell{
  background: rgba(255,255,255,.04);
  border-color: rgba(255,255,255,.08);
}
html[data-theme="dark"] .cm-seg--spell .cm-seg-btn{ color: #b8bac3; }

.spell-dict-prompt{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 18px 14px 14px;
  background: linear-gradient(135deg, rgba(108,99,255,.06) 0%, rgba(0,210,255,.06) 100%);
  border: 1.5px dashed rgba(108,99,255,.3);
  border-radius: 16px;
}
.spell-dict-play{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  border: 2px solid #6c63ff;
  border-radius: 99px;
  background: #fff;
  color: #4A42D6;
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(108,99,255,.18);
  transition: transform .14s ease, box-shadow .14s ease;
}
.spell-dict-play:hover{
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(108,99,255,.28);
}
.spell-dict-play:active{ transform: translateY(1px); }
.spell-dict-play-icon{ font-size: 20px; line-height: 1; }
.spell-dict-meta{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.spell-dict-hint-meta{
  font-size: 12.5px;
  color: #6e6b63;
  font-weight: 500;
}
.spell-dict-pos{
  font-size: 11.5px;
  color: #888780;
  padding: 1px 8px;
  background: rgba(108,99,255,.08);
  border-radius: 99px;
}
html[data-theme="dark"] .spell-dict-prompt{
  background: linear-gradient(135deg, rgba(108,99,255,.12) 0%, rgba(0,210,255,.12) 100%);
  border-color: rgba(108,99,255,.45);
}
html[data-theme="dark"] .spell-dict-play{
  background: rgba(255,255,255,.06);
  color: #c7c2ff;
  border-color: #7d76f2;
}
html[data-theme="dark"] .spell-dict-hint-meta{ color: #b8bac3; }
html[data-theme="dark"] .spell-dict-pos{
  background: rgba(108,99,255,.18);
  color: #c7c2ff;
}

/* ── v14.7 自訂單字集批次匯入 ─────────────────────────────── */
.noesis-import-card{ padding-bottom: 14px; }
.noesis-import-actions{
  display: flex; flex-wrap: wrap; gap: 8px;
}
.noesis-import-file-btn{
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.noesis-import-textarea{
  min-height: 110px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  width: 100%;
  padding: 10px;
  border: 1px solid #D3D1C7;
  border-radius: 10px;
  background: #FFFBF2;
  color: #2C2C2A;
  resize: vertical;
  outline: none;
}
.noesis-import-textarea:focus{
  border-color: #6c63ff;
  box-shadow: 0 0 0 3px rgba(108,99,255,.12);
}
.noesis-import-preview{
  margin-top: 10px;
  padding: 10px 12px;
  background: #F6F4EA;
  border: 1px solid #D3D1C7;
  border-radius: 10px;
  font-size: 13px;
}
.noesis-import-summary{
  padding: 6px 8px;
  background: #FFFBF2;
  border-radius: 6px;
  font-size: 12.5px;
  margin-bottom: 8px;
}
.noesis-import-table-wrap{
  max-height: 260px;
  overflow: auto;
  border: 1px solid #E4E2DA;
  border-radius: 8px;
}
.noesis-import-table{
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.noesis-import-table th{
  background: #EEECE2;
  padding: 6px 8px;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 1;
}
.noesis-import-table td{
  padding: 5px 8px;
  border-top: 1px solid #E4E2DA;
}
.noesis-import-table tr.dup td{
  background: rgba(186,117,23,.08);
  color: #8a5610;
}
.noesis-import-errors{
  margin-top: 8px;
  padding: 6px 10px;
  background: #FCEBEB;
  border-radius: 8px;
  font-size: 12px;
  color: #A32D2D;
}
.noesis-import-errors summary{ cursor: pointer; font-weight: 600; }
.noesis-import-errors div{ padding: 2px 0; }
.noesis-import-confirm:disabled{
  opacity: 0.4;
  cursor: not-allowed;
}

/* Dark mode */
html[data-theme="dark"] .noesis-import-textarea{
  background: rgba(255,255,255,.04);
  border-color: rgba(255,255,255,.1);
  color: #e8eaf2;
}
html[data-theme="dark"] .noesis-import-preview{
  background: rgba(255,255,255,.03);
  border-color: rgba(255,255,255,.08);
  color: #d6d8e0;
}
html[data-theme="dark"] .noesis-import-summary{
  background: rgba(255,255,255,.04);
  color: #d6d8e0;
}
html[data-theme="dark"] .noesis-import-table-wrap{
  border-color: rgba(255,255,255,.08);
}
html[data-theme="dark"] .noesis-import-table th{
  background: rgba(255,255,255,.06);
  color: #e8eaf2;
}
html[data-theme="dark"] .noesis-import-table td{
  border-top-color: rgba(255,255,255,.06);
  color: #d6d8e0;
}
html[data-theme="dark"] .noesis-import-table tr.dup td{
  background: rgba(186,117,23,.15);
  color: #e5c286;
}
html[data-theme="dark"] .noesis-import-errors{
  background: rgba(163,45,45,.15);
  color: #f4b6b6;
}

/* ── v14.8 AI 生習題 modal ─────────────────────────────── */
.noesis-ai-actions{
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #E4E2DA;
}
.noesis-ai-btn{
  background: linear-gradient(135deg, #6c63ff 0%, #00d2ff 100%);
  color: #fff;
  border: none;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 99px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(108,99,255,.25);
}
.noesis-ai-btn:hover{ transform: translateY(-1px); box-shadow: 0 4px 12px rgba(108,99,255,.32); }
html[data-theme="dark"] .noesis-ai-actions{ border-top-color: rgba(255,255,255,.08); }

.noesis-ai-overlay{
  position: fixed; inset: 0;
  background: rgba(15,23,42,.55);
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.noesis-ai-card{
  width: min(620px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #FFFBF2;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.28);
  display: flex;
  flex-direction: column;
}
.noesis-ai-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #E4E2DA;
  position: sticky; top: 0;
  background: inherit;
  z-index: 1;
}
.noesis-ai-title{ font-size: 16px; font-weight: 700; color: #2C2C2A; }
.noesis-ai-close{
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  color: #888780;
}
.noesis-ai-close:hover{ background: rgba(0,0,0,.06); color: #2C2C2A; }
.noesis-ai-body{ padding: 18px 20px 22px; }

.noesis-ai-loading{
  text-align: center;
  padding: 14px 8px;
}
.noesis-ai-spinner{
  width: 40px; height: 40px;
  border: 3.5px solid rgba(108,99,255,.18);
  border-top-color: #6c63ff;
  border-radius: 50%;
  margin: 6px auto 12px;
  animation: noesisSpin .9s linear infinite;
}
@keyframes noesisSpin{ to{ transform: rotate(360deg); } }
.noesis-ai-wordlist{
  list-style: none;
  padding: 10px 0 0;
  margin: 0;
  font-size: 13px;
  color: #6e6b63;
}
.noesis-ai-wordlist li{ padding: 2px 0; }

.noesis-ai-error, .noesis-ai-setup, .noesis-ai-result{
  text-align: center;
  padding: 10px 6px;
}
.noesis-ai-err-icon{
  font-size: 44px;
  color: #BA7517;
  line-height: 1;
  margin-bottom: 8px;
}
.noesis-ai-err-msg{
  font-size: 14px;
  color: #A32D2D;
  font-weight: 600;
}
.noesis-ai-setup h3{
  font-size: 17px;
  margin: 4px 0 10px;
  color: #2C2C2A;
}
.noesis-ai-setup p{
  font-size: 13.5px;
  color: #6e6b63;
  margin: 8px 0;
  text-align: left;
}
.noesis-ai-code{
  background: #2C2C2A;
  color: #E8D8B0;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  text-align: left;
  line-height: 1.55;
  margin: 8px 0 12px;
}

.noesis-ai-progress{
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #6e6b63;
  margin-bottom: 12px;
}
.noesis-ai-progress b{ color: #6c63ff; font-weight: 700; }
.noesis-ai-stem{
  font-size: 16px;
  line-height: 1.65;
  padding: 14px 16px;
  background: #F6F4EA;
  border-radius: 12px;
  margin-bottom: 16px;
  color: #2C2C2A;
  min-height: 50px;
}
.noesis-ai-opts{
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.noesis-ai-opt{
  position: relative;
  text-align: left;
  padding: 12px 14px 12px 46px;
  font-size: 14px;
  border: 1.5px solid #D3D1C7;
  border-radius: 10px;
  background: #fff;
  color: #2C2C2A;
  cursor: pointer;
  transition: all .14s ease;
}
.noesis-ai-opt:hover:not([disabled]){
  border-color: #6c63ff;
  background: #F2F1FF;
}
.noesis-ai-opt .ai-opt-letter{
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #EEECE2;
  color: #6e6b63;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.noesis-ai-opt.ai-correct{
  background: #E8F5E0;
  border-color: #3B6D11;
  color: #27500A;
}
.noesis-ai-opt.ai-correct .ai-opt-letter{
  background: #3B6D11;
  color: #fff;
}
.noesis-ai-opt.ai-wrong{
  background: #FCEBEB;
  border-color: #A32D2D;
  color: #A32D2D;
}
.noesis-ai-opt.ai-wrong .ai-opt-letter{
  background: #A32D2D;
  color: #fff;
}
.noesis-ai-feedback{
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  margin-bottom: 14px;
}
.noesis-ai-feedback.ok{ background: #E8F5E0; color: #27500A; }
.noesis-ai-feedback.no{ background: #FCEBEB; color: #A32D2D; }
.noesis-ai-rationale{
  margin-top: 6px;
  font-size: 12.5px;
  opacity: .85;
  line-height: 1.55;
}
.noesis-ai-nav{
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.noesis-ai-grade{
  width: 72px; height: 72px;
  border-radius: 50%;
  font-size: 36px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px auto 8px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.noesis-ai-grade.grade-S{ background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%); color: #3A2C00; }
.noesis-ai-grade.grade-A{ background: linear-gradient(135deg, #3B6D11 0%, #55A31F 100%); }
.noesis-ai-grade.grade-B{ background: linear-gradient(135deg, #6c63ff 0%, #00d2ff 100%); }
.noesis-ai-grade.grade-C{ background: linear-gradient(135deg, #BA7517 0%, #E8A53F 100%); }
.noesis-ai-grade.grade-D{ background: linear-gradient(135deg, #A32D2D 0%, #C85555 100%); }
.noesis-ai-score{
  font-size: 18px;
  font-weight: 700;
  color: #2C2C2A;
  margin-bottom: 6px;
}

/* Dark mode for AI quiz */
html[data-theme="dark"] .noesis-ai-card{ background: #1a1d25; }
html[data-theme="dark"] .noesis-ai-head{ border-bottom-color: rgba(255,255,255,.08); }
html[data-theme="dark"] .noesis-ai-title{ color: #e8eaf2; }
html[data-theme="dark"] .noesis-ai-close{ color: #b8bac3; }
html[data-theme="dark"] .noesis-ai-close:hover{ background: rgba(255,255,255,.06); color: #e8eaf2; }
html[data-theme="dark"] .noesis-ai-stem{ background: rgba(255,255,255,.04); color: #e8eaf2; }
html[data-theme="dark"] .noesis-ai-opt{
  background: rgba(255,255,255,.03);
  color: #e8eaf2;
  border-color: rgba(255,255,255,.1);
}
html[data-theme="dark"] .noesis-ai-opt:hover:not([disabled]){
  background: rgba(108,99,255,.12);
  border-color: #6c63ff;
}
html[data-theme="dark"] .noesis-ai-opt .ai-opt-letter{
  background: rgba(255,255,255,.08);
  color: #b8bac3;
}
html[data-theme="dark"] .noesis-ai-opt.ai-correct{
  background: rgba(59,109,17,.2);
  border-color: #55A31F;
  color: #a8d98c;
}
html[data-theme="dark"] .noesis-ai-opt.ai-wrong{
  background: rgba(163,45,45,.18);
  border-color: #C85555;
  color: #f4b6b6;
}
html[data-theme="dark"] .noesis-ai-feedback.ok{ background: rgba(59,109,17,.2); color: #a8d98c; }
html[data-theme="dark"] .noesis-ai-feedback.no{ background: rgba(163,45,45,.18); color: #f4b6b6; }
html[data-theme="dark"] .noesis-ai-progress{ color: #b8bac3; }
html[data-theme="dark"] .noesis-ai-score{ color: #e8eaf2; }
html[data-theme="dark"] .noesis-ai-setup p{ color: #b8bac3; }
html[data-theme="dark"] .noesis-ai-setup h3{ color: #e8eaf2; }
html[data-theme="dark"] .noesis-ai-wordlist{ color: #b8bac3; }

/* ── 頭像選擇器 Modal ───────────────────────────────────────── */
.cm-modal-backdrop{
  position: fixed; inset: 0;
  background: rgba(15,23,42,.48);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s;
}
.cm-modal-backdrop.open{ opacity: 1; pointer-events: auto; }
.cm-modal{
  background: var(--cm-surface);
  border-radius: 16px;
  max-width: 460px;
  width: 100%;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 22px;
  box-shadow: var(--cm-shadow-lg);
}
.cm-modal-title{
  font-size: 17px;
  font-weight: 700;
  color: var(--cm-ink);
  margin-bottom: 6px;
}
.cm-modal-sub{
  font-size: 12.5px;
  color: var(--cm-ink-3);
  margin-bottom: 16px;
}
.cm-modal-close{
  position: absolute;
  top: 16px; right: 16px;
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--cm-ink-4);
}

.cm-avatar-picker{
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.cm-avatar-picker button{
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--cm-bg-2);
  border: 2px solid transparent;
  font-size: 24px;
  cursor: pointer;
  transition: all .12s;
  display: grid; place-items: center;
}
.cm-avatar-picker button:hover{ background: var(--cm-accent-soft); }
.cm-avatar-picker button.selected{
  background: var(--cm-accent-soft);
  border-color: var(--cm-accent);
  transform: scale(1.08);
}

.cm-field{
  margin-bottom: 14px;
}
.cm-field-label{
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--cm-ink-3);
  margin-bottom: 6px;
}
.cm-input{
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--cm-line);
  border-radius: 10px;
  font-size: 14px;
  color: var(--cm-ink);
  background: #fff;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  font-family: inherit;
}
.cm-input:focus{
  border-color: var(--cm-accent);
  box-shadow: 0 0 0 3px rgba(83,74,183,.12);
}

.cm-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s;
  font-family: inherit;
}
.cm-btn-primary{
  background: var(--cm-accent);
  color: #fff;
}
.cm-btn-primary:hover{ background:#3C3489; }
.cm-btn-ghost{
  background: transparent;
  color: var(--cm-ink-2);
  border-color: var(--cm-line);
}
.cm-btn-ghost:hover{ background: var(--cm-bg-2); }
.cm-btn-danger{
  background: var(--cm-danger);
  color: #fff;
}
.cm-btn-block{ width: 100%; }

.cm-btn-row{ display: flex; gap: 10px; margin-top: 10px; }

.cm-upload-hint{
  padding: 14px;
  border: 1.5px dashed var(--cm-line);
  border-radius: 10px;
  background: var(--cm-bg);
  text-align: center;
  font-size: 12.5px;
  color: var(--cm-ink-3);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all .12s;
}
.cm-upload-hint:hover{
  border-color: var(--cm-accent);
  color: var(--cm-accent);
  background: var(--cm-accent-soft);
}

/* ============================================================
 *  手機版 (< 768px)
 * ============================================================ */

@media (max-width: 767.98px){
  body.cm-mode .main-wrap{
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "topbar"
      "subjects"
      "content";
    padding-bottom: calc(var(--cm-bottom-nav-h) + env(safe-area-inset-bottom));
  }
  /* 手機版學科切換器 → 第二列（topbar 下方、content 上方）*/
  .cm-subject-switcher--mobile{ grid-area: subjects; }
  .cm-sidebar{ display: none; }
  .cm-topbar{
    padding: 0 14px;
    height: 52px;
    background: rgba(255,255,255,.95);
  }
  .cm-topbar-title{ font-size: 14px; }
  .cm-topbar .cm-chip.level{ display: none; }
  .cm-content{
    padding: 16px 14px 28px;
    max-width: 100%;
  }
  .cm-page-header{
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 14px;
    padding-bottom: 10px;
  }
  .cm-page-title{ font-size: 19px; }
  .cm-profile-hero{
    padding: 18px;
    gap: 14px;
  }
  .cm-profile-hero-name{ font-size: 18px; }
  .cm-profile-stats{ grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .cm-profile-stat{ padding: 12px 14px; }
  .cm-profile-stat-value{ font-size: 19px; }
  .cm-podium{ gap: 6px; }
  .cm-podium-slot{ padding: 12px 6px 14px; }
  .cm-podium-name{ font-size: 12px; }
  .cm-podium-score{ font-size: 16px; }
  .cm-lb-row{ grid-template-columns: 34px 1fr auto; padding: 11px 12px; }
  .cm-lb-extra{ display: none; }
  .cm-lb-user-name{ font-size: 13px; }
  .cm-avatar-picker{ grid-template-columns: repeat(5, 1fr); gap: 8px; }
  body.cm-mode .card{ padding: 14px 14px; border-radius: 10px; }
}

/* ============================================================
 *  手機底部 4 鍵導航 (覆蓋原有 .bottom-nav)
 * ============================================================ */

body.cm-mode .bottom-nav{
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  background: rgba(255,255,255,.98);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--cm-line);
  box-shadow: 0 -2px 12px rgba(15,23,42,.05);
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
  display: none;
}
@media (max-width: 767.98px){
  body.cm-mode .bottom-nav{ display: block; }
}
body.cm-mode .bottom-nav-inner{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: var(--cm-bottom-nav-h);
  max-width: 640px;
  margin: 0 auto;
}
body.cm-mode .bottom-nav-item{
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--cm-ink-3);
  cursor: pointer;
  padding-top: 8px;
  transition: color .12s;
}
body.cm-mode .bottom-nav-item.active{ color: var(--cm-accent); }
body.cm-mode .bottom-nav-item-icon{
  font-size: 20px;
  line-height: 1;
  margin-bottom: 2px;
}
body.cm-mode .bottom-nav-item.active .bottom-nav-item-icon{
  transform: translateY(-1px);
}

/* ── 手機版精簡的 topbar：顯示頁面標題+頭像 ──────────────────── */
.cm-topbar-mobile-title{
  display: none;
}
@media (max-width: 767.98px){
  .cm-topbar-mobile-title{
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: var(--cm-ink);
  }
}

/* ============================================================
 *  Leaderboard / Profile 分頁容器
 * ============================================================ */

#tab-leaderboard, #tab-profile{
  display: none;
}
body.cm-mode .tab-content{ display: none; }
body.cm-mode .tab-content.is-active{ display: block; }

/* ============================================================
 *  手機版隱藏 sidebar user-only 元素
 * ============================================================ */

@media (max-width: 767.98px){
  body.cm-mode .header-right{ display: none !important; }
}

/* ============================================================
 *  深色模式支援
 * ============================================================ */

@media (prefers-color-scheme: dark){
  body.cm-mode.dark-ready{
    --cm-surface:#1C1D21;
    --cm-bg:#16171A;
    --cm-bg-2:#232428;
    --cm-line:#2B2C31;
    --cm-line-2:#33343A;
    --cm-ink:#EDEDEF;
    --cm-ink-2:#BEBEC4;
    --cm-ink-3:#8B8C92;
    --cm-ink-4:#6B6C73;
  }
}

/* 列印 / 無障礙 */
@media (prefers-reduced-motion: reduce){
  *{ animation: none !important; transition: none !important; }
}

/* 減少原有 .app padding (為了不雙層 padding) */
body.cm-mode .screen#mainScreen{ padding: 0; }
body.cm-mode .screen.active{ display: block; }

/* ============================================================
 *  v14: 練習開始覆蓋層 (取代自動朗讀，需使用者點擊才開始)
 * ============================================================ */
.practice-start-overlay{
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(20, 22, 30, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: practiceOverlayIn .22s ease-out;
}
.practice-start-overlay.hidden{ display: none !important; }
@keyframes practiceOverlayIn{
  from { opacity: 0; }
  to   { opacity: 1; }
}
.practice-start-card{
  width: 100%;
  max-width: 420px;
  background: #FFFFFF;
  border-radius: 20px;
  padding: 36px 28px 28px;
  text-align: center;
  box-shadow: 0 28px 70px rgba(10, 14, 32, 0.35);
  animation: practiceCardIn .32s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes practiceCardIn{
  from { transform: translateY(16px) scale(.96); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.practice-start-emoji{
  font-size: 56px;
  line-height: 1;
  margin-bottom: 14px;
}
.practice-start-title{
  font-size: 20px;
  font-weight: 700;
  color: var(--cm-ink, #1F2329);
  margin-bottom: 8px;
}
.practice-start-desc{
  font-size: 13.5px;
  color: var(--cm-ink-3, #6B7280);
  line-height: 1.6;
  margin-bottom: 22px;
}
.practice-start-btn{
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #534AB7, #6E63D8);
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(83, 74, 183, 0.32);
  transition: transform .14s ease, box-shadow .14s ease;
}
.practice-start-btn:hover{
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(83, 74, 183, 0.40);
}
.practice-start-btn:active{
  transform: translateY(0) scale(.98);
}
.practice-start-tip{
  margin-top: 14px;
  font-size: 11.5px;
  color: var(--cm-ink-4, #9CA3AF);
}
/* 深色模式 */
html[data-theme="dark"] .practice-start-card{
  background: #22232B;
}
html[data-theme="dark"] .practice-start-title{ color: #F2F2F4; }
html[data-theme="dark"] .practice-start-desc{ color: #B8BAC3; }
html[data-theme="dark"] .practice-start-tip{  color: #7B7E88; }

/* ============================================================
 *  v14.1: 登入畫面 RichMark 風重設計
 *  - 深色背景 + 紫→青漸層強調
 *  - 大圓角卡片 (24px) + shadow-xl
 *  - 標題漸層文字、版號底部 footer
 *  - 只覆蓋原有 .page-bg/.login-card/.login-title/.login-tab/.btn-login …
 *    所以 HTML 結構不必更動
 * ============================================================ */
:root{
  --rm-bg: #0f1117;
  --rm-surface: #1a1d26;
  --rm-card: #242838;
  --rm-border: rgba(255,255,255,0.08);
  --rm-text: #e8e8f0;
  --rm-text-2: #a8a9b5;
  --rm-text-3: #6b6c78;
  --rm-primary: #6c63ff;
  --rm-accent: #00d2ff;
  --rm-shadow-xl: 0 30px 60px -15px rgba(0,0,0,.55), 0 0 0 1px rgba(108,99,255,.08), 0 0 40px rgba(0,210,255,.06);
  --rm-shadow-md: 0 10px 24px -6px rgba(0,0,0,.4);
  --rm-error: #ff6b82;
}
@keyframes rmModalIn{
  from{ opacity:0; transform:translateY(8px) scale(.97); }
  to  { opacity:1; transform:translateY(0)   scale(1); }
}
@keyframes rmGradShift{
  0%  { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100%{ background-position: 0% 50%; }
}

/* 外層背景：深色 + 動態漸層光暈 */
#loginScreen .page-bg{
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1200px 600px at 15% 10%, rgba(108,99,255,.18), transparent 60%),
    radial-gradient(900px 500px at 90% 90%, rgba(0,210,255,.14), transparent 55%),
    var(--rm-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
}
#loginScreen .login-wrap{
  width: 100%;
  max-width: 440px;
  position: relative;
}

/* 登入卡：大圓角 + 深色 surface + shadow-xl */
#loginScreen .login-card{
  background: var(--rm-surface);
  border: 1px solid var(--rm-border);
  border-radius: 24px;
  padding: 44px 36px 36px;
  box-shadow: var(--rm-shadow-xl);
  animation: rmModalIn .45s cubic-bezier(.2,.9,.3,1.15);
  position: relative;
  overflow: hidden;
}
#loginScreen .login-card::before{
  content:"";
  position:absolute;
  top:0; left:0; right:0;
  height:3px;
  background: linear-gradient(90deg, var(--rm-primary), var(--rm-accent), var(--rm-primary));
  background-size: 200% 100%;
  animation: rmGradShift 6s ease infinite;
  border-radius: 24px 24px 0 0;
}

/* 圖示：noesis mark — 不再是 emoji，是 CSS 漸層 badge */
#loginScreen .login-icon{
  font-size: 54px;
  text-align: center;
  margin-bottom: 10px;
  filter: drop-shadow(0 4px 14px rgba(108,99,255,.45));
}
/* noesis mark — 跨平台一致的字母 logo (取代 emoji)
   採用 Linear/Vercel 風：扁平漸層 + drop-shadow，不加反光蒙皮 */
.noesis-mark{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6c63ff 0%, #00d2ff 100%);
  color: #fff;
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-weight: 800;
  letter-spacing: -0.06em;
  user-select: none;
}
/* 大尺寸：登入畫面 */
.noesis-mark-lg{
  width: 76px;
  height: 76px;
  border-radius: 22px;
  font-size: 44px;
  line-height: 1;
  margin: 0 auto 14px;
  box-shadow:
    0 14px 30px -8px rgba(108,99,255,.55),
    0 0 0 1px rgba(255,255,255,.06) inset,
    0 0 28px rgba(0,210,255,.18);
}
/* 小尺寸：sidebar */
.noesis-mark-sm{
  width: 32px;
  height: 32px;
  border-radius: 9px;
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 4px 10px -2px rgba(108,99,255,.4);
}
/* login-icon 在 noesis-mark 模式下要完整覆蓋 vocabulary.css 的
   .login-icon { width:56px; display:flex; background:light } 預設樣式，
   否則會出現 badge 偏左 / 背景打架的狀況 */
#loginScreen .login-icon.noesis-mark{
  display: flex;                 /* 改 block-flex 讓 margin:auto 水平置中可靠 */
  width: 76px;
  height: 76px;
  border-radius: 22px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #6c63ff 0%, #00d2ff 100%);
  font-size: 44px;
  line-height: 1;
  filter: none;
  box-shadow:
    0 14px 30px -8px rgba(108,99,255,.55),
    0 0 0 1px rgba(255,255,255,.06) inset,
    0 0 28px rgba(0,210,255,.18);
}

/* 標題：漸層文字 */
#loginScreen .login-title{
  font-size: 26px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, var(--rm-primary), var(--rm-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  margin-bottom: 6px;
}
#loginScreen .login-sub{
  font-size: 13px;
  color: var(--rm-text-3);
  text-align: center;
  margin-bottom: 24px;
}

/* Tab：膠囊風，選中漸層 */
#loginScreen .login-tab-wrap{
  display: flex;
  gap: 6px;
  padding: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--rm-border);
  border-radius: 14px;
  margin-bottom: 20px;
}
#loginScreen .login-tab{
  flex: 1;
  background: transparent;
  border: none;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--rm-text-2);
  border-radius: 10px;
  cursor: pointer;
  transition: all .2s ease;
}
#loginScreen .login-tab:hover{ color: var(--rm-text); }
#loginScreen .login-tab.active{
  background: linear-gradient(135deg, var(--rm-primary), var(--rm-accent));
  color: #fff;
  box-shadow: 0 6px 16px -4px rgba(108,99,255,.45);
}

/* 表單 row */
#loginScreen .form-row{
  margin-bottom: 14px;
}
#loginScreen .form-row label{
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--rm-text-3);
  letter-spacing: 0.4px;
  margin-bottom: 6px;
  text-transform: uppercase;
}
#loginScreen .form-row input,
#loginScreen .form-row .form-select,
#loginScreen .pw-wrap input{
  width: 100%;
  padding: 13px 16px;
  background: var(--rm-card);
  border: 1px solid var(--rm-border);
  border-radius: 12px;
  color: var(--rm-text);
  font-size: 15px;
  font-family: inherit;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
  outline: none;
}
#loginScreen .form-row input::placeholder,
#loginScreen .pw-wrap input::placeholder{
  color: var(--rm-text-3);
}
#loginScreen .form-row input:focus,
#loginScreen .form-row .form-select:focus,
#loginScreen .pw-wrap input:focus{
  border-color: var(--rm-primary);
  box-shadow: 0 0 0 3px rgba(108,99,255,.18);
  background: #2a2e40;
}

/* 密碼眼睛按鈕 */
#loginScreen .pw-wrap{
  position: relative;
}
#loginScreen .pw-wrap input{
  padding-right: 46px;
}
#loginScreen .pw-eye{
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--rm-text-2);
  opacity: .7;
  transition: opacity .2s;
}
#loginScreen .pw-eye:hover{ opacity: 1; }

/* 錯誤訊息 */
#loginScreen .err-msg{
  color: var(--rm-error);
  font-size: 13px;
  margin: 4px 0 10px;
  padding: 8px 12px;
  background: rgba(255,107,130,.08);
  border: 1px solid rgba(255,107,130,.22);
  border-radius: 8px;
}
#loginScreen .err-msg.hidden{ display: none; }

/* 主按鈕：漸層填色 + 光暈 */
#loginScreen .btn-login{
  width: 100%;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--rm-primary), var(--rm-accent));
  background-size: 200% 100%;
  background-position: 0% 50%;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  margin-top: 6px;
  box-shadow: 0 10px 24px -6px rgba(108,99,255,.5);
  transition: background-position .4s ease, transform .14s ease, box-shadow .2s ease;
}
#loginScreen .btn-login:hover{
  background-position: 100% 50%;
  transform: translateY(-1px);
  box-shadow: 0 14px 30px -6px rgba(108,99,255,.6);
}
#loginScreen .btn-login:active{
  transform: translateY(0);
}
#loginScreen .btn-login:disabled{
  opacity: .6;
  cursor: not-allowed;
  transform: none;
}

/* 註冊頁輔助文字 */
#loginScreen .text-center{ text-align: center; }
#loginScreen .text-sm-muted{
  font-size: 12px;
  color: var(--rm-text-3);
}
#loginScreen .mt-10{ margin-top: 10px; }

/* 版號 footer */
.cm-login-version{
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--rm-text-3);
  letter-spacing: 0.6px;
  user-select: none;
}
.cm-login-version a{
  color: var(--rm-text-2);
  text-decoration: none;
  cursor: pointer;
}
.cm-login-version a:hover{ color: var(--rm-accent); }

/* 手機版微調 */
@media (max-width: 480px){
  #loginScreen .login-card{
    padding: 32px 22px 26px;
    border-radius: 20px;
  }
  #loginScreen .login-title{ font-size: 24px; }
  #loginScreen .login-icon.noesis-mark{
    width: 68px; height: 68px;
    border-radius: 20px;
    font-size: 40px;
    margin-bottom: 14px;
  }
  #loginScreen .login-sub{ font-size: 12.5px; margin-bottom: 20px; }
}

/* ============================================================
 *  v14.3.1 登入狀態：隱藏主 App 的底部導覽 / 版號 footer 不擋 nav
 *  - 未登入時 #loginScreen.active → 藏 .bottom-nav
 *  - 登入後 #mainScreen.active → bottom-nav 手機可見（維持原行為）
 * ============================================================ */
body.cm-mode:has(#loginScreen.active) .bottom-nav,
body.cm-mode:has(#loginScreen.active) #pwaToolbar{
  display: none !important;
}
/* 登入畫面 page-bg 不要被 bottom-nav 擠到（因為要讓 nav 藏掉，用 100vh 撐滿） */
body.cm-mode:has(#loginScreen.active) .page-bg{
  padding-bottom: env(safe-area-inset-bottom);
}
/* fallback：舊瀏覽器不支援 :has()，登入時以 JS 控制 body 新增 no-nav class */
body.no-nav .bottom-nav,
body.no-nav #pwaToolbar{
  display: none !important;
}

/* ============================================================
 *  v14.1: 更新紀錄 Modal (RichMark 風)
 * ============================================================ */
.rm-modal-overlay{
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(10,12,18,.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: rmModalIn .25s ease-out;
}
.rm-modal-overlay.hidden{ display: none !important; }
.rm-modal{
  background: var(--rm-surface, #1a1d26);
  border: 1px solid var(--rm-border, rgba(255,255,255,0.08));
  border-radius: 20px;
  padding: 28px;
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--rm-shadow-xl);
  animation: rmModalIn .35s cubic-bezier(.2,.9,.3,1.15);
}
.rm-modal h3{
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--rm-text, #e8e8f0);
  background: linear-gradient(135deg, var(--rm-primary), var(--rm-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.rm-modal-body{
  flex: 1;
  overflow-y: auto;
  padding-right: 8px;
  color: var(--rm-text-2, #a8a9b5);
  font-size: 14px;
  line-height: 1.7;
}
.rm-modal-body h2{
  color: var(--rm-text, #e8e8f0);
  font-size: 16px;
  margin: 18px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rm-border, rgba(255,255,255,.08));
}
.rm-modal-body h2:first-child{ margin-top: 0; }
.rm-modal-body h3{
  color: var(--rm-accent, #00d2ff);
  font-size: 14px;
  margin: 12px 0 4px;
  background: none;
  -webkit-text-fill-color: initial;
  font-weight: 700;
}
.rm-modal-body ul{ margin: 4px 0 10px; padding-left: 22px; }
.rm-modal-body li{ margin: 3px 0; }
.rm-modal-body code{
  background: rgba(255,255,255,.06);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.rm-modal-body::-webkit-scrollbar{ width: 8px; }
.rm-modal-body::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,.12);
  border-radius: 4px;
}
.rm-modal-close{
  margin-top: 18px;
  padding: 11px 20px;
  background: transparent;
  border: 1px solid var(--rm-border, rgba(255,255,255,.12));
  border-radius: 10px;
  color: var(--rm-text, #e8e8f0);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-end;
  transition: background .2s, border-color .2s;
}
.rm-modal-close:hover{
  background: rgba(255,255,255,.04);
  border-color: var(--rm-primary, #6c63ff);
}

/* ============================================================
 *  v14.1: PWA 更新 Toast & Loading Overlay (RichMark 風)
 * ============================================================ */
.rm-update-toast{
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 9800;
  background: var(--rm-surface, #1a1d26);
  border: 1px solid var(--rm-border, rgba(255,255,255,.1));
  border-radius: 14px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 280px;
  max-width: calc(100vw - 48px);
  box-shadow: var(--rm-shadow-xl, 0 20px 60px rgba(0,0,0,.5));
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s, transform .3s;
}
.rm-update-toast.show{
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.rm-update-toast-icon{
  font-size: 22px;
  animation: rmToastBounce 1.4s ease-in-out infinite;
}
@keyframes rmToastBounce{
  0%, 100%{ transform: translateY(0); }
  50%     { transform: translateY(-3px); }
}
.rm-update-toast-body{
  flex: 1;
  min-width: 0;
}
.rm-update-toast-title{
  font-size: 14px;
  font-weight: 700;
  color: var(--rm-text, #e8e8f0);
  margin-bottom: 2px;
}
.rm-update-toast-desc{
  font-size: 12px;
  color: var(--rm-text-3, #6b6c78);
}
.rm-update-toast-btn{
  padding: 8px 14px;
  background: linear-gradient(135deg, var(--rm-primary, #6c63ff), var(--rm-accent, #00d2ff));
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 6px 16px -4px rgba(108,99,255,.45);
  transition: transform .14s ease;
}
.rm-update-toast-btn:hover{ transform: translateY(-1px); }

.rm-update-overlay{
  position: fixed;
  inset: 0;
  z-index: 10100;
  background: rgba(10,12,18,.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
  color: var(--rm-text, #e8e8f0);
  animation: rmModalIn .25s ease-out;
}
.rm-update-overlay.hidden{ display: none !important; }
.rm-update-spinner{
  width: 56px;
  height: 56px;
  border: 3px solid rgba(108,99,255,.18);
  border-top-color: var(--rm-primary, #6c63ff);
  border-radius: 50%;
  animation: rmSpin .9s linear infinite;
}
@keyframes rmSpin{ to{ transform: rotate(360deg); } }
.rm-update-overlay-title{
  font-size: 16px;
  font-weight: 700;
  color: var(--rm-text, #e8e8f0);
}
.rm-update-overlay-desc{
  font-size: 13px;
  color: var(--rm-text-3, #6b6c78);
}

/* ═══════════════ v14.11 Math practice (Phase 2b) ═══════════════ */

/* subject-scoped wrapper — cmSwitchSubject 切換可見性 */
.practice-subject-content.hidden{ display:none !important; }

/* 主題選擇列 — topic chips */
.math-topic-chip{
  padding: 8px 14px;
  border: 1.5px solid #d4d2cb;
  border-radius: 999px;
  background: #fafaf7;
  color: #2c2c2a;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.math-topic-chip:hover{
  border-color: #6c63ff;
  background: #f3f1ff;
}
.math-topic-chip.active{
  background: linear-gradient(135deg,#6c63ff,#00d2ff);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(108,99,255,.25);
}
.math-topic-chip .math-topic-grade{
  margin-left: 6px;
  padding: 1px 6px;
  background: rgba(0,0,0,.08);
  border-radius: 8px;
  font-size: 11px;
}
.math-topic-chip.active .math-topic-grade{
  background: rgba(255,255,255,.24);
}

/* 題型徽章 */
.math-qtype-badge{
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .3px;
}
.math-qtype-badge.qt-mc        { background:#e6f3ff; color:#0055a5; }
.math-qtype-badge.qt-numeric   { background:#ffeedc; color:#7a3a00; }
.math-qtype-badge.qt-fill_blank{ background:#e6ffef; color:#005f2c; }
.math-qtype-badge.qt-steps     { background:#f3e6ff; color:#4a1a8e; }

/* 題幹 */
.math-stem{
  font-size: 20px;
  font-weight: 600;
  line-height: 1.5;
  color: #1e1e1e;
  padding: 14px 16px;
  background: #fafaf4;
  border-left: 4px solid #6c63ff;
  border-radius: 6px;
  word-break: break-word;
}

/* 進度條（通用） */
.progress-bar{
  width: 100%;
  height: 6px;
  background: #eee;
  border-radius: 3px;
  overflow: hidden;
}

/* 解答揭示 */
.answer-reveal{
  margin-top: 12px;
  padding: 12px 14px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 8px;
  color: #14532d;
  font-size: 14px;
  line-height: 1.6;
}
.answer-reveal.hidden{ display:none; }
.answer-reveal .reveal-label{
  font-weight: 700;
  margin-right: 6px;
  color: #059669;
}

/* MC 題選項 */
.math-mc-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.math-mc-option{
  padding: 14px 16px;
  border: 2px solid #e0ddd3;
  border-radius: 10px;
  background: #fff;
  color: #2c2c2a;
  font-size: 16px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all .15s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}
.math-mc-option:hover:not(:disabled){
  border-color: #6c63ff;
  background: #f7f6ff;
}
.math-mc-option .mc-letter{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eee;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.math-mc-option.selected{
  border-color: #6c63ff;
  background: #ece9ff;
}
.math-mc-option.selected .mc-letter{
  background: #6c63ff;
  color: #fff;
}
.math-mc-option.correct{
  border-color: #22c55e;
  background: #f0fdf4;
}
.math-mc-option.correct .mc-letter{
  background: #22c55e;
  color: #fff;
}
.math-mc-option.wrong{
  border-color: #ef4444;
  background: #fef2f2;
}
.math-mc-option.wrong .mc-letter{
  background: #ef4444;
  color: #fff;
}
.math-mc-option:disabled{
  cursor: not-allowed;
  opacity: .85;
}

/* Numeric 輸入 + numpad */
.math-numeric-wrap{
  margin: 14px 0;
  max-width: 360px;
}
.math-numeric-input{
  width: 100%;
  padding: 12px 14px;
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  border: 2px solid #d4d2cb;
  border-radius: 8px;
  background: #fafaf7;
  color: #1e1e1e;
  letter-spacing: 2px;
}
.math-numeric-input:focus{
  outline: none;
  border-color: #6c63ff;
  background: #fff;
}
.math-numpad{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
}
.math-numpad button{
  padding: 14px 0;
  font-size: 18px;
  font-weight: 600;
  border: 1.5px solid #d4d2cb;
  border-radius: 8px;
  background: #fff;
  color: #2c2c2a;
  cursor: pointer;
  transition: background .1s ease;
}
.math-numpad button:hover{ background: #f3f1ff; }
.math-numpad button:active{ background: #ece9ff; }
.math-numpad button.npad-op{ background:#fafaf4; color:#6c63ff; }
.math-numpad button.npad-clear{ background:#fef2f2; color:#dc2626; }

/* Fill blank */
.math-fillblank-template{
  font-size: 20px;
  font-weight: 500;
  line-height: 2;
  margin: 14px 0;
  color: #1e1e1e;
}
.math-fillblank-input{
  display: inline-block;
  min-width: 60px;
  max-width: 120px;
  padding: 6px 10px;
  margin: 0 4px;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  border: none;
  border-bottom: 2px solid #6c63ff;
  background: #f7f6ff;
  color: #1e1e1e;
  border-radius: 4px 4px 0 0;
}
.math-fillblank-input:focus{
  outline: none;
  background: #ece9ff;
  border-bottom-width: 3px;
}
.math-fillblank-input.correct{ border-color:#22c55e; background:#f0fdf4; }
.math-fillblank-input.wrong  { border-color:#ef4444; background:#fef2f2; }

/* Steps 階梯揭示 */
.math-steps-list{
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 0;
}
.math-step{
  padding: 12px 14px;
  border: 1.5px solid #e0ddd3;
  border-radius: 8px;
  background: #fafaf7;
  transition: all .2s ease;
}
.math-step.locked{
  opacity: .4;
  pointer-events: none;
  background: #f0f0eb;
}
.math-step.active{
  border-color: #6c63ff;
  background: #f7f6ff;
  box-shadow: 0 2px 8px rgba(108,99,255,.15);
}
.math-step.passed{
  border-color: #22c55e;
  background: #f0fdf4;
  opacity: .85;
}
.math-step-num{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #6c63ff;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  margin-right: 8px;
}
.math-step.passed .math-step-num{ background:#22c55e; }
.math-step.locked .math-step-num{ background:#b0b0aa; }
.math-step-prompt{
  font-size: 15px;
  color: #2c2c2a;
  margin-bottom: 8px;
}
.math-step-input{
  width: 100%;
  max-width: 220px;
  padding: 8px 12px;
  font-size: 16px;
  border: 1.5px solid #d4d2cb;
  border-radius: 6px;
  background: #fff;
}
.math-step-hint{
  margin-top: 6px;
  font-size: 12px;
  color: #8a7a5a;
  font-style: italic;
}

/* feedback 顏色（若既有 .feedback 已有定義，此處以 math 內部覆蓋） */
#mFeedback.correct{ color:#059669; font-weight:600; }
#mFeedback.wrong{   color:#dc2626; font-weight:600; }

/* ═══════════════════════════════════════════════════════════════
   v14.12 Phase 2c — Math stats 頁樣式
   ─────────────────────────────────────────────────────────────── */

/* stats-subject wrapper 與 practice-subject wrapper 用同一組邏輯 */
.stats-subject-content.hidden{ display:none !important; }

/* Mastery list */
.noesis-mastery-list{ display:flex; flex-direction:column; gap:14px; }
.noesis-mastery-row{
  padding:10px 0;
  border-bottom:1px solid #eeece4;
}
.noesis-mastery-row:last-child{ border-bottom:none; }
.noesis-mastery-head{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  margin-bottom:6px;
}
.noesis-mastery-name{
  font-size:14px;
  font-weight:600;
  color:#2c2c2a;
}
.noesis-mastery-val{
  font-size:14px;
  font-weight:700;
  color:#6c63ff;
  font-variant-numeric: tabular-nums;
}
.noesis-mastery-sub{
  margin-top:4px;
  font-size:12px;
  color:#8a867a;
}
.mastery-bar{
  height:8px;
  background:#eeece4;
  border-radius:4px;
  overflow:hidden;
}
.mastery-bar-fill{
  height:100%;
  border-radius:4px;
  transition:width .35s ease;
}
.mastery-bar-fill.good{ background:linear-gradient(90deg,#22c55e,#10b981); }
.mastery-bar-fill.mid{  background:linear-gradient(90deg,#f59e0b,#f97316); }
.mastery-bar-fill.low{  background:linear-gradient(90deg,#ef4444,#dc2626); }

/* Math weak chip — 避免與英文弱點 .noesis-weak-chip 撞名 */
.math-weak-chip{
  padding:6px 14px;
  border:1.5px solid #ef4444;
  border-radius:999px;
  background:#fef2f2;
  color:#991b1b;
  font-size:13px;
  font-weight:600;
  cursor:pointer;
  transition:transform .15s, background .15s;
}
.math-weak-chip:hover{
  background:#fee2e2;
  transform:translateY(-1px);
}
.math-weak-chip:active{
  transform:translateY(0);
}

/* 7 日答題長條圖 */
#msDailyChart{ min-height:80px; }
.noesis-dailybar{
  flex:1;
  min-width:28px;
  max-width:56px;
  border-radius:4px 4px 0 0;
  transition:height .35s ease;
}
.noesis-dailybar.bar-good{  background:linear-gradient(180deg,#34d399,#10b981); }
.noesis-dailybar.bar-mid{   background:linear-gradient(180deg,#fbbf24,#f59e0b); }
.noesis-dailybar.bar-low{   background:linear-gradient(180deg,#f87171,#ef4444); }
.noesis-dailybar.bar-empty{ background:#e6e4dc; }
.noesis-dailybar-label{
  flex:1;
  min-width:28px;
  max-width:56px;
  text-align:center;
  font-size:11px;
  color:#8a867a;
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════════════════════
   v14.16 — UI Polish Pass（設計系統統一）
   ═══════════════════════════════════════════════════════════════════════
   目標：把散落在 math / social / natural / english practice 的視覺拉齊：
   - 統一 spacing / radius / shadow / color tokens
   - ptab-bar 改 segmented-pill 風
   - question-card / option / fill-blank / progress / feedback / empty-state
     套同一套設計語言
   - 每個 subject 有自己的 accent 主色（頂端 chip / 進度條可選用）
   兼容策略：保留舊 class 名不動，直接 override；新功能才走 .nx-* helpers。
   ─────────────────────────────────────────────────────────────────────── */

:root{
  /* spacing scale (4px base) */
  --nx-space-1: 4px;
  --nx-space-2: 8px;
  --nx-space-3: 12px;
  --nx-space-4: 16px;
  --nx-space-5: 20px;
  --nx-space-6: 24px;
  --nx-space-8: 32px;
  --nx-space-10: 40px;

  /* radius */
  --nx-radius-sm: 6px;
  --nx-radius-md: 10px;
  --nx-radius-lg: 14px;
  --nx-radius-xl: 18px;
  --nx-radius-pill: 999px;

  /* elevation */
  --nx-shadow-xs: 0 1px 2px rgba(15,23,42,.04);
  --nx-shadow-sm: 0 2px 6px rgba(15,23,42,.06);
  --nx-shadow-md: 0 6px 18px rgba(15,23,42,.08);
  --nx-shadow-lg: 0 14px 40px rgba(15,23,42,.10);
  --nx-shadow-focus: 0 0 0 3px rgba(108,99,255,.22);

  /* semantic colors */
  --nx-ink-1: #111827;       /* headings */
  --nx-ink-2: #1F2329;       /* body */
  --nx-ink-3: #4B5563;       /* secondary text */
  --nx-ink-4: #6B7280;       /* tertiary / hints */
  --nx-ink-5: #9CA3AF;       /* disabled */
  --nx-surface: #FFFFFF;
  --nx-surface-2: #F7F7F5;
  --nx-surface-3: #F3F3F1;
  --nx-line: #E7E5DE;
  --nx-line-strong: #D4D2CB;

  --nx-brand: #6c63ff;
  --nx-brand-ink: #534AB7;
  --nx-brand-soft: #EEEDFE;
  --nx-brand-softer: #F5F4FF;
  --nx-accent: #00d2ff;

  --nx-ok: #10b981;
  --nx-ok-soft: #dcfce7;
  --nx-ok-ink: #065f46;
  --nx-warn: #f59e0b;
  --nx-warn-soft: #fef3c7;
  --nx-warn-ink: #92400e;
  --nx-err: #ef4444;
  --nx-err-soft: #fee2e2;
  --nx-err-ink: #991b1b;

  /* subject accents — 給 ptab-bar / topic chip / badge 用 */
  --nx-subj-english: #2563eb;
  --nx-subj-math:    #6c63ff;
  --nx-subj-social:  #d97706;
  --nx-subj-science: #059669;

  /* typography */
  --nx-text-xs: 11px;
  --nx-text-sm: 13px;
  --nx-text-base: 14px;
  --nx-text-md: 16px;
  --nx-text-lg: 18px;
  --nx-text-xl: 22px;
  --nx-text-2xl: 28px;
}

/* ────────────── Card：統一 padding + hover lift ────────────── */
body.cm-mode .card{
  background: var(--nx-surface);
  border: 1px solid var(--nx-line);
  border-radius: var(--nx-radius-lg);
  box-shadow: var(--nx-shadow-xs);
  padding: var(--nx-space-5);
  margin-bottom: var(--nx-space-4);
  transition: box-shadow .18s ease, transform .18s ease;
}
body.cm-mode .card:has(.math-mc-option:hover){
  /* MC 選項 hover 時卡片微微上浮 */
  box-shadow: var(--nx-shadow-sm);
}

/* ────────────── ptab-bar：segmented-pill ────────────── */
.ptab-bar{
  display: flex;
  gap: 4px;
  background: var(--nx-surface-3);
  padding: 4px;
  border-radius: var(--nx-radius-lg);
  margin-bottom: var(--nx-space-4);
  border: 1px solid var(--nx-line);
  box-shadow: var(--nx-shadow-xs) inset;
}
.ptab-bar-scroll{
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.ptab-bar-scroll::-webkit-scrollbar{ display:none; }
.ptab-bar-scroll .ptab-btn{
  flex: 0 0 auto;
  min-width: 100px;
  white-space: nowrap;
}
.ptab-btn{
  flex: 1;
  padding: 9px 14px;
  text-align: center;
  font-size: var(--nx-text-sm);
  border: none;
  background: transparent;
  color: var(--nx-ink-3);
  border-radius: var(--nx-radius-md);
  cursor: pointer;
  font-weight: 600;
  letter-spacing: .01em;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease, transform .15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.2;
}
.ptab-btn:hover:not(.active){
  background: rgba(255,255,255,.65);
  color: var(--nx-ink-2);
}
.ptab-btn.active{
  background: var(--nx-surface);
  color: var(--nx-ink-1);
  box-shadow: var(--nx-shadow-sm);
  border: 1px solid var(--nx-line);
}
.ptab-btn:focus-visible{
  outline: none;
  box-shadow: var(--nx-shadow-focus);
}

/* 科目範疇內 active 色（給非 english subject 的 ptab 一點辨識度） */
body[data-subject="math"]     .ptab-btn.active{ color: var(--nx-subj-math); }
body[data-subject="social"]   .ptab-btn.active{ color: var(--nx-subj-social); }
body[data-subject="science"]  .ptab-btn.active{ color: var(--nx-subj-science); }

/* ────────────── Topic chip（math / social / natural 共用）────────────── */
.math-topic-chip{
  padding: 7px 14px;
  border: 1px solid var(--nx-line-strong);
  border-radius: var(--nx-radius-pill);
  background: var(--nx-surface);
  color: var(--nx-ink-2);
  font-size: var(--nx-text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .12s ease, box-shadow .15s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.math-topic-chip:hover{
  border-color: var(--nx-brand);
  background: var(--nx-brand-softer);
  transform: translateY(-1px);
}
.math-topic-chip:active{ transform: translateY(0); }
.math-topic-chip.active{
  background: linear-gradient(135deg, var(--nx-brand), var(--nx-accent));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px -2px rgba(108,99,255,.38);
}
.math-topic-chip .math-topic-grade{
  margin-left: 4px;
  padding: 1px 7px;
  background: rgba(0,0,0,.06);
  border-radius: var(--nx-radius-pill);
  font-size: var(--nx-text-xs);
  font-weight: 600;
}
.math-topic-chip.active .math-topic-grade{
  background: rgba(255,255,255,.22);
  color: #fff;
}

.math-topic-list{
  display: flex;
  flex-wrap: wrap;
  gap: var(--nx-space-2);
}

/* ────────────── Qtype badge（題型徽章）────────────── */
.math-qtype-badge{
  padding: 4px 11px;
  border-radius: var(--nx-radius-pill);
  font-size: var(--nx-text-xs);
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  line-height: 1.4;
}
.math-qtype-badge.qt-mc        { background:#e0efff; color:#1e40af; }
.math-qtype-badge.qt-numeric   { background:#ffedd5; color:#9a3412; }
.math-qtype-badge.qt-fill_blank{ background:#dcfce7; color:#166534; }
.math-qtype-badge.qt-steps     { background:#ede9fe; color:#5b21b6; }
.math-qtype-badge.qt-short     { background:#fef3c7; color:#92400e; }
.math-qtype-badge.qt-matching  { background:#fce7f3; color:#9d174d; }

/* ────────────── Question stem（題幹）────────────── */
.math-stem{
  font-size: var(--nx-text-lg);
  font-weight: 600;
  line-height: 1.55;
  color: var(--nx-ink-1);
  padding: var(--nx-space-4) var(--nx-space-5);
  background: linear-gradient(180deg, #FBFAFF 0%, #F7F6FF 100%);
  border: 1px solid #E5E1FA;
  border-left: 4px solid var(--nx-brand);
  border-radius: var(--nx-radius-md);
  word-break: break-word;
  letter-spacing: -0.005em;
}

/* ────────────── Unified progress track ────────────── */
.nx-progress,
.progress-bar,
.math-progress-track{
  width: 100%;
  height: 8px;
  background: var(--nx-surface-3);
  border-radius: var(--nx-radius-pill);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--nx-line) inset;
}
.nx-progress-fill,
.math-progress-fill{
  height: 100%;
  background: linear-gradient(90deg, var(--nx-brand) 0%, var(--nx-accent) 100%);
  border-radius: var(--nx-radius-pill);
  transition: width .35s cubic-bezier(.2,.8,.2,1);
}

/* ────────────── MC options（選擇題）────────────── */
.math-mc-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--nx-space-3);
  margin: var(--nx-space-4) 0;
}
.math-mc-option{
  padding: 14px 16px;
  border: 1.5px solid var(--nx-line-strong);
  border-radius: var(--nx-radius-md);
  background: var(--nx-surface);
  color: var(--nx-ink-2);
  font-size: var(--nx-text-md);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .1s ease, box-shadow .15s ease;
  display: flex;
  align-items: center;
  gap: var(--nx-space-3);
  line-height: 1.45;
  min-height: 56px;
}
.math-mc-option:hover:not(:disabled){
  border-color: var(--nx-brand);
  background: var(--nx-brand-softer);
  transform: translateY(-1px);
  box-shadow: var(--nx-shadow-sm);
}
.math-mc-option:active:not(:disabled){ transform: translateY(0); }
.math-mc-option:focus-visible{
  outline: none;
  border-color: var(--nx-brand);
  box-shadow: var(--nx-shadow-focus);
}
.math-mc-option .mc-letter{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--nx-surface-3);
  color: var(--nx-ink-3);
  font-weight: 700;
  font-size: var(--nx-text-sm);
  flex-shrink: 0;
  transition: background .15s ease, color .15s ease, transform .2s ease;
}
.math-mc-option:hover:not(:disabled) .mc-letter{
  background: var(--nx-brand-soft);
  color: var(--nx-brand-ink);
}
.math-mc-option.selected{
  border-color: var(--nx-brand);
  background: var(--nx-brand-soft);
}
.math-mc-option.selected .mc-letter{
  background: var(--nx-brand);
  color: #fff;
}
.math-mc-option.correct{
  border-color: var(--nx-ok);
  background: var(--nx-ok-soft);
  animation: nxPulseOk .5s ease;
}
.math-mc-option.correct .mc-letter{
  background: var(--nx-ok);
  color: #fff;
  transform: scale(1.05);
}
.math-mc-option.wrong{
  border-color: var(--nx-err);
  background: var(--nx-err-soft);
  animation: nxShake .35s cubic-bezier(.36,.07,.19,.97);
}
.math-mc-option.wrong .mc-letter{
  background: var(--nx-err);
  color: #fff;
}
.math-mc-option:disabled{
  cursor: not-allowed;
  opacity: .8;
}

@keyframes nxPulseOk{
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,.35); }
  70%  { box-shadow: 0 0 0 10px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}
@keyframes nxShake{
  10%,90% { transform: translateX(-1px); }
  20%,80% { transform: translateX(2px); }
  30%,50%,70% { transform: translateX(-4px); }
  40%,60% { transform: translateX(4px); }
}

/* ────────────── Numeric input + numpad ────────────── */
.math-numeric-wrap{
  margin: var(--nx-space-4) 0;
  max-width: 380px;
}
.math-numeric-input{
  width: 100%;
  padding: 14px 16px;
  font-size: 26px;
  font-weight: 700;
  text-align: center;
  border: 2px solid var(--nx-line-strong);
  border-radius: var(--nx-radius-md);
  background: var(--nx-surface);
  color: var(--nx-ink-1);
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.math-numeric-input:focus{
  outline: none;
  border-color: var(--nx-brand);
  background: var(--nx-brand-softer);
  box-shadow: var(--nx-shadow-focus);
}
.math-numpad{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: var(--nx-space-3);
}
.math-numpad button{
  padding: 14px 0;
  font-size: var(--nx-text-lg);
  font-weight: 700;
  border: 1.5px solid var(--nx-line);
  border-radius: var(--nx-radius-md);
  background: var(--nx-surface);
  color: var(--nx-ink-1);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .08s ease;
  font-variant-numeric: tabular-nums;
}
.math-numpad button:hover{
  background: var(--nx-brand-softer);
  border-color: var(--nx-brand);
}
.math-numpad button:active{ transform: scale(.97); }
.math-numpad button.npad-op{
  background: var(--nx-brand-softer);
  color: var(--nx-brand-ink);
  font-weight: 800;
}
.math-numpad button.npad-clear{
  background: var(--nx-err-soft);
  color: var(--nx-err-ink);
  border-color: rgba(239,68,68,.25);
}

/* ────────────── Fill blank ────────────── */
.math-fillblank-template{
  font-size: var(--nx-text-lg);
  font-weight: 500;
  line-height: 2;
  margin: var(--nx-space-4) 0;
  color: var(--nx-ink-1);
}
.math-fillblank-input{
  display: inline-block;
  min-width: 72px;
  max-width: 140px;
  padding: 6px 10px;
  margin: 0 4px;
  font-size: var(--nx-text-md);
  font-weight: 700;
  text-align: center;
  border: none;
  border-bottom: 2px solid var(--nx-brand);
  background: var(--nx-brand-softer);
  color: var(--nx-ink-1);
  border-radius: var(--nx-radius-sm) var(--nx-radius-sm) 0 0;
  transition: background .15s ease, border-color .15s ease;
}
.math-fillblank-input:focus{
  outline: none;
  background: var(--nx-brand-soft);
  border-bottom-width: 3px;
}
.math-fillblank-input.correct{ border-color: var(--nx-ok); background: var(--nx-ok-soft); color: var(--nx-ok-ink); }
.math-fillblank-input.wrong  { border-color: var(--nx-err); background: var(--nx-err-soft); color: var(--nx-err-ink); }

/* ────────────── Steps ladder ────────────── */
.math-steps-list{
  display: flex;
  flex-direction: column;
  gap: var(--nx-space-3);
  margin: var(--nx-space-4) 0;
}
.math-step{
  padding: var(--nx-space-3) var(--nx-space-4);
  border: 1.5px solid var(--nx-line);
  border-radius: var(--nx-radius-md);
  background: var(--nx-surface);
  transition: all .2s ease;
}
.math-step.locked{
  opacity: .45;
  pointer-events: none;
  background: var(--nx-surface-3);
}
.math-step.active{
  border-color: var(--nx-brand);
  background: var(--nx-brand-softer);
  box-shadow: 0 2px 10px rgba(108,99,255,.14);
}
.math-step.passed{
  border-color: var(--nx-ok);
  background: var(--nx-ok-soft);
}
.math-step-num{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--nx-brand);
  color: #fff;
  font-size: var(--nx-text-sm);
  font-weight: 800;
  margin-right: var(--nx-space-2);
}
.math-step.passed .math-step-num{ background: var(--nx-ok); }
.math-step.locked .math-step-num{ background: var(--nx-ink-5); }
.math-step-prompt{
  font-size: 15px;
  color: var(--nx-ink-2);
  margin-bottom: var(--nx-space-2);
}
.math-step-input{
  width: 100%;
  max-width: 240px;
  padding: 10px 14px;
  font-size: var(--nx-text-md);
  border: 1.5px solid var(--nx-line-strong);
  border-radius: var(--nx-radius-sm);
  background: var(--nx-surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.math-step-input:focus{
  outline: none;
  border-color: var(--nx-brand);
  box-shadow: var(--nx-shadow-focus);
}
.math-step-hint{
  margin-top: var(--nx-space-2);
  font-size: var(--nx-text-xs);
  color: var(--nx-ink-4);
  font-style: italic;
}

/* ────────────── Feedback pill + answer reveal ────────────── */
.feedback{
  min-height: 0;
  margin-top: var(--nx-space-3);
  font-size: var(--nx-text-sm);
  font-weight: 600;
  line-height: 1.5;
  padding: 0;
  transition: all .18s ease;
}
.feedback:not(:empty){
  padding: 10px 14px;
  border-radius: var(--nx-radius-md);
  background: var(--nx-surface-3);
  color: var(--nx-ink-2);
}
.feedback.correct,
#mFeedback.correct,
#vFeedback.correct,
#sFeedback.correct,
#gFeedback.correct,
#ssFeedback.correct,
#snFeedback.correct{
  background: var(--nx-ok-soft);
  color: var(--nx-ok-ink);
  font-weight: 700;
}
.feedback.wrong,
#mFeedback.wrong,
#vFeedback.wrong,
#sFeedback.wrong,
#gFeedback.wrong,
#ssFeedback.wrong,
#snFeedback.wrong{
  background: var(--nx-err-soft);
  color: var(--nx-err-ink);
  font-weight: 700;
}

.answer-reveal{
  margin-top: var(--nx-space-3);
  padding: var(--nx-space-3) var(--nx-space-4);
  background: var(--nx-ok-soft);
  border: 1px solid rgba(16,185,129,.28);
  border-radius: var(--nx-radius-md);
  color: var(--nx-ok-ink);
  font-size: var(--nx-text-base);
  line-height: 1.6;
}
.answer-reveal.hidden{ display: none; }
.answer-reveal .reveal-label{
  font-weight: 800;
  margin-right: 6px;
  color: var(--nx-ok);
}

/* ────────────── Unified empty state ────────────── */
.nx-empty-state,
#mEmptyState,
#ssEmptyState,
#snEmptyState{
  text-align: center;
  padding: var(--nx-space-8) var(--nx-space-5);
  border: 1px dashed var(--nx-line-strong);
  border-radius: var(--nx-radius-lg);
  background: var(--nx-surface);
  box-shadow: none !important;
}
.nx-empty-icon{
  font-size: 44px;
  line-height: 1;
  margin-bottom: var(--nx-space-3);
  opacity: .78;
}
.nx-empty-title,
#mEmptyTitle,
#ssEmptyTitle,
#snEmptyTitle{
  font-size: var(--nx-text-lg);
  font-weight: 700;
  color: var(--nx-ink-1);
  margin-bottom: var(--nx-space-2);
}
.nx-empty-hint,
#mEmptyHint,
#ssEmptyHint,
#snEmptyHint{
  font-size: var(--nx-text-sm);
  color: var(--nx-ink-4);
  line-height: 1.6;
}

/* ────────────── Action row（送出/下一題 底部列）────────────── */
.nx-action-row{
  display: flex;
  align-items: center;
  gap: var(--nx-space-3);
  margin-top: var(--nx-space-5);
  padding-top: var(--nx-space-4);
  border-top: 1px solid var(--nx-line);
}
.nx-action-row .nx-spacer{ flex: 1; }
.nx-action-row .btn-back{ min-width: 96px; }
.nx-action-row .btn-primary,
.nx-action-row .btn-success{
  min-width: 140px;
  font-weight: 700;
}

/* 底部操作列的三個按鈕統一視覺重量（math/social/natural 共用） */
body.cm-mode .card .flex-between.mt-12 .btn-back,
body.cm-mode .card .flex-between.mt-12 .btn-primary,
body.cm-mode .card .flex-between.mt-12 .btn-success{
  padding: 10px 18px;
  font-size: var(--nx-text-sm);
  font-weight: 700;
  border-radius: var(--nx-radius-md);
  transition: background .15s ease, transform .12s ease, box-shadow .15s ease;
}
body.cm-mode .card .flex-between.mt-12 .btn-primary{
  background: linear-gradient(135deg, var(--nx-brand), var(--nx-accent));
  color: #fff;
  border: none;
  box-shadow: 0 4px 14px -4px rgba(108,99,255,.5);
}
body.cm-mode .card .flex-between.mt-12 .btn-primary:hover{
  transform: translateY(-1px);
  box-shadow: 0 6px 18px -4px rgba(108,99,255,.6);
}
body.cm-mode .card .flex-between.mt-12 .btn-success{
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  box-shadow: 0 4px 14px -4px rgba(16,185,129,.5);
}
body.cm-mode .card .flex-between.mt-12 .btn-success:hover{
  transform: translateY(-1px);
  box-shadow: 0 6px 18px -4px rgba(16,185,129,.6);
}
body.cm-mode .card .flex-between.mt-12 .btn-back{
  background: var(--nx-surface);
  color: var(--nx-ink-3);
  border: 1px solid var(--nx-line-strong);
}
body.cm-mode .card .flex-between.mt-12 .btn-back:hover:not(:disabled){
  background: var(--nx-surface-3);
  color: var(--nx-ink-2);
}
body.cm-mode .card .flex-between.mt-12 .btn-back:disabled{
  opacity: .5;
  cursor: not-allowed;
}

/* ────────────── Topic title row（主題卡的頭）────────────── */
.nx-section-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--nx-space-2);
  margin-bottom: var(--nx-space-3);
}
.nx-section-head .nx-section-title{
  font-size: var(--nx-text-md);
  font-weight: 700;
  color: var(--nx-ink-1);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nx-section-head .nx-section-title::before{
  content: '';
  display: inline-block;
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--nx-brand), var(--nx-accent));
}

/* ────────────── Topbar / page header polish ────────────── */
.cm-page-header{
  margin-bottom: var(--nx-space-5);
  padding-bottom: var(--nx-space-3);
}
.cm-page-title{
  font-size: var(--nx-text-2xl);
  letter-spacing: -0.02em;
}

/* ────────────── Sidebar hover / active ────────────── */
body.cm-mode .cm-nav-item{
  transition: background .15s ease, color .15s ease, transform .12s ease;
}
body.cm-mode .cm-nav-item:hover{
  background: var(--cm-accent-soft);
  color: var(--cm-accent);
}
body.cm-mode .cm-nav-item.active{
  background: var(--cm-accent-soft);
  color: var(--cm-accent);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--cm-accent);
}

/* ────────────── Bottom nav：手機更大點擊區 + active 底線 ────────────── */
@media (max-width: 860px){
  body.cm-mode .cm-bottom-nav-item{
    padding: 6px 4px 10px;
    position: relative;
  }
  body.cm-mode .cm-bottom-nav-item.active::after{
    content: '';
    position: absolute;
    top: 0;
    left: 30%;
    right: 30%;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: linear-gradient(90deg, var(--nx-brand), var(--nx-accent));
  }
}

/* ────────────── 手機適配 ────────────── */
@media (max-width: 640px){
  body.cm-mode .card{
    padding: var(--nx-space-4);
    border-radius: var(--nx-radius-md);
  }
  .math-stem{
    font-size: var(--nx-text-md);
    padding: var(--nx-space-3) var(--nx-space-4);
  }
  .math-mc-option{
    padding: 12px 14px;
    font-size: var(--nx-text-base);
    min-height: 52px;
  }
  .math-mc-grid{
    grid-template-columns: 1fr;
    gap: var(--nx-space-2);
  }
  .ptab-btn{
    padding: 8px 10px;
    font-size: var(--nx-text-xs);
  }
  .ptab-bar-scroll .ptab-btn{ min-width: 88px; }
  .nx-empty-state,
  #mEmptyState, #ssEmptyState, #snEmptyState{
    padding: var(--nx-space-6) var(--nx-space-4);
  }
}

/* ────────────── Depth compensation: when card contains mc options, add subtle inner highlight ────────────── */
body.cm-mode .card:has(#mQuestionBody),
body.cm-mode .card:has(#ssQuestionBody),
body.cm-mode .card:has(#snQuestionBody){
  box-shadow: var(--nx-shadow-sm);
}

/* ────────────── 年級篩選下拉 ────────────── */
.nx-grade-filter{
  max-width: 150px;
  padding: 7px 12px !important;
  font-size: var(--nx-text-sm) !important;
  border: 1px solid var(--nx-line-strong) !important;
  border-radius: var(--nx-radius-md) !important;
  background-color: var(--nx-surface) !important;
  color: var(--nx-ink-2) !important;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.nx-grade-filter:hover{ border-color: var(--nx-brand) !important; }
.nx-grade-filter:focus{
  outline: none;
  border-color: var(--nx-brand) !important;
  box-shadow: var(--nx-shadow-focus);
}

/* ────────────── 英文練習卡片微調（貫徹設計語言）────────────── */
body.cm-mode #tab-practice .card .word-big{
  font-size: 34px;
  font-weight: 800;
  color: var(--nx-ink-1);
  letter-spacing: -0.015em;
  line-height: 1.15;
}
body.cm-mode #tab-practice .card .phonetic{
  font-size: var(--nx-text-base);
  color: var(--nx-ink-3);
  margin-top: 4px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
body.cm-mode #tab-practice .example-box,
body.cm-mode #tab-practice .meaning-box,
body.cm-mode #tab-practice .explain-box{
  background: var(--nx-surface-2);
  border: 1px solid var(--nx-line);
  border-radius: var(--nx-radius-md);
  padding: var(--nx-space-3) var(--nx-space-4);
  color: var(--nx-ink-2);
  line-height: 1.65;
  font-size: var(--nx-text-base);
}
body.cm-mode #tab-practice .example-box{
  background: linear-gradient(180deg, #FBFAFF, #F7F6FF);
  border-color: #E5E1FA;
}
body.cm-mode #tab-practice .grammar-stem{
  font-size: var(--nx-text-lg);
  font-weight: 600;
  line-height: 1.55;
  color: var(--nx-ink-1);
  margin-bottom: var(--nx-space-4);
  padding: var(--nx-space-3) var(--nx-space-4);
  background: linear-gradient(180deg, #FBFAFF, #F7F6FF);
  border-left: 4px solid var(--nx-brand);
  border-radius: var(--nx-radius-md);
}
body.cm-mode #tab-practice .prog-wrap{
  width: 100%;
  height: 8px;
  background: var(--nx-surface-3);
  border-radius: var(--nx-radius-pill);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--nx-line) inset;
  margin-bottom: var(--nx-space-3);
}
body.cm-mode #tab-practice .prog-fill{
  height: 100%;
  background: linear-gradient(90deg, var(--nx-brand), var(--nx-accent));
  border-radius: var(--nx-radius-pill);
  transition: width .35s cubic-bezier(.2,.8,.2,1);
}

/* 英文練習選項 hover state 更清楚 */
body.cm-mode #quizOpts .card-option,
body.cm-mode #gOpts .card-option{
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
}
body.cm-mode #quizOpts .card-option:hover,
body.cm-mode #gOpts .card-option:hover{
  transform: translateY(-1px);
}

/* ────────────── Level row 等級切換列 ────────────── */
body.cm-mode .level-row{
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--nx-surface-3);
  border-radius: var(--nx-radius-md);
  border: 1px solid var(--nx-line);
}
body.cm-mode .lbtn{
  border: none;
  background: transparent;
  color: var(--nx-ink-3);
  padding: 6px 14px;
  font-size: var(--nx-text-sm);
  font-weight: 600;
  border-radius: var(--nx-radius-sm);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
body.cm-mode .lbtn:hover:not(.active){
  background: rgba(255,255,255,.7);
  color: var(--nx-ink-2);
}
body.cm-mode .lbtn.active{
  background: var(--nx-surface);
  color: var(--nx-brand-ink);
  box-shadow: var(--nx-shadow-xs);
}

/* ────────────── stats 頁卡片數字大字視覺升級 ────────────── */
body.cm-mode #tab-stats .stat-number,
body.cm-mode #tab-stats .stat-big{
  font-size: var(--nx-text-2xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--nx-ink-1);
  font-variant-numeric: tabular-nums;
}
body.cm-mode #tab-stats .stat-label{
  font-size: var(--nx-text-xs);
  color: var(--nx-ink-4);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  margin-top: 2px;
}

/* ────────────── Modal / overlay 視覺更穩 ────────────── */
body.cm-mode .modal,
body.cm-mode .sheet{
  border-radius: var(--nx-radius-xl);
  box-shadow: var(--nx-shadow-lg);
  border: 1px solid var(--nx-line);
}

/* ────────────── Print-friendly clean up ────────────── */
@media print{
  .ptab-bar, .cm-sidebar, .cm-bottom-nav{ display: none !important; }
  body.cm-mode .card{ box-shadow: none; border: 1px solid #ccc; }
}
