/* ═══════════════════════════════════════════
   樂透統計學 APP 使用說明書 — 共用樣式
   與官網、功能手冊同一套淺色風格
   ═══════════════════════════════════════════ */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-soft: #475569;
  --text-muted: #94a3b8;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --orange: #f97316;
  --orange-soft: #fff7ed;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --red: #e11d48;
  --red-soft: #fff1f2;
  --gold: #ca8a04;
  --gold-soft: #fefce8;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / .08), 0 2px 4px -2px rgb(0 0 0 / .08);
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Noto Sans TC', 'Microsoft JhengHei', 'PingFang TC', system-ui, sans-serif;
  font-size: 16px; line-height: 1.85;
}
a { color: var(--accent); }
img { max-width: 100%; display: block; }
.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }

/* 頂部列 */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 54px; gap: 12px; }
.topbar .brand { font-weight: 800; color: #1e3a8a; text-decoration: none; white-space: nowrap; }
.topbar nav { display: flex; gap: 14px; font-size: 14px; font-weight: 700; }
.topbar nav a { text-decoration: none; color: var(--text-soft); white-space: nowrap; }
.topbar nav a.line { color: #06c755; }

/* 麵包屑 */
.crumb { font-size: 13px; color: var(--text-muted); padding: 14px 0 0; }
.crumb a { color: var(--text-soft); text-decoration: none; }
.crumb a:hover { text-decoration: underline; }

/* 標題區 */
.hero { padding: 18px 0 26px; }
.hero .eyebrow { color: var(--accent); font-size: 13px; font-weight: 700; letter-spacing: 2px; }
.hero h1 { font-size: clamp(28px, 6vw, 40px); line-height: 1.3; margin: 4px 0 10px; }
.hero .lead { color: var(--text-soft); font-size: 17px; max-width: 40em; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-top: 18px; }
.fact { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.fact b { display: block; font-size: 12px; color: var(--text-muted); font-weight: 700; letter-spacing: 1px; }
.fact span { font-weight: 700; }

/* 目錄 */
.toc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin: 8px 0 10px; box-shadow: var(--shadow); }
.toc b { color: var(--accent); }
.toc ol { margin: 8px 0 0 22px; display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 20px; font-size: 15px; }
.toc a { text-decoration: none; color: var(--text); }
.toc a:hover { color: var(--accent); }

/* 章節 */
section.ch { padding: 34px 0 10px; scroll-margin-top: 64px; }
section.ch > h2 { display: flex; align-items: center; gap: 10px; font-size: 24px; line-height: 1.35; margin-bottom: 12px; }
section.ch > h2 .no {
  flex: none; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 17px; font-weight: 800;
}
section.ch h3 { font-size: 18px; margin: 22px 0 6px; }
section.ch p { margin: 8px 0; }
ul.list, ol.list { margin: 8px 0 8px 24px; }
ul.list li, ol.list li { margin: 4px 0; }
.kbd { display: inline-block; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: 0 7px; font-size: .92em; font-weight: 700; line-height: 1.6; }
.n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--orange); color: #fff; font-size: 12px; font-weight: 800; vertical-align: 2px; }
.ball { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 4px; border-radius: 14px; background: #3949ab; color: #fff; font-size: 13px; font-weight: 700; margin: 1px; }
.ball.on { background: #ec407a; }
mark { background: #fef08a; padding: 0 3px; border-radius: 3px; }

/* 提示框 */
.box { border-radius: 12px; padding: 14px 16px; margin: 16px 0; border: 1px solid var(--border); background: var(--surface); }
.box > b:first-child { display: block; margin-bottom: 4px; }
.box.tip { background: var(--accent-soft); border-color: #c7d2fe; }
.box.tip > b:first-child { color: var(--accent); }
.box.ok { background: var(--green-soft); border-color: #bbf7d0; }
.box.ok > b:first-child { color: var(--green); }
.box.warn { background: var(--gold-soft); border-color: #fde68a; }
.box.warn > b:first-child { color: var(--gold); }
.box.ex { background: var(--orange-soft); border-color: #fed7aa; }
.box.ex > b:first-child { color: var(--orange); }

/* 截圖 */
figure.shot { margin: 18px auto; max-width: 420px; }
figure.shot.wide { max-width: 640px; }
figure.shot img { width: 100%; border-radius: 14px; border: 1px solid var(--border); box-shadow: var(--shadow); cursor: zoom-in; background: #fff; }
figure.shot figcaption { font-size: 13px; color: var(--text-soft); text-align: center; margin-top: 8px; }

/* 表格 */
.table-wrap { overflow-x: auto; margin: 14px 0; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--surface-2); font-size: 13px; color: var(--text-soft); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.c, th.c { text-align: center; }

/* 步驟 */
.steps { counter-reset: st; margin: 14px 0; }
.step { position: relative; padding: 0 0 18px 50px; }
.step::before {
  counter-increment: st; content: counter(st);
  position: absolute; left: 0; top: 0; width: 34px; height: 34px; border-radius: 50%;
  background: var(--orange); color: #fff; font-weight: 800; display: grid; place-items: center;
}
.step::after { content: ''; position: absolute; left: 16px; top: 38px; bottom: 4px; width: 2px; background: var(--border); }
.step:last-child::after { display: none; }
.step h4 { font-size: 17px; margin-bottom: 2px; }

/* 檢查表 */
table.check td:last-child { white-space: nowrap; font-weight: 700; }
.yes { color: var(--green); } .mid { color: var(--gold); } .no-ok { color: var(--red); }

/* FAQ */
details.faq { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; margin: 10px 0; }
details.faq summary { font-weight: 700; cursor: pointer; list-style: none; }
details.faq summary::before { content: 'Q　'; color: var(--accent); font-weight: 800; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq p { margin-top: 8px; color: var(--text-soft); }

/* 連到共通篇的卡片 */
.link-card { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid #c7d2fe; border-radius: var(--radius); padding: 14px 16px; margin: 14px 0; text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
.link-card:hover { border-color: var(--accent); }
.link-card .ico { font-size: 28px; }
.link-card b { display: block; color: var(--accent); }
.link-card small { color: var(--text-soft); }

/* 結尾 CTA */
.cta { background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; border-radius: 20px; padding: 26px 22px; text-align: center; margin: 40px 0 10px; }
.cta h2 { font-size: 22px; margin-bottom: 6px; }
.cta p { opacity: .9; }
.cta .btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 22px; border-radius: 999px; font-weight: 800; text-decoration: none; }
.btn.white { background: #fff; color: #4f46e5; }
.btn.line { background: #06c755; color: #fff; }
.btn.ghost { border: 2px solid rgba(255,255,255,.6); color: #fff; }

footer.foot { color: var(--text-muted); font-size: 13px; text-align: center; padding: 28px 16px 40px; line-height: 1.7; }

/* 說明書目錄頁 */
.cat { margin: 28px 0; }
.cat h2 { font-size: 20px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.cat h2 small { font-size: 13px; color: var(--text-muted); font-weight: 400; }
.prog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.prog { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; text-decoration: none; color: var(--text); }
.prog b { display: block; }
.prog span { font-size: 13px; color: var(--text-muted); }
a.prog:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.prog.ready span { color: var(--green); font-weight: 700; }
div.prog { opacity: .6; }

/* 放大檢視 */
.lightbox { position: fixed; inset: 0; z-index: 1000; background: rgb(15 23 42 / .92); display: none; align-items: center; justify-content: center; padding: 16px; cursor: zoom-out; }
.lightbox.open { display: flex; }
.lightbox img { max-height: 92vh; max-width: 100%; border-radius: 12px; }

@media (max-width: 640px) {
  body { font-size: 15.5px; }
  .topbar nav a.hide-sm { display: none; }
  section.ch > h2 { font-size: 21px; }
  th, td { padding: 8px 9px; font-size: 14px; }
}

/* ── 看圖學：圖在旁邊，文字精簡 ── */
.story { background: var(--surface); border: 2px solid #fed7aa; border-radius: 18px; padding: 16px 18px; margin: 10px 0 6px; box-shadow: var(--shadow); }
.story b.t { display: block; color: var(--orange); font-size: 14px; letter-spacing: 1px; margin-bottom: 6px; }
.story .row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 16px; }
.pic-step { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 22px; align-items: center; padding: 26px 0; border-bottom: 1px dashed var(--border); scroll-margin-top: 64px; }
.pic-step.flip { grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr); }
.pic-step.flip .pic { order: 2; }
.pic-step .pic img { width: 100%; border-radius: 14px; border: 1px solid var(--border); box-shadow: var(--shadow); cursor: zoom-in; background: #fff; }
.pic-step .pic.narrow { max-width: 340px; margin: 0 auto; }
.pic-step .pic.pair { display: grid; grid-template-columns: 1.5fr 1fr; gap: 10px; align-items: start; }
.pic-step .no { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--orange); color: #fff; font-weight: 800; margin-bottom: 6px; }
.pic-step h2 { font-size: 22px; line-height: 1.35; margin-bottom: 8px; }
.pic-step .say { font-size: 17px; margin: 6px 0; }
.pic-step .say b { color: var(--accent); }
.chip-ex { display: inline-block; background: var(--orange-soft); color: #9a3412; border: 1px solid #fed7aa; border-radius: 10px; padding: 6px 10px; font-size: 15px; margin-top: 8px; }
.chip-tip { display: inline-block; background: var(--green-soft); color: #166534; border: 1px solid #bbf7d0; border-radius: 10px; padding: 6px 10px; font-size: 15px; margin-top: 8px; }
.mini-check { list-style: none; margin: 8px 0; }
.mini-check li { padding: 4px 0 4px 28px; position: relative; font-size: 16px; }
.mini-check li::before { content: '☐'; position: absolute; left: 4px; color: var(--orange); font-weight: 800; }
@media (max-width: 720px) {
  .pic-step, .pic-step.flip { grid-template-columns: 1fr; gap: 12px; }
  .pic-step.flip .pic { order: 0; }
  .pic-step .pic.pair { grid-template-columns: 1.6fr 1fr; }
  .pic-step .pic.pair.stack { grid-template-columns: 1fr; max-width: 420px; margin: 0 auto; }
}
body.picbook .wrap { max-width: 1040px; }
