/* 介面稿 01～08 的版面。
 *
 * design.css 放 token 與共用元件，style.css 放引擎產出的內容（題幹、圖形、
 * 詳解、批改氣泡），這一份只放「畫面」—— 首頁的型錄、題庫的三欄、
 * 作答的側欄導覽、結果的環形分數。
 *
 * 版面一律用 grid/flex 的 auto-fit，因為介面稿的每一區都是這樣寫的：
 * 欄數由可用寬度決定，不靠斷點硬切。手機上只需要縮 gutter 與字級。
 */

/* 寬版畫面：介面稿用 1200px，站上原本的 --maxw 是 44rem（閱讀寬度）。
   題庫與分析是型錄型版面，需要寬；作答與結果的題幹仍然要窄，否則一行太長。 */
.view-wide { max-width: var(--page); }
.view-full { max-width: none; padding: 0; }
/* 側欄在窄螢幕會換行到主欄下面，這時黏在頂端沒有意義，反而會擋住內容 */
@media (max-width: 1080px) { .browse-side { position: static; } }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5);
}
.page-head h1 { font-size: 32px; }
.page-head p { margin: var(--sp-1) 0 0; }

/* 分頁列（首頁冊次、登入分頁、分析區間） */
.tabbar {
  display: flex; gap: 6px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 4px;
}
.tab {
  border: none; background: transparent; color: var(--ink-muted);
  font-weight: 800; font-size: 14px;
  padding: 8px 16px; border-radius: var(--r-pill); cursor: pointer;
}
.tab:hover { color: var(--navy); }
.tab.is-on { background: var(--navy); color: #fff; }
.tabbar-2 { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border: none; padding: 5px; }
.tabbar-2 .tab { font-size: 16px; padding: 11px; }
.tabbar-2 .tab.is-on { background: var(--surface); color: var(--navy); box-shadow: var(--sh-soft); }

/* ═════════════════════ 01 首頁 ═════════════════════ */

.land-hero {
  border-radius: var(--r-xl); overflow: hidden;
  border: 4px solid #fff; background: #fff;
  box-shadow: var(--sh-hero);
  margin-bottom: var(--sp-5);
}
.land-hero-img { display: block; width: 100%; height: auto; }

.land-cta {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-5); flex-wrap: wrap; margin-bottom: var(--sp-4);
}
.land-cta h1 { font-size: 22px; margin: 0 0 4px; }
.land-cta p { margin: 0; }
.land-cta-btns { display: flex; gap: var(--sp-3); flex-wrap: wrap; }

/* 「幫我找出弱點」的年級：記住之後是按鈕底下的一行小字，第一次按時展開成選項 */
.land-cta-act { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-2); }
.quick-grade-cur {
  background: none; border: none; padding: 0 2px; font: inherit; font-size: 13px;
  color: var(--ink-muted); cursor: pointer;
}
.quick-ask {
  flex-basis: 100%; display: grid; gap: var(--sp-3);
  padding-top: var(--sp-4); border-top: 1px solid var(--border);
}
.quick-ask-q { font-weight: 900; font-size: 17px; color: var(--ink); }
.quick-ask-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: var(--sp-3); }
.qg-opt { flex-direction: column; gap: 2px; font-size: 17px; padding: 12px 16px; line-height: 1.2; }
.qg-sub { font-size: 12px; font-weight: 700; opacity: .7; }
.qg-opt.is-on { background: var(--navy); color: #fff; border-color: var(--navy); }
.quick-ask-cancel { justify-self: start; font-size: 14px; }

.land-resume {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  background: var(--navy); color: #fff; border: none;
  border-radius: var(--radius); padding: 16px 20px; cursor: pointer;
  text-align: left; margin-bottom: var(--sp-6);
  box-shadow: 0 4px 0 var(--navy-deep);
}
.land-resume:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--navy-deep); }
.land-resume-icon { width: 38px; height: 38px; display: grid; place-items: center; flex: none;
  background: rgba(255,255,255,.14); border-radius: var(--r-xs); }
.land-resume-icon svg { width: 20px; height: 20px; stroke: #fff; fill: none; }
.land-resume-title { display: block; font-weight: 900; font-size: 17px; }
.land-resume-sub { display: block; font-size: 13px; opacity: .8; margin-top: 2px; }
.land-resume .intent-arrow { stroke: #fff; flex: none; }

.land-sec { margin-bottom: var(--sp-7); }
.land-sec-head { margin-bottom: var(--sp-4); }
.land-sec-head h2 { font-size: 30px; display: inline; margin-right: var(--sp-3); }
.land-sec-head p { display: inline; }
.land-sec-head-row { display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap; }

.grade-grid { display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grade-card { box-shadow: var(--sh-soft); }
.grade-head { display: flex; align-items: center; gap: 14px; margin-bottom: var(--sp-4); }
.grade-mark {
  width: 60px; height: 60px; border-radius: var(--r-md); flex: none;
  background: var(--navy); color: #fff; display: grid; place-items: center;
  font-weight: 900; font-size: 32px; box-shadow: 0 4px 0 var(--navy-deep);
}
.grade-name { display: block; font-weight: 900; font-size: 22px; color: var(--navy); }
.grade-desc { display: block; font-size: 14px; }
.grade-terms { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grade-term {
  border: 2px solid var(--border); background: var(--bg); color: var(--navy);
  font-weight: 800; font-size: 15px; padding: 12px; border-radius: var(--r-sm);
  cursor: pointer; text-align: left;
}
.grade-term:hover:not(:disabled) { border-color: var(--blue); background: var(--blue-tint); }
.grade-term:disabled { opacity: .45; cursor: not-allowed; }
.grade-term span { display: block; font-weight: 600; margin-top: 2px; }

.topic-grid { display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.topic-card {
  position: relative; display: flex; flex-direction: column; gap: 12px;
  background: linear-gradient(180deg, #fff 45%, var(--t-tint));
  border: 2px solid #fff; outline: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; padding-top: 52px;
  box-shadow: var(--sh-soft); cursor: pointer; text-align: left; overflow: hidden;
}
.topic-card:hover { outline-color: var(--t); }
.topic-n {
  position: absolute; top: 0; left: 0; width: 44px; height: 40px;
  background: var(--t); color: #fff; border-bottom-right-radius: 20px;
  display: grid; place-items: center; font-weight: 900; font-size: 18px;
}
.topic-name { display: block; font-weight: 900; font-size: 21px; color: var(--navy); }
.topic-en { display: block; font-weight: 800; font-size: 13px; color: var(--t-deep); }
.topic-foot { display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: auto; }
.topic-go {
  margin-left: auto;
  background: var(--cta); color: #fff; font-weight: 800; font-size: 13px;
  padding: 8px 14px; border-radius: var(--r-pill); box-shadow: 0 3px 0 var(--cta-shadow);
  white-space: nowrap;
}

.chcard-grid { display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.chcard {
  position: relative; display: flex; flex-direction: column; gap: 14px;
  background: linear-gradient(180deg, #fff 50%, var(--t-tint));
  border: 2px solid #fff; outline: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; padding-top: 52px;
  box-shadow: var(--sh-soft); overflow: hidden;
}
.chcard-badge {
  position: absolute; top: 0; left: 0; height: 40px; padding: 0 16px;
  background: var(--t); color: #fff; border-bottom-right-radius: 20px;
  display: grid; place-items: center; font-weight: 900; font-size: 15px;
}
.chcard-topic { font-weight: 800; font-size: 13px; color: var(--t-deep); }
.chcard h3 { font-size: 21px; line-height: 1.35; margin: 2px 0 0; }
.chcard-units { list-style: none; margin: 0; padding: 0 0 0 12px;
  border-left: 3px solid var(--t); display: flex; flex-direction: column; gap: 4px; }
.chcard-units li { font-size: 14px; color: var(--text-2); }
.chcard-units b { color: var(--t-deep); margin-right: 6px; }
.chcard-go { align-self: flex-end; margin-top: auto; }

.feat-grid { display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-bottom: var(--sp-6); }
.feat-n { font-weight: 900; font-size: 28px; }
.feat h3 { font-size: 19px; margin: 6px 0; }
.feat p { margin: 0; line-height: 1.7; }

/* ═════════════════════ 02 登入 / 註冊 ═════════════════════ */

.auth-split { min-height: 100vh; display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); background: var(--surface); }
.auth-aside {
  background: var(--blue-tint); padding: 32px;
  display: flex; flex-direction: column; gap: 24px; justify-content: center;
}
.auth-aside p { font-size: 15px; color: var(--navy); line-height: 1.7; margin: 0; }
.brand-row { display: flex; align-items: center; gap: 10px; cursor: pointer;
  background: none; border: none; padding: 0; font-weight: 900; font-size: 20px; color: var(--navy); }
.brand-row em { font-style: normal; color: var(--red); }
.auth-art { border-radius: var(--radius); overflow: hidden; border: 4px solid #fff;
  box-shadow: var(--sh-lift); }
.auth-art img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.auth-main { display: grid; place-items: center; padding: 40px var(--gutter); }
.auth-form-wrap { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: var(--sp-4); }
.auth-form-wrap h2 { font-size: 28px; margin: var(--sp-2) 0 0; }
.auth-form-wrap > p { margin: 0; }

/* ═════════════════════ 03 題庫 ═════════════════════ */

.browse { display: flex; flex-wrap: wrap; gap: var(--sp-5); align-items: flex-start; }
.browse-side {
  flex: 1 1 240px; max-width: 300px; position: sticky; top: 76px;
  display: flex; flex-direction: column; gap: var(--sp-5); padding: 20px;
}
.side-block { display: flex; flex-direction: column; gap: 8px; }
.side-label { font-weight: 900; font-size: 13px; color: var(--ink-muted); letter-spacing: .08em; }
.seg-tight .seg-btn { font-size: 14px; padding: 7px 14px; }
.browse-main { flex: 999 1 560px; min-width: 0;
  display: flex; flex-direction: column; gap: var(--sp-4); }

.topic-chip i { width: 10px; height: 10px; border-radius: 3px; background: var(--t); display: inline-block; }
.topic-chip.is-on { border-color: var(--t); background: var(--t-tint); }

.timeline { position: relative; display: flex; flex-direction: column; gap: 2px;
  max-height: 46vh; overflow-y: auto; }
.timeline::before { content: ''; position: absolute; left: 14px; top: 14px; bottom: 14px;
  width: 3px; background: var(--border); border-radius: 2px; }
.tl-item { position: relative; display: flex; gap: 12px; align-items: flex-start;
  border: none; background: transparent; padding: 9px 10px 9px 7px;
  border-radius: var(--r-xs); cursor: pointer; text-align: left; }
.tl-item:hover { background: var(--bg); }
.tl-dot { position: relative; z-index: 1; width: 16px; height: 16px; flex: none; margin-top: 2px;
  border-radius: 50%; border: 3px solid #9FB8DD; background: #fff; }
.tl-item:hover .tl-dot { border-color: var(--blue); }
.tl-label { font-size: 14px; line-height: 1.5; font-weight: 700; color: var(--navy); }

/* 介面稿的學期橫幅是左文右圖的兩欄；欄寬不夠時自動疊成一欄。 */
.browse-banner {
  background: var(--t-tint); border: 2px solid #fff; border-radius: var(--r-xl);
  padding: 24px; box-shadow: var(--sh-soft);
  display: grid; gap: 24px; align-items: center;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.bn-crumb { font-size: 14px; font-weight: 800; color: var(--t-deep); }
.browse-banner h1 { font-size: 34px; line-height: 1.2; margin: 8px 0 4px; }
.browse-banner p { margin: 0 0 12px; }
.bn-prog { display: flex; align-items: center; gap: 12px; }
.bn-prog .bar { flex: 1; max-width: 260px; height: 10px; background: rgba(255,255,255,.9); }
.bn-prog .bar > i { background: var(--t); }
.bn-prog-label { font-weight: 800; font-size: 14px; color: var(--navy); }

.chsec { padding: 0; overflow: hidden; border: 2px solid var(--border); }
.chsec-head { padding: 20px; border-bottom: 1px solid var(--border-lite); }
.chsec-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.chsec-badge { background: var(--t); color: #fff; font-weight: 900; font-size: 13px;
  padding: 4px 12px; border-radius: var(--r-pill); }
.chsec-head h2 { font-size: 26px; line-height: 1.3; margin-bottom: 10px; }
.chsec-prog { display: flex; align-items: center; gap: 10px; }
.chsec-prog .bar { flex: 1; max-width: 240px; }

.unit-rows { display: flex; flex-direction: column; }
.unit-row2 {
  display: grid; align-items: center; gap: 16px;
  grid-template-columns: 56px minmax(140px, 1fr) minmax(120px, 180px) 80px auto;
  padding: 14px 20px; border-top: 1px solid var(--surface-3);
}
.unit-row2:hover { background: var(--surface-2); }
.u-code { font-weight: 900; font-size: 15px; color: var(--ink-faint); }
.u-name { font-weight: 800; font-size: 16px; color: var(--ink); }
.u-bar { display: flex; align-items: center; gap: 8px; }
.u-bar .bar { flex: 1; }
.u-pct { font-weight: 800; font-size: 13px; color: var(--ink-muted); width: 36px; text-align: right; }

.scope-bar { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding-top: var(--sp-3); }

/* ═════════════════════ 04 測驗設定 ═════════════════════ */

.crumb { display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  font-size: 14px; font-weight: 700; color: var(--ink-muted); margin-bottom: var(--sp-4); }
.crumb button { border: none; background: none; color: var(--blue-deep);
  font: inherit; cursor: pointer; padding: 0; }
.crumb b { color: var(--navy); }

.setup { display: grid; gap: var(--sp-5); align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.setup-unit { border-top: 6px solid var(--t); box-shadow: var(--sh-soft); }
.su-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.setup-unit h1 { font-size: 32px; margin-bottom: 6px; }
.su-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: var(--sp-4); }
.su-stats > div { background: var(--bg); border-radius: var(--r-sm); padding: 14px; }
.su-stats b { display: block; font-weight: 900; font-size: 24px; color: var(--navy); margin-top: 2px; }

.setup-side { display: flex; flex-direction: column; gap: var(--sp-4); }
.setup-form { box-shadow: var(--sh-soft); }
.setup-form h2 { font-size: 22px; margin-bottom: var(--sp-4); }
.field-block { margin-bottom: var(--sp-4); }
.field-label { font-weight: 800; font-size: 14px; color: var(--ink-muted); margin-bottom: 8px; }
.field-block p { margin: 8px 0 0; }
.seg-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.seg-grid-2 .seg-btn, .seg-grid-3 .seg-btn, .seg-grid-4 .seg-btn { border-radius: var(--r-sm); padding: 12px 4px; }

/* 綜合測驗・不分版本（選範圍頁最上面）。窄螢幕時按鈕換行，不橫向捲動 */
.mix-card { display: grid; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.mix-card h2 { font-size: 20px; margin: 0 0 4px; }
.mix-card p { margin: 0; }
.mix-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.mix-btns .btn { min-width: 0; }

/* 錯題本（學習分析頁最上面） */
.wrong-book .an-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.wb-rows { display: flex; flex-direction: column; margin-top: var(--sp-3); }
.wb-row { display: flex; align-items: center; gap: var(--sp-3); padding: 10px 0; border-top: 1px solid var(--border-lite); }
.wb-row .grow { min-width: 0; }
.wb-row .code { font-weight: 800; margin-right: 4px; }
#wrong-card { margin-top: var(--sp-3); }
.wb-all { margin-top: var(--sp-3); }
.wb-all summary { cursor: pointer; font-weight: 700; }
.lm-group { margin: var(--sp-4) 0 var(--sp-2); font-size: 15px; }
.lm-rows { display: flex; flex-direction: column; }
.lm-row { display: flex; align-items: center; gap: var(--sp-3); padding: 10px 0; border-top: 1px solid var(--border-lite); }
.lm-row .grow { min-width: 0; }
ul.plain { margin: 0; padding-left: 1.2em; }
.rv-unsure { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700;
  color: var(--ink-muted); border: 1px solid var(--border); white-space: nowrap; }

.uh-rows { display: flex; flex-direction: column; }
.uh-row { display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-top: 1px solid var(--border-lite); font-size: 14px; }

/* ═════════════════════ 05 作答 ═════════════════════ */

.quizbar { position: sticky; top: 0; z-index: 30;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.quizbar-in { display: flex; align-items: center; gap: var(--sp-4);
  flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.quizbar-prog { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 6px; }
.quizbar-meta { display: flex; justify-content: space-between; gap: var(--sp-3);
  font-size: 14px; font-weight: 800; color: var(--navy); }
.quizbar .progress { height: 10px; border-radius: var(--r-pill); background: var(--border-lite); }
.quizbar .progress-fill { background: var(--green); border-radius: inherit; transition: width .3s; }
.quiz-timer { font-weight: 900; font-size: 20px; color: var(--navy);
  background: var(--bg); padding: 8px 14px; border-radius: var(--r-xs); }

.quiz-body { display: flex; flex-wrap: wrap; gap: var(--sp-5);
  align-items: flex-start; padding-top: var(--sp-5); padding-bottom: var(--sp-7); }
.quiz-body .question { flex: 999 1 560px; min-width: 0; padding: 32px;
  border-radius: var(--r-xl); box-shadow: var(--sh-soft); }
.quiz-side { flex: 1 1 260px; max-width: 340px; position: sticky; top: 88px;
  display: flex; flex-direction: column; gap: var(--sp-4); }
.quiz-side h3 { font-size: 17px; }
.quiz-side .dots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.quiz-side .dot { width: 100%; aspect-ratio: 1; margin: 0; }
.qnav-legend { display: flex; flex-direction: column; gap: 8px;
  font-size: 13px; color: var(--ink-muted);
  border-top: 1px solid var(--border-lite); padding-top: 14px; }
.qnav-legend span { display: flex; align-items: center; gap: 8px; }
.qnav-legend i { width: 14px; height: 14px; border-radius: 5px; flex: none; }
.lg-done { background: var(--navy); }
.lg-cur { border: 3px solid var(--orange); }
.lg-mark { background: var(--amber); border-radius: 50% !important; }
.quiz-side-actions { display: flex; flex-direction: column; gap: 8px; }
#btn-mark.is-marked { border-color: var(--amber); background: var(--amber-tint); color: var(--orange-deep); }
.dot.marked::before {
  content: ''; position: absolute; top: -5px; right: -5px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--amber); border: 2px solid var(--surface);
}

/* ═════════════════════ 響應式 ═════════════════════ */

@media (max-width: 900px) {
  .browse-side, .quiz-side { position: static; max-width: none; }
  .timeline { max-height: 32vh; }
}
@media (max-width: 640px) {
  .page-head h1, .setup-unit h1 { font-size: 26px; }
  .land-sec-head h2 { font-size: 24px; }
  .browse-banner h1 { font-size: 26px; }
  .unit-row2 { grid-template-columns: 44px 1fr auto; row-gap: 8px; }
  .unit-row2 .u-bar { grid-column: 1 / -1; }
  .unit-row2 .pill-mastery { display: none; }
  .su-stats { grid-template-columns: 1fr; }
  .quiz-body .question { padding: 20px; }
}

/* 側欄很窄（300px），六個冊次用 flex 會斷成「一／上」兩行。
   固定三欄就穩定了，而且上下學期剛好對齊成兩列。 */
#seg-book { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#seg-book .seg-btn { padding: 8px 2px; font-size: 14px; white-space: nowrap; }
#seg-publisher { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#seg-publisher .seg-btn { padding: 8px 2px; white-space: nowrap; }
.unit-row2 .btn { white-space: nowrap; }

/* 主視覺：介面稿的橫幅，原生 2000×1091。版面最寬 1200px，所以 1x 給 1200、
   2x 直接給原生的 2000 —— 放大到 2400 只是把像素撐開，不會更清楚。 */
.land-hero-img { width: 100%; height: auto; aspect-ratio: 2000 / 1091; }

/* 登入頁左欄用同一張圖裁成 4:3。焦點稍微偏上，避免把標題切掉。 */
.auth-art img { object-position: 50% 42%; }

/* ═════════════════════ 插圖槽 ═════════════════════
 *
 * 介面稿每個型錄式畫面都留了插圖位（<image-slot>）：主題卡與章節卡 4:3、
 * 學期橫幅與單元卡 16:9。站上目前只有六張插圖，其餘還沒畫。
 *
 * 空著不放，等圖做好再塞，版面會整個重排；所以照介面稿的做法先把空間占住，
 * 並在裡面寫清楚這一格要放什麼 —— 對維護的人來說這比一塊灰色佔位有用得多。
 */
.img-slot {
  position: relative;
  width: 100%;
  aspect-ratio: var(--ar, 4 / 3);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--t-tint, var(--surface-3));
  display: grid; place-items: center;
  flex: none;
}
.img-slot.is-empty {
  border: 2px dashed var(--border-strong);
  background: repeating-linear-gradient(45deg,
    var(--surface-2) 0 10px, var(--surface-3) 10px 20px);
}
.img-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-slot span {
  padding: 6px 10px; text-align: center;
  font-size: 12px; font-weight: 800; line-height: 1.4;
  color: var(--faint);
}
.img-slot-16x9 { --ar: 16 / 9; }
.img-slot-4x3  { --ar: 4 / 3; }

/* 題庫章節卡左邊的縮圖：介面稿是固定 200px 寬的方塊 */
.chsec-thumb { width: 200px; flex: none; background: var(--t-tint);
  border-radius: var(--r-md); padding: 6px; }
.chsec-thumb .img-slot { border-radius: var(--r-sm); }
.chsec-head { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.chsec-head > .chsec-copy { flex: 1; min-width: 200px; }

/* 測驗設定的單元卡：介面稿把插圖放在卡片頂端、襯一塊主題色底 */
.setup-unit { padding: 0; overflow: hidden; }
.su-art { background: var(--t-tint); padding: 20px; }
.su-body { padding: 24px; }

/* 首頁的主題卡與章節卡：插圖在標題上方 */
.topic-card .img-slot, .chcard .img-slot { margin-bottom: 2px; }

@media (max-width: 640px) {
  .chsec-thumb { width: 100%; }
}

/* 首頁「課程章節」的兩排分頁：上排版本、下排冊次。
   窄螢幕時靠左，才不會跟左邊的標題擠在同一行中間。 */
.land-picker { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
@media (max-width: 720px) { .land-picker { align-items: flex-start; width: 100%; } }

/* ═════════════════════ 頂部欄 ═════════════════════
 *
 * 介面稿有兩種：首頁版（品牌帶副標、右邊兩顆 CTA）與內頁版（中間分頁導覽、
 * 右邊使用者）。差異只有三處，所以用同一份 DOM 配 data-nav 切換，
 * 不做成兩條 header —— 兩條 header 會讓捲動時的 sticky 疊在一起閃一下。
 */
.topbar {
  position: sticky; top: 0; z-index: 30;
  /* style.css 的舊版 .topbar 是 flex 且自帶 padding —— 那會讓 .topbar-in
     變成 flex item 而縮成內容寬度，整排擠在畫面正中間。橫幅本身要滿版，
     置中的是裡面那層，所以這裡要把 display 與 padding 都收回來。 */
  display: block; padding: 0;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-in {
  max-width: var(--page); margin: 0 auto;
  padding: 10px var(--gutter);
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.topbar[data-nav="landing"] .topbar-in { padding-top: 12px; padding-bottom: 12px; }
.topbar[data-nav="app"] .topbar-in { gap: 28px; }

.brand-btn {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; padding: 0; cursor: pointer;
}
.brand-mark {
  width: 40px; height: 40px; border-radius: var(--r-xs); flex: none;
  background: var(--navy); color: #fff;
  display: grid; place-items: center;
  font-weight: 900; font-size: 19px;
  box-shadow: 0 3px 0 var(--navy-deep);
}
.brand-text { display: flex; flex-direction: column; align-items: flex-start; }
.brand-name { font-weight: 900; font-size: 18px; color: var(--navy); letter-spacing: .02em; }
.brand-name em { font-style: normal; color: var(--red); }
.brand-sub { font-size: 11px; color: var(--muted); font-weight: 700; }
/* 副標只在首頁版出現 —— 內頁的品牌要讓位給導覽 */
.topbar[data-nav="app"] .brand-sub { display: none; }

/* 導覽只在內頁版出現；首頁版右邊要靠底，所以品牌之後補一個彈性空白 */
.topbar[data-nav="landing"] .topnav { display: none; }
.topnav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; margin: 0; }
.topnav-link {
  border: none; background: transparent; color: var(--navy);
  font-weight: 800; font-size: 15px;
  padding: 9px 16px; border-radius: var(--r-pill); cursor: pointer;
}
.topnav-link:hover { background: var(--blue-tint); }
.topnav-link.is-on { background: var(--navy); color: #fff; }

.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar-right .btn { white-space: nowrap; }

/* 使用者晶片：右對齊的姓名與方案，加一個圓形頭像 */
.user-chip {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; padding: 4px; cursor: pointer;
  border-radius: var(--r-pill);
}
.user-chip:hover { background: var(--blue-tint); }
.user-meta { display: flex; flex-direction: column; align-items: flex-end; }
.user-name { font-weight: 800; font-size: 14px; color: var(--navy); }
.user-plan { font-size: 12px; color: var(--muted); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  background: var(--orange-tint); border: 2px solid var(--orange);
  display: grid; place-items: center;
  font-weight: 900; color: var(--orange-deep);
}
.user-chip.is-paid .avatar { background: var(--green-tint); border-color: var(--green); color: var(--green-deep); }

@media (max-width: 640px) {
  .topbar[data-nav="app"] .topbar-in { gap: 12px; }
  .topnav { order: 3; width: 100%; flex: none; }
  .topnav-link { font-size: 14px; padding: 7px 12px; }
  .user-meta { display: none; }
  .brand-sub { display: none; }
}

/* 主題卡的副標：標出這個五大主題涵蓋哪些 108 主軸。
   兩套分類都是真的（五大主題來自九年一貫與會考，n/g/s/a/f/d 來自 108 課綱），
   把對應寫在卡片上，使用者才不必自己猜兩邊怎麼接。 */
.topic-covers {
  display: block; margin-top: 4px;
  font-size: 12px; font-weight: 700; line-height: 1.45;
  color: var(--ink-muted);
}

/* 分析頁「主題能力」的標題列：標題在左、分類切換在右 */
.an-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3);
}
.an-card-head h3 { margin: 0; }
.an-card-head .tabbar { padding: 3px; }
.an-card-head .tab { font-size: 13px; padding: 6px 12px; }
.an-note { margin: var(--sp-3) 0 0; padding-top: var(--sp-3);
  border-top: 1px solid var(--border-lite); line-height: 1.7; }

/* =====================================================================
   題目問題回報
   =====================================================================
   用原生 <dialog>，所以 Esc 關閉、焦點鎖在對話框裡、背景不能點
   這三件事都不必自己寫。 */
.dlg {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(32rem, calc(100vw - 32px));
  width: 100%;
}
.dlg::backdrop { background: rgb(15 37 72 / .45); }

.dlg-box {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 12px 32px rgb(15 37 72 / .18);
}
.dlg-title { margin: 0; font-size: 1.1rem; color: var(--navy); }
.dlg-note  { margin: 0; font-size: .85rem; color: var(--ink-muted); line-height: 1.6; }

.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fld-label { font-size: .82rem; color: var(--ink-muted); }
.fld-label span { font-weight: 400; }
.fld-input {
  font: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
  box-sizing: border-box;
}
textarea.fld-input { resize: vertical; min-height: 5.5em; line-height: 1.6; }
.fld-input:focus-visible { outline: 2px solid var(--navy); outline-offset: 1px; }

/* honeypot：真人看不到，機器人會填。不能用 display:none —— 有些機器人
   會跳過隱藏欄位，反而失去辨識力。 */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.dlg-msg { margin: 0; font-size: .85rem; min-height: 1.2em; }
.dlg-msg.is-ok  { color: #1F6B55; }
.dlg-msg.is-bad { color: #A8322B; }

.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

@media (max-width: 420px) {
  .dlg-box { padding: 16px; border-radius: 10px; }
  .dlg-actions .btn { flex: 1 1 auto; }
}

/* ═════════════════════ 訂閱方案 ═════════════════════
   價格卡兩張並排；年訂那張加框線與「最划算」標籤。手機寬度下自動疊成一欄。 */

.land-plans {
  display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap;
  margin-bottom: var(--sp-6); border: 2px solid var(--cta-tint);
}
.land-plans h2 { margin: 0 0 4px; font-size: 20px; }
.land-plans p { margin: 0; }
.land-plans .grow { flex: 1 1 260px; min-width: 0; }

.plans-head { text-align: center; margin: var(--sp-4) auto var(--sp-5); max-width: 640px; }
.plans-head h1 { font-size: 26px; margin: 0 0 6px; text-wrap: balance; }
.plans-head p { margin: 0; line-height: 1.7; }
.plans-status {
  display: inline-block; margin-top: var(--sp-3) !important; padding: 8px 16px;
  border-radius: var(--r-pill); background: var(--blue-tint); color: var(--blue-deep);
  font-weight: 700;
}
.plans-status.is-ok { background: var(--green-tint); color: var(--green-deep); }
.plans-status.is-bad { background: var(--red-tint); color: var(--red-deep); }

.plans-grid {
  display: grid; gap: var(--sp-4); margin: 0 auto var(--sp-5); max-width: 760px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.plan-card {
  position: relative; display: flex; flex-direction: column; gap: var(--sp-2);
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--r-lg);
  padding: 24px 22px 20px; min-width: 0;
}
.plan-card.is-best { border-color: var(--cta); box-shadow: 0 6px 0 var(--cta-tint); }
.plan-tag {
  position: absolute; top: -13px; left: 50%; transform: translateX(-50%);
  background: var(--cta); color: #fff; font-weight: 800; font-size: 13px;
  padding: 3px 12px; border-radius: var(--r-pill); white-space: nowrap;
}
.plan-name { font-weight: 800; font-size: 18px; color: var(--navy); }
.plan-price { font-family: 'Nunito', 'Noto Sans TC', sans-serif; font-weight: 900;
  font-size: 34px; color: var(--ink); font-variant-numeric: tabular-nums; }
.plan-price small { font-size: 15px; font-weight: 700; color: var(--ink-muted); margin-left: 2px; }
.plan-sub { color: var(--ink-muted); font-size: 14px; min-height: 1.6em; }
.plan-card .btn { margin-top: auto; }

/* 首批會員優惠：方案頁上方的說明、年訂卡上劃掉的原價、帳號頁與首頁方案卡的那一行 */
.plans-founder {
  max-width: 760px; margin: 0 auto var(--sp-5); padding: 12px 18px;
  border: 1px solid var(--amber-bd); border-radius: var(--r-md);
  background: var(--amber-tint); color: var(--ink); line-height: 1.75; text-align: center; text-wrap: pretty;
}
.plans-founder b, .land-plans-offer b { color: var(--orange-deep); }
.plans-founder .linklike { margin-left: 4px; }
.plan-was {
  margin-left: 10px; font-size: 16px; font-weight: 700; color: var(--ink-faint);
  text-decoration: line-through;
}
.land-plans .land-plans-offer { margin-top: 6px; color: var(--ink); line-height: 1.7; }
.founder-line { color: var(--orange-deep); font-weight: 700; }

.plans-incl { max-width: 760px; margin: 0 auto var(--sp-4); }
.plans-incl h2 { font-size: 18px; margin: 0 0 var(--sp-2); }
.plans-list { margin: 0; padding-left: 1.2em; line-height: 1.9; }

.plans-agree {
  display: flex; gap: var(--sp-2); align-items: flex-start; max-width: 760px;
  margin: 0 auto var(--sp-3); font-size: 14px; line-height: 1.7; color: var(--ink);
  cursor: pointer;
}
.plans-agree input { margin-top: 5px; flex: none; width: 18px; height: 18px; }
#plans-err, .plans-foot { max-width: 760px; margin-left: auto; margin-right: auto; }
.plans-foot { line-height: 1.7; }

.acct-billing {
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2);
  padding: 14px 16px; margin: var(--sp-3) 0; display: flex; flex-direction: column; gap: 8px;
}
.acct-billing p { margin: 0; line-height: 1.6; }
.acct-billing .warn-line { color: var(--orange-deep); font-weight: 700; }
.acct-billing .btn { align-self: flex-start; }
/* 刪除帳號（兩步驟確認） */
.acct-danger { margin-top: var(--sp-4); text-align: center; font-size: 14px; }
.acct-delete {
  margin-top: var(--sp-3); text-align: left; padding: 14px 16px; line-height: 1.6;
  border: 1px solid var(--orange-deep); border-radius: var(--r-md); background: var(--surface-2);
}
.acct-delete h3 { margin: 0 0 6px; font-size: 16px; }
.acct-delete p, .acct-delete ul { margin: 6px 0; }
.acct-delete ul { padding-left: 1.2em; }
.acct-delete .warn-line { color: var(--orange-deep); font-weight: 700; }
.acct-delete-btns { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.acct-delete .btn.danger { background: var(--orange-deep); border-color: var(--orange-deep); color: #fff; }
/* AI 功能本月額度 */
.acct-ai-head { margin: 6px 0 0; font-weight: 700; }
.acct-ai { margin: 0; padding-left: 1.2em; line-height: 1.7; }
.tutor-quota { margin: 6px 0 0; }

.quota-note { text-align: center; margin: var(--sp-2) 0 0; }
.linklike {
  background: none; border: none; padding: 0; font: inherit; color: var(--blue-deep);
  text-decoration: underline; cursor: pointer;
}

/* ═════════════════ 信箱驗證與忘記密碼 ═════════════════ */

.auth-links { display: flex; justify-content: center; gap: var(--sp-4); margin-top: var(--sp-3); font-size: 14px; }
.acct-verify { display: grid; gap: 4px; }
.acct-verify p { margin: 0; line-height: 1.6; }
.acct-verify .warn-line { color: var(--orange-deep); font-weight: 700; }

/* 頂端列下面的提醒。不蓋住內容，也不擋作答。 */
.mail-banner {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3);
  padding: 10px 44px 10px var(--sp-4); position: relative;
  background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--border);
  font-size: 14px; font-weight: 700; text-align: center;
}
.mail-banner .linklike { color: inherit; font-weight: 800; }
.mail-banner-x {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: none; background: none; border-radius: 50%;
  font-size: 20px; line-height: 1; color: inherit; cursor: pointer;
}
.mail-banner-x:hover { background: rgba(0, 0, 0, .06); }

/* 短暫的操作回饋（寄出了、驗證完成了）。不需要使用者按任何東西。 */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 60; max-width: min(92vw, 520px); padding: 12px 18px;
  background: var(--navy); color: #fff; border-radius: var(--r-md);
  box-shadow: 0 6px 24px rgba(15, 37, 72, .35);
  font-size: 15px; font-weight: 700; line-height: 1.5; text-align: center;
}
@media print { .mail-banner, .toast { display: none !important; } }

/* 經營者與聯絡方式（頁尾、方案頁） */
.footer-co { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; color: var(--muted); }
.footer-co b { color: var(--text-2); letter-spacing: .06em; }
.footer-co a, .plans-foot a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.footer-legal { color: var(--muted); }
.footer-legal a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.footer-legal span { margin: 0 6px; }
.plans-foot b { color: var(--text-2); }

/* ═════════════════ 開站中 ═════════════════
   首頁在 HTML 裡就先顯示（主視覺不必等 JS 與題庫索引）。事件綁好之前按鈕按了沒反應，
   先淡掉、不能按，免得看起來像壞掉；app.js 的 boot() 綁好後拿掉 html.is-booting。 */
.is-booting .land-cta-act,
.is-booting .topbar-right,
.is-booting .parent-card { opacity: .55; pointer-events: none; }

/* 首頁「不用註冊，可以先免費試做 3 題」 */
.land-trial-note { margin: 0; font-size: 14px; font-weight: 800; color: var(--ok); }

/* ═════════════════ 給家長：範例診斷、傳給孩子 ═════════════════ */
.parent-card {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: var(--sp-4) var(--sp-5); margin-bottom: var(--sp-4);
}
.parent-copy { flex: 1 1 300px; min-width: 0; }
.parent-copy h2 { font-size: 18px; margin: 0 0 4px; }
.parent-copy p { margin: 0; }
.parent-act { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-3); }
.share-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
/* LINE 的品牌綠，一眼認得出是「傳到 LINE」 */
.btn.share-line { background: #06C755; border-color: #06C755; color: #fff; text-decoration: none; }
.btn.share-line:hover { background: #05B34C; border-color: #05B34C; }

/* 體驗題組做完的註冊卡 */
.trial-cta { margin-bottom: var(--sp-4); border: 2px solid var(--cta); }
.trial-cta h2 { margin: var(--sp-1) 0 var(--sp-2); font-size: var(--fs-xl); }
.trial-cta p { margin: 0 0 var(--sp-3); }

/* 範例診斷的頁首：一眼看得出這不是誰真的考的 */
.sample-banner {
  display: flex; gap: var(--sp-4); align-items: flex-start; margin-bottom: var(--sp-4);
  border: 2px dashed var(--border-strong);
}
.sample-tag {
  flex: none; padding: 4px 12px; border-radius: var(--r-pill);
  background: var(--warn-soft); color: var(--warn); font-weight: 900; font-size: 13px;
}
.sample-copy { min-width: 0; }
.sample-copy h2 { font-size: 18px; margin: 0 0 4px; }
.sample-copy p { margin: 0 0 var(--sp-3); }
@media (max-width: 560px) { .sample-banner { flex-direction: column; gap: var(--sp-2); } }
@media print { .share-row { display: none !important; } }

/* ═════════════ 廣告訪客的家長版第一屏 ═════════════
   index.html 頁首的小段程式在第一次繪製前就決定 html.from-ad，兩個版本不會閃來閃去。
   家長版已經把「看範例」「傳給孩子」放在第一屏，下面那張家長卡片就不再重複。 */
html:not(.from-ad) .ad-only { display: none !important; }
.from-ad .default-only { display: none !important; }
.from-ad #parent-card { display: none !important; }
.ad-share { display: grid; gap: 6px; }
.ad-about { margin-top: var(--sp-3, 12px); }
.ad-about a { color: inherit; text-decoration: underline; }
