/* =========================================================
   Lab Final — styles ของหน้า labfinal/ (ทุกอย่างอยู่ใต้ .lf ไม่กระทบแท็บอื่น)
   สีหลัก: --final / --final-soft (teal) จาก app.css
   มือถือเป็นหลัก (≤ 860px): หน้าทำข้อสอบเต็มจอ (ซ่อนแถบบนของเว็บ), ปุ่มหลัก/ผลตรวจอยู่แถบล่างเดียว,
   ตั้งค่า + ผังข้อเป็น bottom sheet ; จอใหญ่ใช้หน้าตาแบบการ์ดเหมือนเดิม
   ========================================================= */
.lf {
  --lf-top: 58px;
  --lf-dock-h: 0px;
  --on-final: #fff; --on-lab: #fff; --on-exam: #fff;
  --final-ink: #0a6670; --lab-ink: #0b7a5c; --exam-ink: #b23a32; --warn-ink: #8f5a05;
  /* ขนาดตัวอักษรโจทย์/ตัวเลือก (ปรับได้ใน sheet: ปกติ / ใหญ่) */
  --lf-qfs: 17px; --lf-qth: 15px; --lf-ofs: 15.5px; --lf-oth: 13.5px;
  outline: none;
  touch-action: manipulation;   /* แตะเร็ว ๆ ไม่ซูมหน้า (ยังถ่างนิ้วซูมได้) */
}
html[data-theme="dark"] .lf {
  --on-final: #03282c; --on-lab: #03261c; --on-exam: #2b0906;
  --final-ink: var(--final); --lab-ink: var(--lab); --exam-ink: var(--exam); --warn-ink: var(--warn);
}
.lf.fs-l { --lf-qfs: 19px; --lf-qth: 17px; --lf-ofs: 17.5px; --lf-oth: 15.5px; }
.lf [hidden] { display: none !important; }
.lf-boot { min-height: 70vh; }

/* ---------- ระดับหน้า (เฉพาะหน้านี้): แถบอ่านจบซ้ำกับ progress ของหน้านี้, safe area, ล็อกการเลื่อน ---------- */
body[data-section="labfinal"] .readbar { display: none; }
html.lf-noscroll, html.lf-lock, html.lf-lock body { overflow: hidden; }
@media (max-width: 860px) {
  body[data-section="labfinal"] {
    --lf-gl: max(16px, env(safe-area-inset-left));
    --lf-gr: max(16px, env(safe-area-inset-right));
  }
  body[data-section="labfinal"] .main { padding: 16px var(--lf-gr) 64px var(--lf-gl); }
  body[data-section="labfinal"] .topbar {
    height: calc(58px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top);
    padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right));
  }
  /* หน้าทำข้อสอบ: ซ่อนแถบบนของเว็บ ใช้แถบของหน้านี้แทน */
  html.lf-immersive body[data-section="labfinal"] .topbar { display: none; }
  html.lf-immersive body[data-section="labfinal"] .main { padding-top: 0; padding-bottom: 0; }
}
@media (max-width: 460px) {
  body[data-section="labfinal"] .topbar { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
}

/* ---------- base overrides (เฉพาะในหน้านี้) ---------- */
.lf .eyebrow { text-transform: none; letter-spacing: .02em; font-size: 12.5px; }
.lf svg.i { width: 18px; height: 18px; flex: 0 0 auto; }
.lf svg.i.fill { fill: currentColor; stroke: none; }
.lf button, .lf a, .lf summary, .lf label, .lf select, .lf input { -webkit-tap-highlight-color: transparent; }
.lf button, .lf a, .lf summary, .lf label { touch-action: manipulation; }
/* ปุ่ม/ตัวเลือกไม่ให้เผลอลากเลือกข้อความ (ตัวโจทย์ยังเลือก/copy ได้) */
.lf button, .lf summary, .lf .lf-cell, .lf .lf-browselink { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.lf :focus-visible { outline: 2px solid var(--final); outline-offset: 2px; }
.lf:focus, .lf:focus-visible, .lf-fb:focus, .lf-sheet:focus { outline: none; }
.lf mark { background: color-mix(in srgb, var(--warn) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.lf h2.lf-h { font-size: 18px; margin: 0 0 14px; padding-top: 0; border-top: 0; letter-spacing: -.01em; }
.lf .reveal > summary::before { color: var(--final); }

/* buttons */
.lf .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 6px 14px; font-size: 14px; border-radius: 10px; text-decoration: none; line-height: 1.3;
}
.lf .btn svg.i { width: 16px; height: 16px; }
.lf .btn.sm { min-height: 32px; padding: 4px 11px; font-size: 13px; border-radius: 9px; }
.lf .btn.sm svg.i { width: 15px; height: 15px; }
.lf .btn.lg { min-height: 46px; padding: 9px 18px; font-size: 15px; border-radius: 12px; }
.lf .btn:hover { border-color: var(--line-strong); color: var(--ink); }
.lf .btn.primary, .lf .btn.primary:hover { background: var(--final); border-color: var(--final); color: var(--on-final); }
.lf .btn.ghost, .lf .btn.ghost:hover { background: transparent; border-color: transparent; color: var(--ink-2); }
.lf .btn.danger, .lf .btn.danger:hover { background: var(--exam); border-color: var(--exam); color: var(--on-exam); }
.lf .btn.danger-o, .lf .btn.danger-o:hover { color: var(--exam-ink); border-color: color-mix(in srgb, var(--exam) 45%, var(--line)); }
@media (hover: hover) {
  .lf .btn:hover { border-color: var(--final); color: var(--final-ink); }
  .lf .btn.primary:hover { filter: brightness(1.07); color: var(--on-final); }
  .lf .btn.ghost:hover { background: var(--bg-sunken); color: var(--ink); }
  .lf .btn.danger:hover { filter: brightness(1.06); color: var(--on-exam); }
  .lf .btn.danger-o:hover { border-color: var(--exam); color: var(--exam-ink); }
}
.lf .btn:active:not(:disabled) { transform: translateY(1px); background-color: var(--bg-sunken); }
.lf .btn.primary:active:not(:disabled), .lf .btn.danger:active:not(:disabled) { background: var(--final); filter: brightness(.92); }
.lf .btn.danger:active:not(:disabled) { background: var(--exam); }
.lf .btn:disabled, .lf .btn:disabled:hover { opacity: .45; cursor: not-allowed; filter: none; }

/* chips */
.lf .chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 5px 13px; font-size: 13.5px;
}
.lf .chip:hover { border-color: var(--line-strong); color: var(--ink-2); }
@media (hover: hover) { .lf .chip:hover { border-color: var(--final); color: var(--ink); } }
.lf .chip:active:not(:disabled) { background: var(--bg-sunken); }
.lf .chip.on, .lf .chip.on:hover, .lf .chip.on:active { background: var(--final); border-color: var(--final); color: var(--on-final); }
.lf .chip:disabled { opacity: .38; cursor: not-allowed; }
.lf .chip .ct { font-family: var(--mono); font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.lf .chip.on .ct { color: inherit; opacity: .8; }
.lf .chip.zero:not(.on) { opacity: .55; }

/* inline confirm */
.lf-inconf { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; font-size: 14px; color: var(--ink); line-height: 1.55; }
.lf-cbtns { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- page head ---------- */
.lf-head { margin-bottom: 20px; }
.lf-head h1 { margin-bottom: 8px; }
.lf-head .lead { margin-bottom: 0; font-size: 16.5px; line-height: 1.75; max-width: 64ch; }

/* ---------- resume banner ---------- */
.lf-resume {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px;
  padding: 12px 14px; margin: 0 0 16px; border-radius: var(--radius);
  background: var(--final-soft); border: 1px solid color-mix(in srgb, var(--final) 35%, var(--line));
}
.lf-resume-t { display: flex; align-items: flex-start; gap: 10px; flex: 1 1 220px; min-width: 0; color: var(--final-ink); }
.lf-resume-t svg { margin-top: 3px; }
.lf-resume-t b { display: block; font-size: 15px; color: var(--ink); }
.lf-resume-t span { display: block; font-size: 13.5px; color: var(--ink-2); line-height: 1.55; }
.lf-resume-b { display: flex; gap: 8px; flex-wrap: wrap; }
.lf-resume .lf-inconf { flex: 1 1 100%; }

/* ---------- today card: นับถอยหลัง + วงแหวนความแม่น + วันนี้ทำไปกี่ข้อ ---------- */
.lf .lf-today {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px 20px;
  margin: 0 0 14px; padding: 16px 18px 12px;
}
.lf-cd { min-width: 96px; padding-right: 20px; border-right: 1px solid var(--line); }
.lf-cd-n { font-family: var(--mono); font-size: 44px; font-weight: 700; line-height: 1; letter-spacing: -.04em; color: var(--final-ink); }
.lf-cd-l { margin-top: 6px; font-size: 14.5px; font-weight: 700; line-height: 1.35; }
.lf-cd-d { font-size: 12.5px; color: var(--ink-3); line-height: 1.45; }
.lf-cd-t { font-size: 20px; font-weight: 700; line-height: 1.3; color: var(--final-ink); }
.lf-ms { display: flex; align-items: center; gap: 12px; min-width: 0; }
.lf-ring { position: relative; flex: 0 0 auto; width: 66px; height: 66px; }
.lf-ring svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.lf-ring circle { fill: none; stroke-width: 5.5; }
.lf-ring .trk { stroke: var(--bg-sunken); }
.lf-ring .lv-good { stroke: var(--final); }
.lf-ring .lv-learn { stroke: var(--warn); }
.lf-ring .lv-weak { stroke: var(--exam); }
.lf-ring > span { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--ink); }
.lf-ms-t { min-width: 0; }
.lf-ms-big { font-family: var(--mono); font-size: 14px; font-weight: 600; line-height: 1.3; color: var(--ink-3); white-space: nowrap; }
.lf-ms-big b { font-size: 23px; font-weight: 700; color: var(--ink); }
.lf-ms-big span { font-family: var(--font); font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.lf-ms-sub { display: flex; flex-wrap: wrap; gap: 0 12px; margin-top: 4px; font-size: 12.5px; line-height: 1.55; color: var(--ink-3); }
.lf-ms-sub span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.lf-ms-sub b { font-family: var(--mono); font-weight: 600; color: var(--ink-2); }
.lf-tfoot {
  grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 2px 12px;
  padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.5; color: var(--ink-3);
}
.lf-tfoot b { font-family: var(--mono); color: var(--ink); }
.lf-nudge { color: var(--ink-2); }
.lf-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--ink-2); }
.lf-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.lf-legend b { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.lf-dot { display: inline-block; flex: 0 0 auto; width: 10px; height: 10px; border-radius: 3px; background: var(--line-strong); }
.lf-dot.lv-good { background: var(--final); }
.lf-dot.lv-learn { background: var(--warn); }
.lf-dot.lv-weak { background: var(--exam); }

/* ---------- ปุ่มเริ่มหลัก + แถวสรุปค่า ---------- */
.lf-cta { margin: 0 0 20px; }
.lf-go {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 62px; padding: 9px 18px 9px 10px;
  font-family: var(--font); font-size: 18px; font-weight: 700; line-height: 1.3; text-align: left;
  color: var(--on-final); background: var(--final); border: 0; border-radius: 16px; cursor: pointer;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .12), 0 12px 24px -14px var(--final);
  transition: transform .1s ease, filter .15s;
}
.lf-go-ic { display: grid; place-items: center; flex: 0 0 auto; width: 42px; height: 42px; border-radius: 12px; background: rgba(255, 255, 255, .17); }
html[data-theme="dark"] .lf-go-ic { background: rgba(3, 40, 44, .14); }
.lf-go-ic svg.i { width: 17px; height: 17px; margin-left: 2px; }
.lf-go-t { flex: 1 1 auto; min-width: 0; }
.lf-go .lf-go-ar { width: 20px; height: 20px; opacity: .85; }
.lf-go:active:not(:disabled) { transform: scale(.985); filter: brightness(.93); }
@media (hover: hover) { .lf-go:hover:not(:disabled) { filter: brightness(1.06); } }
.lf-go:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.lf-adj {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; margin-top: 4px; padding: 4px 2px 4px 6px;
  font-family: var(--font); text-align: left; color: var(--ink-2); background: none; border: 0; border-radius: 12px; cursor: pointer;
}
.lf-adj-s { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13.5px; }
.lf-adj-b {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; min-height: 38px; padding: 4px 13px;
  font-size: 13.5px; font-weight: 700; color: var(--final-ink); background: var(--final-soft); border-radius: 99px; transition: box-shadow .15s;
}
.lf-adj-b svg.i { width: 16px; height: 16px; }
.lf-adj:active .lf-adj-b { box-shadow: inset 0 0 0 1px var(--final); filter: brightness(.96); }
@media (hover: hover) { .lf-adj:hover .lf-adj-b { box-shadow: inset 0 0 0 1px var(--final); } }
.lf-cta .lf-reason { margin: 2px 6px 0; }
.lf-reason { margin: 10px 0 0; font-size: 13.5px; color: var(--exam-ink); }

/* ---------- ทางลัด 2×2 ---------- */
.lf-quick { margin: 0 0 24px; }
.lf .lf-qh {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin: 0 2px 10px; padding: 0; border: 0; font-size: 15px; font-weight: 700; letter-spacing: 0;
}
.lf .lf-qh span { font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
.lf-qgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.lf-qt {
  display: flex; flex-direction: column; align-items: flex-start; min-width: 0; min-height: 108px; padding: 12px 13px 13px;
  font-family: var(--font); text-align: left; color: var(--ink); background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); cursor: pointer;
  transition: transform .1s ease, border-color .15s, background-color .15s;
}
.lf-qt-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; width: 100%; margin-bottom: 10px; }
.lf-qt-ic { display: grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; border-radius: 11px; color: var(--final-ink); background: var(--final-soft); }
.lf-qt-ic svg.i { width: 19px; height: 19px; }
.q-wrong .lf-qt-ic { color: var(--exam-ink); background: var(--exam-soft); }
.q-new .lf-qt-ic { color: var(--accent); background: var(--accent-soft); }
.q-exam .lf-qt-ic { color: var(--warn-ink); background: var(--warn-soft); }
.lf-qt-n { padding: 1px 9px; border-radius: 99px; font-family: var(--mono); font-size: 14px; font-weight: 700; color: var(--ink); background: var(--bg-sunken); }
.q-wrong .lf-qt-n { color: var(--exam-ink); background: var(--exam-soft); }
.lf-qt-t { font-size: 15px; font-weight: 700; line-height: 1.35; }
.lf-qt-d { margin-top: 2px; font-size: 12.5px; line-height: 1.45; color: var(--ink-3); }
.lf-qt:active:not(:disabled) { transform: scale(.98); background: var(--bg-sunken); }
@media (hover: hover) { .lf-qt:hover:not(:disabled) { border-color: var(--final); } }
.lf-qt:disabled { cursor: not-allowed; background: transparent; box-shadow: none; border-style: dashed; }
.lf-qt:disabled .lf-qt-ic, .lf-qt:disabled .lf-qt-t, .lf-qt:disabled .lf-qt-n { opacity: .45; }

/* ---------- question map ---------- */
.lf .lf-mapc { margin: 0 0 4px; }
.lf-cardhead { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; }
.lf-cardhead h2.lf-h { margin: 0; }
.lf-maphint { font-size: 12.5px; color: var(--ink-3); }
.lf-mapc .lf-legend { margin-bottom: 12px; }
.lf-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 5px; }
.lf-cell {
  display: grid; place-items: center; aspect-ratio: 1 / 1; min-height: 32px; border-radius: 8px;
  font-family: var(--mono); font-size: 12px; font-weight: 600; text-decoration: none;
  color: var(--ink-3); background: var(--bg-sunken); border: 1px solid transparent; transition: transform .12s, box-shadow .12s;
}
.lf-cell.lv-weak { background: var(--exam-soft); color: var(--exam-ink); border-color: color-mix(in srgb, var(--exam) 40%, transparent); }
.lf-cell.lv-learn { background: var(--warn-soft); color: var(--warn-ink); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.lf-cell.lv-good { background: var(--final); color: var(--on-final); }
.lf-cell:active { transform: scale(.92); }
@media (hover: hover) { .lf-cell:hover { transform: translateY(-1px); box-shadow: 0 0 0 2px var(--final); } }

/* ---------- browse link / tips / data ---------- */
.lf-browselink {
  display: flex; align-items: center; gap: 14px; padding: 15px 18px; margin: 20px 0;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  color: inherit; text-decoration: none; transition: border-color .15s, background-color .15s;
}
.lf-browselink:active { background: var(--bg-sunken); }
.lf-bl-ic { display: grid; place-items: center; flex: 0 0 auto; width: 42px; height: 42px; border-radius: 12px; background: var(--final-soft); color: var(--final-ink); }
.lf-bl-t { flex: 1; min-width: 0; }
.lf-bl-t b { display: block; font-size: 15.5px; color: var(--ink); line-height: 1.45; }
.lf-bl-t span { display: block; font-size: 13px; color: var(--ink-3); line-height: 1.5; }
.lf-bl-go { color: var(--ink-3); }
@media (hover: hover) { .lf-browselink:hover { border-color: var(--final); } .lf-browselink:hover .lf-bl-go { color: var(--final-ink); } }
.lf-browselink + .lf-browselink { margin-top: -8px; }

.lf-tips { margin-top: 30px; }
.lf-tipgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.lf .lf-tip { margin: 0; padding: 16px 16px 15px; }
.lf-tip-ic { display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 10px; border-radius: 10px; background: var(--final-soft); color: var(--final-ink); }
.lf-tip h3 { margin: 0 0 4px; font-size: 15px; }
.lf-tip p { margin: 0; font-size: 13.5px; line-height: 1.65; color: var(--ink-2); }
.lf-a2hs { display: flex; align-items: flex-start; gap: 8px; margin: 14px 2px 0; font-size: 13px; line-height: 1.6; color: var(--ink-3); }
.lf-a2hs svg.i { width: 16px; height: 16px; margin-top: 3px; color: var(--final-ink); }

.lf-data { margin-top: 28px; }
.lf-dnote { margin: 12px 0 14px; font-size: 13.5px; color: var(--ink-2); }
.lf-dgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.lf-dbox h3 { margin: 0 0 8px; font-size: 14.5px; }
.lf-ta {
  display: block; width: 100%; min-height: 70px; margin: 0 0 8px; padding: 8px 10px; resize: vertical;
  font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 9px; word-break: break-all;
}
.lf-ta:focus { outline: none; border-color: var(--final); box-shadow: 0 0 0 3px color-mix(in srgb, var(--final) 18%, transparent); }
#lf-expbox { margin-top: 10px; }
.lf-msg { font-size: 13px; color: var(--lab-ink); }
.lf-msg.bad { color: var(--exam-ink); }
.lf-dsub { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-3); line-height: 1.55; }
.lf-dbox .lf-inconf { padding: 10px 12px; border-radius: 10px; background: var(--exam-soft); }

/* =========================================================
   Sheet: มือถือ = เลื่อนขึ้นจากขอบล่าง (มีที่จับ) ; จอใหญ่ = dialog กลางจอ
   ========================================================= */
.lf-sw { position: fixed; inset: 0; z-index: 120; }
.lf-sbd { position: absolute; inset: 0; background: rgba(9, 13, 19, .44); opacity: 0; transition: opacity .26s ease; }
html[data-theme="dark"] .lf-sbd { background: rgba(0, 0, 0, .6); }
.lf-sw.on .lf-sbd { opacity: 1; }
.lf-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column;
  max-height: calc(100% - 28px - env(safe-area-inset-top));
  background: var(--bg-elev); border-radius: 20px 20px 0 0; box-shadow: 0 -16px 48px -16px rgba(0, 0, 0, .35);
  transform: translateY(105%); transition: transform .3s cubic-bezier(.2, .8, .2, 1);
}
.lf-sw.on .lf-sheet { transform: none; }
.lf-sw.off .lf-sheet { transition-duration: .22s; }
.lf-sh {
  position: relative; display: flex; align-items: flex-start; gap: 10px; flex: 0 0 auto;
  padding: 20px var(--lf-gr, 18px) 10px var(--lf-gl, 18px); touch-action: none; cursor: grab;
}
.lf-grab { position: absolute; top: 8px; left: 50%; width: 40px; height: 5px; margin-left: -20px; border-radius: 99px; background: var(--line-strong); }
.lf-sht { flex: 1 1 auto; min-width: 0; padding-top: 4px; }
.lf .lf-st { margin: 0; padding: 0; border: 0; font-size: 18px; font-weight: 700; line-height: 1.35; letter-spacing: -.01em; }
.lf-ssub { margin: 2px 0 0; font-size: 13px; line-height: 1.5; color: var(--ink-3); }
.lf-sx {
  display: grid; place-items: center; flex: 0 0 auto; width: 40px; height: 40px; margin: -2px -4px 0 0; padding: 0;
  color: var(--ink-2); background: var(--bg-sunken); border: 0; border-radius: 50%; cursor: pointer;
}
.lf-sx svg.i { width: 20px; height: 20px; }
.lf-sx:active { filter: brightness(.94); }
.lf-sb {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 4px var(--lf-gr, 18px) 14px var(--lf-gl, 18px);
}
.lf-sf {
  flex: 0 0 auto; padding: 12px var(--lf-gr, 18px) calc(12px + env(safe-area-inset-bottom)) var(--lf-gl, 18px);
  background: var(--bg-elev); border-top: 1px solid var(--line);
}
.lf-sf .lf-info { margin: 0 0 10px; font-size: 13px; line-height: 1.55; color: var(--ink-2); }
.lf-sf .lf-reason { margin: 0 0 10px; }
.lf .lf-sgo { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 54px; margin: 0; font-size: 17px; border-radius: 14px; background: var(--final); color: var(--on-final); }
.lf .lf-sgo svg.i { width: 18px; height: 18px; }
.lf .lf-sgo:active:not(:disabled) { filter: brightness(.93); transform: scale(.99); }
@media (min-width: 861px) {
  .lf-sw { display: grid; place-items: center; padding: 24px; }
  .lf-sheet {
    position: relative; left: auto; right: auto; bottom: auto; width: min(620px, 100%); max-height: min(88vh, 900px);
    border-radius: 20px; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(14px) scale(.98);
    transition: transform .2s ease, opacity .2s ease;
  }
  .lf-sw.on .lf-sheet { opacity: 1; transform: none; }
  .lf-grab { display: none; }
  .lf-sh { padding: 18px 20px 8px 22px; cursor: auto; touch-action: auto; }
  .lf-sb { padding: 4px 22px 16px; }
  .lf-sf { padding: 14px 22px 18px; border-radius: 0 0 20px 20px; }
  .lf-confsheet .lf-sheet { width: min(460px, 100%); }
}

/* ---------- settings (ใน sheet) ---------- */
.lf-frow { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 6px 14px; align-items: start; padding: 12px 0; border-top: 1px solid var(--line); }
.lf-set .lf-frow:first-child { border-top: 0; padding-top: 4px; }
.lf-flbl { font-size: 13px; font-weight: 600; color: var(--ink-3); padding-top: 9px; line-height: 1.4; }
.lf-fctl { min-width: 0; }
.lf-fnote { margin: 8px 0 0; font-size: 13px; color: var(--warn-ink); }
.lf-ncount { display: flex; flex-wrap: wrap; gap: 6px; }
.lf-ncus {
  display: inline-flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 12px 0 14px; cursor: text;
  font-size: 13.5px; font-weight: 600; color: var(--ink-2); background: var(--bg-elev); border: 1px dashed var(--line-strong); border-radius: 99px;
}
.lf-ncus-i { display: inline-flex; align-items: center; gap: 6px; }
.lf .lf-ncus input {
  width: 62px; height: 30px; padding: 0 8px; text-align: center; font-family: var(--mono); font-size: 15px; font-weight: 600;
  color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 99px; -moz-appearance: textfield; appearance: textfield;
}
.lf .lf-ncus input::-webkit-outer-spin-button, .lf .lf-ncus input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.lf .lf-ncus input:focus { outline: none; border-color: var(--final); box-shadow: 0 0 0 3px color-mix(in srgb, var(--final) 18%, transparent); }
.lf-ncus.on { color: var(--final-ink); background: var(--final-soft); border-style: solid; border-color: var(--final); }
.lf-ncus.on input { border-color: color-mix(in srgb, var(--final) 50%, var(--line)); }
.lf-seg { display: inline-flex; flex-wrap: wrap; gap: 3px; max-width: 100%; padding: 3px; border-radius: 12px; background: var(--bg-sunken); border: 1px solid var(--line); }
.lf-segb {
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; flex: 1 1 auto;
  min-height: 38px; padding: 6px 14px; text-align: left; font-family: var(--font); color: var(--ink-2);
  background: transparent; border: 1px solid transparent; border-radius: 9px; cursor: pointer; transition: background .15s, color .15s;
}
.lf-segb .t { font-size: 14px; font-weight: 600; line-height: 1.4; }
.lf-segb .d { font-size: 12px; line-height: 1.45; color: var(--ink-3); }
.lf-seg.plain .lf-segb { align-items: center; text-align: center; }
.lf-segb.on { background: var(--bg-elev); border-color: var(--line); color: var(--final-ink); box-shadow: 0 1px 2px rgba(16,24,40,.08), 0 2px 8px -4px rgba(16,24,40,.12); }
.lf-segb.on .d { color: var(--ink-2); }
.lf-segb:active:not(.on) { background: color-mix(in srgb, var(--bg-elev) 60%, transparent); }
@media (hover: hover) { .lf-segb:not(.on):hover { color: var(--ink); background: color-mix(in srgb, var(--bg-elev) 55%, transparent); } }
.lf-disc {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 6px 2px; min-height: 40px;
  background: none; border: 0; font-family: var(--font); font-size: 13.5px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.lf-disc-v { color: var(--final-ink); }
.lf-disc svg.i { width: 16px; height: 16px; transition: transform .15s; }
.lf-disc[aria-expanded="true"] svg.i { transform: rotate(180deg); }
.lf-mods { margin-top: 4px; }
.lf-modgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; }
.lf-mod {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 7px 10px; text-align: left;
  font-family: var(--font); font-size: 13px; line-height: 1.35; color: var(--ink-2);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; transition: border-color .12s, background .12s;
}
.lf-mod b { min-width: 30px; font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.lf-mod .nm { flex: 1; min-width: 0; }
.lf-mod .ct { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--ink-3); }
.lf-mod.on { background: var(--final-soft); border-color: var(--final); color: var(--ink); }
.lf-mod.on b, .lf-mod.on .ct { color: var(--final-ink); }
.lf-mod.zero:not(.on) { opacity: .5; }
.lf-mod:active { background: var(--bg-sunken); }
@media (hover: hover) { .lf-mod:hover { border-color: var(--final); } }
.lf-linkbtn {
  margin-top: 6px; padding: 8px 2px; background: none; border: 0; cursor: pointer;
  font-family: var(--font); font-size: 13px; font-weight: 600; color: var(--final-ink); text-decoration: underline; text-underline-offset: 3px;
}
.lf .lf-switch { padding: 2px 0; align-items: flex-start; }
.lf .lf-switch input { accent-color: var(--final); }
.lf .lf-switch .t { display: block; font-size: 14.5px; line-height: 1.5; }
.lf .lf-switch .d { display: block; }

/* ---------- confirm / palette sheets ---------- */
.lf-ctext { margin: 0; font-size: 15px; line-height: 1.65; color: var(--ink-2); }
.lf-cbtns2 { display: flex; flex-direction: column; gap: 8px; }
.lf-cbtns2 .btn.lg { width: 100%; min-height: 50px; font-size: 15.5px; border-radius: 13px; }
.lf-pal-key { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 14px 0 0; font-size: 12.5px; color: var(--ink-3); }
.lf-pal-key span { display: inline-flex; align-items: center; gap: 6px; }
.lf-pal-key .k { display: inline-block; width: 14px; height: 14px; border-radius: 4px; background: var(--bg); border: 1px solid var(--line-strong); }
.lf-pal-key .k.done { background: var(--final); border-color: var(--final); }
.lf-pal-key .k.cur { box-shadow: 0 0 0 1.5px var(--bg-elev), 0 0 0 3px var(--ink-2); }
.lf-palsheet .lf-pal-g { grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: 8px; }
.lf-palsheet .lf-pb { height: 48px; font-size: 14px; border-radius: 11px; }

/* =========================================================
   PLAY: แถบบน (หน้าทำข้อสอบ / ทีละข้อ)
   ========================================================= */
.lf-bar { position: sticky; top: var(--lf-top); z-index: 30; display: flex; align-items: center; gap: 10px; }
.lf-hb {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: 0 0 auto; min-width: 44px; height: 44px; padding: 0 10px;
  font-family: var(--font); font-size: 14px; font-weight: 600; color: var(--ink-2); background: transparent; border: 0; border-radius: 12px; cursor: pointer;
}
.lf-hb svg.i { width: 22px; height: 22px; }
.lf-hb:active { background: var(--bg-sunken); }
@media (hover: hover) { .lf-hb:hover { background: var(--bg-sunken); color: var(--ink); } }
.lf-hnav { display: inline-flex; flex: 0 0 auto; }
.lf-hprog { flex: 1 1 auto; min-width: 48px; }
.lf-segs { display: block; }
.lf-sg { display: flex; gap: 3px; height: 6px; }
.lf-sg i { display: block; flex: 1 1 0; min-width: 0; border-radius: 3px; background: var(--bg-sunken); transition: background-color .25s; }
.lf-sg i.cur { background: color-mix(in srgb, var(--ink) 28%, var(--bg-sunken)); }
.lf-sg i.ok { background: var(--lab); }
.lf-sg i.bad { background: var(--exam); }
.lf-sg i.done { background: var(--final); }
.lf-sg i.done.cur { background: color-mix(in srgb, var(--final) 70%, var(--ink)); }
.lf-sl { display: flex; height: 6px; overflow: hidden; border-radius: 3px; background: var(--bg-sunken); }
.lf-sl i { display: block; height: 100%; transition: width .3s ease; }
.lf-sl i.ok { background: var(--lab); }
.lf-sl i.bad { background: var(--exam); }
.lf-sl i.done { background: var(--final); }
html[data-theme="dark"] .lf-sg i, html[data-theme="dark"] .lf-sl { background: color-mix(in srgb, var(--ink) 12%, var(--bg-elev)); }
html[data-theme="dark"] .lf-sg i.cur { background: color-mix(in srgb, var(--ink) 40%, var(--bg-elev)); }
html[data-theme="dark"] .lf-sg i.ok { background: var(--lab); }
html[data-theme="dark"] .lf-sg i.bad { background: var(--exam); }
html[data-theme="dark"] .lf-sg i.done { background: var(--final); }
.lf-prog { flex: 0 0 auto; font-size: 15px; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lf-prog .lf-of { font-weight: 600; color: var(--ink-3); }
.lf-score { flex: 0 0 auto; font-size: 13.5px; color: var(--ink-2); white-space: nowrap; }
.lf-timer {
  display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto; padding: 3px 9px; border-radius: 99px;
  font-family: var(--mono); font-size: 14.5px; font-weight: 700; color: var(--ink); background: var(--bg-sunken); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.lf-timer svg.i { width: 15px; height: 15px; color: var(--ink-3); }
.lf-timer.low { color: var(--exam-ink); background: var(--exam-soft); }
.lf-timer.low svg.i { color: inherit; }
.lf-sp { flex: 1 1 auto; }
.lf-thbtn {
  display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto; min-height: 36px; padding: 2px 11px 2px 9px;
  font-family: var(--font); font-size: 12.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap;
  background: var(--bg); border: 1px solid var(--line); border-radius: 99px; cursor: pointer;
}
.lf-thbtn svg.i { width: 16px; height: 16px; color: var(--final-ink); }
.lf-thbtn[data-th="hide"] svg.i { color: var(--ink-3); }
.lf-thbtn:active { background: var(--bg-sunken); }
@media (hover: hover) { .lf-thbtn:hover { border-color: var(--final); color: var(--ink); } }

/* ---------- question card ---------- */
.lf .lf-card { margin: 0; padding: 18px 20px 20px; box-shadow: var(--shadow); }
.lf-qhead { display: flex; align-items: flex-start; gap: 8px 10px; margin-bottom: 12px; }
.lf .lf-num { min-width: 0; height: 26px; margin-top: 0; padding: 0 8px; border-radius: 8px; font-size: 12.5px; background: var(--final); color: var(--on-final); }
.lf-pills { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; padding-top: 1px; }
.lf .lf-pill { min-height: 24px; max-width: 100%; white-space: nowrap; flex-wrap: nowrap; }
.lf .lf-pill svg.i { width: 13px; height: 13px; }
.lf .lf-pill.acc { background: var(--final-soft); color: var(--final-ink); border-color: transparent; }
.lf .lf-pill.re { background: var(--warn-soft); color: var(--warn-ink); border-color: transparent; }
.lf .lf-pill.lv-weak { background: var(--exam-soft); color: var(--exam-ink); border-color: transparent; }
.lf .lf-pill.lv-learn { background: var(--warn-soft); color: var(--warn-ink); border-color: transparent; }
.lf .lf-pill.lv-good { background: var(--lab-soft); color: var(--lab-ink); border-color: transparent; }
.lf .lf-pill.mod { display: inline-block; overflow: hidden; text-overflow: ellipsis; line-height: 20px; }

.lf-q .en, .lf-body .en { margin: 0; font-size: var(--lf-qfs); font-weight: 600; line-height: 1.6; color: var(--ink); overflow-wrap: anywhere; }
.lf-q .th, .lf-body .th { margin: 6px 0 0; font-size: var(--lf-qth); font-weight: 400; line-height: 1.7; color: var(--ink-2); }
.lf-body { margin-top: 12px; }
.lf-card.th-hide .th, .lf-card.th-after:not(.answered) .th { display: none; }

/* exhibit images: พื้นขาวเสมอ (เป็น screenshot) */
.lf-fig { margin: 14px 0 4px; }
.lf-imgbtn {
  position: relative; display: inline-block; max-width: 100%; padding: 0; vertical-align: top;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: zoom-in;
}
.lf .lf-imgbtn img { display: block; max-width: 100%; height: auto; border: 0; border-radius: 0; background: #fff; }
.lf-fig figcaption { margin: 4px 0 0; text-align: left; }
.lf-zoomlink {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 2px; border: 0; background: none; cursor: zoom-in;
  font-family: var(--font); font-size: 12.5px; font-weight: 600; color: var(--ink-3);
}
.lf-zoomlink:hover { color: var(--final); }
.lf-zoomlink svg.i { width: 14px; height: 14px; }

/* options */
.lf-ans { margin-top: 16px; }
.lf .cq-opts { gap: 8px; }
.lf .cq-opt {
  position: relative; align-items: flex-start; min-height: 48px; padding: 11px 14px; border-radius: 12px;
  font-size: var(--lf-ofs); line-height: 1.55; background: var(--lf-opt-bg, var(--bg)); transition: border-color .12s, background-color .12s, transform .08s;
}
.lf .cq-opt:hover { border-color: var(--line); }
@media (hover: hover) { .lf button.cq-opt:hover { border-color: var(--final); } }
.lf button.cq-opt:active { transform: scale(.99); border-color: var(--final); background: color-mix(in srgb, var(--final) 6%, var(--lf-opt-bg, var(--bg))); }
.lf .cq-mark { width: 26px; height: 26px; margin-top: 0; border-radius: 8px; font-size: 12.5px; }
.lf .cq-mark svg.i { width: 15px; height: 15px; stroke-width: 2.6; }
.lf .cq-t { min-width: 0; padding-top: 1px; overflow-wrap: anywhere; }
.lf .cq-t .en { display: block; }
.lf .cq-t .th.o { margin: 3px 0 0; font-size: var(--lf-oth); line-height: 1.6; color: var(--ink-3); }
.lf .cq-opt.picked, .lf .cq-opt.picked:hover { border-color: var(--final); background: var(--final-soft); }
.lf .cq-opt.picked .cq-mark { background: var(--final); color: var(--on-final); }
.lf .cq-opt.right, .lf .cq-opt.right:hover { border-color: var(--lab); background: var(--lab-soft); }
.lf .cq-opt.right .cq-mark { background: var(--lab); color: var(--on-lab); }
.lf .cq-opt.wrong, .lf .cq-opt.wrong:hover { border-color: var(--exam); background: var(--exam-soft); }
.lf .cq-opt.wrong .cq-mark { background: var(--exam); color: var(--on-exam); }
.lf .cq-opt.dim { opacity: .6; }
.lf-you {
  flex: 0 0 auto; align-self: center; padding: 1px 8px; border-radius: 99px; white-space: nowrap;
  font-size: 11.5px; font-weight: 600; color: var(--ink-2); background: var(--bg-elev); border: 1px solid var(--line);
}

/* image options (imgopt) */
.lf-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.lf-tile {
  position: relative; display: flex; flex-direction: column; gap: 8px; padding: 10px; text-align: left;
  font-family: var(--font); color: var(--ink); background: var(--lf-opt-bg, var(--bg)); border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.lf div.lf-tile { cursor: default; }
@media (hover: hover) { .lf button.lf-tile:hover { border-color: var(--final); } }
.lf button.lf-tile:active { border-color: var(--final); }
.lf-tile .cq-mark { position: absolute; top: 8px; left: 8px; z-index: 1; box-shadow: 0 0 0 2px var(--bg-elev); }
.lf-tile-img { display: grid; place-items: center; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 8px; background: #fff; }
.lf .lf-tile-img img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.lf-tile-l { font-size: 14px; font-weight: 600; line-height: 1.4; }
.lf-tile-l .th.o { margin: 2px 0 0; font-size: 12.5px; font-weight: 400; color: var(--ink-3); }
.lf-tile .lf-you { position: absolute; top: 8px; right: 8px; }
.lf-tile.picked { border-color: var(--final); background: var(--final-soft); }
.lf-tile.picked .cq-mark { background: var(--final); color: var(--on-final); }
.lf-tile.right { border-color: var(--lab); background: var(--lab-soft); }
.lf-tile.right .cq-mark { background: var(--lab); color: var(--on-lab); }
.lf-tile.wrong { border-color: var(--exam); background: var(--exam-soft); }
.lf-tile.wrong .cq-mark { background: var(--exam); color: var(--on-exam); }
.lf-tile.dim { opacity: .6; }

/* match */
.lf-match { display: flex; flex-direction: column; gap: 10px; }
.lf-mrow { padding: 12px 14px; background: var(--lf-opt-bg, var(--bg)); border: 1px solid var(--line); border-radius: 12px; transition: border-color .15s, background .15s; }
.lf-mrow.set { border-color: color-mix(in srgb, var(--final) 40%, var(--line)); }
.lf-mrow.ok { border-color: var(--lab); background: var(--lab-soft); }
.lf-mrow.bad { border-color: var(--exam); background: var(--exam-soft); }
.lf-mp { display: flex; align-items: flex-start; gap: 10px; }
.lf-mn {
  display: grid; place-items: center; flex: 0 0 auto; width: 24px; height: 24px; margin-top: 1px; border-radius: 7px;
  font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--ink-3); background: var(--bg-sunken);
}
.lf-mn svg.i { width: 14px; height: 14px; stroke-width: 2.6; }
.lf-mrow.set .lf-mn { color: var(--final-ink); background: var(--final-soft); }
.lf-mrow.ok .lf-mn { color: var(--on-lab); background: var(--lab); }
.lf-mrow.bad .lf-mn { color: var(--on-exam); background: var(--exam); }
.lf-mpt { flex: 1; min-width: 0; }
.lf-mpt .en { margin: 0; font-size: var(--lf-ofs); font-weight: 500; line-height: 1.55; overflow-wrap: anywhere; }
.lf-mpt .th { margin: 3px 0 0; font-size: var(--lf-oth); line-height: 1.6; color: var(--ink-2); }
.lf-mchips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0 34px; }
.lf-mchip {
  position: relative; display: inline-flex; flex-direction: column; justify-content: center; align-items: flex-start; max-width: 100%;
  min-height: 42px; padding: 6px 12px; text-align: left; font-family: var(--font); font-size: 14px; font-weight: 500; line-height: 1.35;
  color: var(--ink); background: var(--lf-chip-bg, var(--bg-elev)); border: 1px solid var(--line-strong); border-radius: 10px; cursor: pointer; transition: border-color .12s, background .12s;
}
.lf-mchip .lf-mcl { overflow-wrap: anywhere; }
.lf-mchip .th { font-size: 12px; font-weight: 400; color: var(--ink-3); }
.lf-mchip .lf-sub { font-size: 11px; font-weight: 400; color: var(--ink-3); }
.lf-mchip.none { border-style: dashed; color: var(--ink-2); }
.lf-mchip .lf-mcl .lf-sub { font-size: 11.5px; }
@media (hover: hover) { .lf button.lf-mchip:hover { border-color: var(--final); } }
.lf button.lf-mchip:active { border-color: var(--final); }
.lf-mchip.on, .lf button.lf-mchip.on:hover { background: var(--final); border-color: var(--final); color: var(--on-final); border-style: solid; }
.lf-mchip.on .th, .lf-mchip.on .lf-sub { color: inherit; opacity: .85; }
.lf-mchip.used { color: var(--ink-3); background: var(--bg-sunken); border-style: dashed; }
.lf-usedtag {
  position: absolute; top: -7px; right: -6px; display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 99px; font-family: var(--mono); font-size: 10.5px; font-weight: 700; color: var(--bg-elev); background: var(--ink-3);
}
.lf-mchip.right { background: var(--lab); border-color: var(--lab); color: var(--on-lab); border-style: solid; }
.lf-mchip.right.miss { background: var(--bg-elev); color: var(--lab-ink); box-shadow: inset 0 0 0 1px var(--lab); }
.lf-mchip.right .th, .lf-mchip.right .lf-sub { color: inherit; opacity: .85; }
.lf-mchip.wrong { background: var(--exam); border-color: var(--exam); color: var(--on-exam); border-style: solid; }
.lf-mchip.wrong .th, .lf-mchip.wrong .lf-sub { color: inherit; opacity: .85; }
.lf-mchip.dim { opacity: .45; }
.lf div.lf-mchip { cursor: default; }
.lf-mfix { margin: 8px 0 0 34px; font-size: 14px; color: var(--ink-2); }
.lf-mfix b { color: var(--lab-ink); }
.lf-mfix .th { color: var(--ink-3); font-size: 13px; }
.lf-mrow.lf-flash { animation: lfFlash .8s ease; }
@keyframes lfFlash {
  0% { box-shadow: 0 0 0 0 transparent; }
  25% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--warn) 40%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* hint + feedback (ในการ์ด) */
.lf-pend { margin-top: 10px; min-height: 0; }
.lf-pend:empty { display: none; }
.lf-hint { font-size: 13.5px; color: var(--ink-3); }
.lf-hint.warn { color: var(--warn-ink); font-weight: 600; }
.lf-shake { animation: lfShake .32s ease; }
@keyframes lfShake { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.lf-fb:empty { display: none; }
.lf-fb { margin-top: 16px; scroll-margin-top: 70px; }
.lf-card.answered .lf-fb { animation: lfIn .22s ease both; }
.lf-verdict { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; padding: 10px 14px; border-radius: 12px; font-size: 15.5px; line-height: 1.5; }
.lf-verdict svg.i { width: 20px; height: 20px; stroke-width: 2.4; }
.lf-verdict b { font-weight: 700; }
.lf-verdict span { font-weight: 600; color: var(--ink); }
.lf-verdict.ok { color: var(--lab-ink); background: var(--lab-soft); }
.lf-verdict.bad { color: var(--exam-ink); background: var(--exam-soft); }
.lf-hook {
  margin-top: 12px; padding: 11px 14px; border-radius: 12px; font-size: 15px; line-height: 1.7; color: var(--ink);
  background: var(--final-soft); border: 1px solid color-mix(in srgb, var(--final) 22%, transparent);
}
.lf-hook .lbl { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; font-size: 12.5px; font-weight: 700; color: var(--final-ink); }
.lf-hook .lbl svg.i { width: 15px; height: 15px; }
.lf-exp { margin-top: 14px; font-size: 15px; line-height: 1.75; color: var(--ink); }
.lf-exp .lbl { display: block; margin-bottom: 4px; font-size: 12.5px; font-weight: 700; letter-spacing: .02em; color: var(--ink-3); }
.lf-exp p, .lf-more-b p { margin: 0 0 10px; }
.lf-exp ul, .lf-more-b ul { margin: 0 0 10px; padding-left: 20px; }
.lf-exp li, .lf-more-b li { margin: 3px 0; }
.lf-exp > :last-child, .lf-more-b > :last-child { margin-bottom: 0; }
.lf-exp.en { color: var(--ink-2); }
.lf-exp code, .lf-more-b code, .lf-hook code, .lf-dk code { white-space: normal; }
.lf-more { margin-top: 12px; padding-top: 6px; border-top: 1px solid var(--line); }
.lf-more > summary {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 0; list-style: none; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--ink-2);
}
.lf-more > summary::-webkit-details-marker { display: none; }
.lf-more > summary svg.i { width: 15px; height: 15px; transition: transform .15s; }
.lf-more[open] > summary svg.i { transform: rotate(90deg); }
.lf-more-b { padding: 4px 0 2px; font-size: 14.5px; line-height: 1.7; color: var(--ink-2); }
.lf-more-b .lf-fig { margin-top: 4px; }

/* แถบล่าง (#lf-actbar): ตัวช่วยที่ใช้ทุกขนาดจอ */
.lf-actbar { margin-top: 14px; }
.lf-actbar:empty { display: none; }
.lf-drow { display: flex; align-items: center; gap: 8px; }
.lf-sent { display: block; height: 1px; }
.lf-dfb, .lf-dhint, .lf-dpal, .lf .lf-dexp { display: none; }
.lf-kbdline { display: none; }
@media (hover: hover) and (pointer: fine) and (min-width: 861px) {
  .lf-kbdline { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 16px; margin: 12px 2px 0; font-size: 12.5px; color: var(--ink-3); }
}
.lf .kbd { font-size: 11px; padding: 1px 5px; }

/* exam palette */
.lf-pal { margin-top: 16px; padding: 14px 16px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); }
.lf-pal-h { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.lf-pal-g { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.lf-pb {
  height: 40px; padding: 0; border-radius: 9px; cursor: pointer;
  font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--ink-2); background: var(--bg); border: 1px solid var(--line-strong);
}
.lf-pb.done { color: var(--on-final); background: var(--final); border-color: var(--final); }
.lf-pb.cur { box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 4px var(--ink-2); }
.lf-pb:active { transform: scale(.94); }
@media (hover: hover) { .lf-pb:not(.done):hover { border-color: var(--final); } }

/* stage transition */
.lf-stage.lf-in > .lf-card { animation: lfIn .2s ease both; }
@keyframes lfIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes lfUp { from { transform: translateY(100%); } to { transform: none; } }

/* ---------- result ---------- */
.lf .lf-score-card { padding: 22px 20px 20px; text-align: center; }
.lf-rring { position: relative; width: 140px; height: 140px; margin: 0 auto 6px; }
.lf-rring svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.lf-rring circle { fill: none; stroke-width: 9; }
.lf-rring .trk { stroke: var(--bg-sunken); }
.lf-rring .val { stroke: var(--final); stroke-linecap: round; }
.tone-mid .lf-rring .val { stroke: var(--warn); }
.tone-low .lf-rring .val { stroke: var(--exam); }
.lf-rc { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.lf-big { font-family: var(--mono); line-height: 1; }
.lf-big b { font-size: 40px; font-weight: 700; }
.lf-big span { font-size: 18px; font-weight: 600; color: var(--ink-3); }
.lf-pct { margin-top: 5px; font-size: 14px; font-weight: 700; }
.tone-good .lf-big b, .tone-good .lf-pct { color: var(--final-ink); }
.tone-mid .lf-big b, .tone-mid .lf-pct { color: var(--warn-ink); }
.tone-low .lf-big b, .tone-low .lf-pct { color: var(--exam-ink); }
.lf-line1 { margin: 8px 0 2px; font-size: 16.5px; font-weight: 600; }
.lf-meta { margin: 0; font-size: 13.5px; color: var(--ink-3); }
.lf-timeup {
  display: inline-flex; align-items: center; gap: 6px; margin: 12px 0 0; padding: 4px 11px; border-radius: 99px;
  font-size: 13px; font-weight: 600; color: var(--exam-ink); background: var(--exam-soft);
}
.lf-timeup svg.i { width: 15px; height: 15px; }
.lf-resbtns { display: flex; flex-direction: column; gap: 8px; margin: 16px 0 4px; }
.lf-rb-2 { display: flex; gap: 8px; }
.lf-rb-2 .btn { flex: 1 1 0; min-width: 0; }
.lf-resbtns .btn.lg { min-height: 50px; }
.lf-mods-res { margin-top: 24px; }
.lf-mods-res h2.lf-h { margin-bottom: 10px; font-size: 16px; }
.lf-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.lf-mchipres {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 11px; border-radius: 99px; font-size: 13px;
  background: var(--bg-elev); border: 1px solid var(--line);
}
.lf-mchipres b { font-family: var(--mono); font-size: 12px; }
.lf-mchipres .ct { padding: 0 7px; border-radius: 99px; font-family: var(--mono); font-weight: 700; color: var(--exam-ink); background: var(--exam-soft); }
.lf-review { margin-top: 30px; }
.lf-review .lf-card { margin: 0 0 14px; }
.lf-rightlist { margin-top: 20px; }
.lf .lf-rightlist .body { padding: 4px 14px 14px; }
.lf .lf-rightlist .lf-card { margin: 12px 0 0; box-shadow: none; }

/* ---------- browse ---------- */
.lf-back {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; margin-bottom: 4px; padding: 4px 0;
  font-size: 13.5px; font-weight: 600; color: var(--final-ink); text-decoration: none;
}
.lf-back svg.i { width: 16px; height: 16px; }
.lf-bsent { display: block; height: 1px; margin-bottom: -1px; }
.lf-bsticky {
  position: sticky; top: var(--lf-top); z-index: 20;
  margin: 0 calc(-1 * var(--lf-gr, 0px)) 0 calc(-1 * var(--lf-gl, 0px)); padding: 8px var(--lf-gr, 0px) 8px var(--lf-gl, 0px);
  background: var(--bg); transition: box-shadow .15s;
}
.lf-bsticky.stuck {
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
  box-shadow: 0 1px 0 var(--line), 0 10px 18px -16px rgba(16, 24, 40, .35);
}
.lf-bsearch { display: flex; gap: 8px; }
.lf-search {
  display: flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; height: 46px; padding: 0 12px; cursor: text;
  background: var(--bg-elev); border: 1px solid var(--line-strong); border-radius: 12px;
}
.lf-search:focus-within { border-color: var(--final); box-shadow: 0 0 0 3px color-mix(in srgb, var(--final) 18%, transparent); }
.lf-search svg.i { color: var(--ink-3); }
.lf .lf-search input { flex: 1; min-width: 0; height: 100%; padding: 0; font-size: 15px; color: var(--ink); background: transparent; border: 0; outline: none; }
.lf-bmod {
  position: relative; display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; height: 46px; padding: 0 10px 0 13px;
  font-size: 14px; font-weight: 600; color: var(--ink-2); background: var(--bg-elev); border: 1px solid var(--line-strong); border-radius: 12px; cursor: pointer;
}
.lf-bmod svg.i { width: 16px; height: 16px; color: var(--ink-3); }
.lf-bmod select { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0; cursor: pointer; font-size: 16px; }
.lf-bmod.on { color: var(--final-ink); background: var(--final-soft); border-color: var(--final); }
.lf-bmod.on svg.i { color: inherit; }
.lf-bmod:focus-within { border-color: var(--final); box-shadow: 0 0 0 3px color-mix(in srgb, var(--final) 18%, transparent); }
.lf-bchips { position: relative; margin: 4px 0 2px; }
.lf-bfil { gap: 6px; }
.lf-bfil .chip { flex: 0 0 auto; }
.lf-bcount { min-height: 1.6em; margin: 6px 2px 8px; font-size: 13px; color: var(--ink-3); }
.lf-list { display: flex; flex-direction: column; gap: 8px; }
.lf-row { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.lf-row.open { border-color: color-mix(in srgb, var(--final) 45%, var(--line)); box-shadow: var(--shadow); }
.lf-rowbtn {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 12px 14px; text-align: left; cursor: pointer;
  font-family: var(--font); color: var(--ink); background: none; border: 0;
}
.lf-rowbtn:active { background: var(--bg-sunken); }
@media (hover: hover) { .lf-rowbtn:hover { background: color-mix(in srgb, var(--final) 4%, transparent); } }
.lf-rid { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; min-width: 40px; padding-top: 2px; font-family: var(--mono); font-size: 12.5px; font-weight: 700; color: var(--final-ink); }
.lf-rtx { flex: 1; min-width: 0; }
.lf-rtx .en { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14.5px; font-weight: 500; line-height: 1.55; overflow-wrap: anywhere; }
.lf-rtx .th { display: block; margin-top: 2px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; color: var(--ink-3); }
.lf-snip { display: block; margin-top: 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12.5px; color: var(--ink-3); }
.lf-snip b { font-weight: 600; color: var(--ink-2); }
.lf-row.open .lf-snip { display: none; }
.lf-row.open .lf-rtx .en { display: block; -webkit-line-clamp: unset; font-size: 15.5px; font-weight: 600; }
.lf-row.open .lf-rtx .th { white-space: normal; font-size: 14px; color: var(--ink-2); }
.lf-rchev { width: 16px; height: 16px; margin-top: 4px; color: var(--ink-3); transition: transform .15s; }
.lf .lf-rowbtn svg.lf-rchev { width: 16px; height: 16px; }
.lf-row.open .lf-rchev { transform: rotate(180deg); }
.lf-rowbody { padding: 0 14px 16px; border-top: 1px solid var(--line); }
.lf-sol { padding-top: 12px; }
.lf .lf-sol .cq-opts { gap: 6px; }
.lf .lf-sol .cq-opt { min-height: 0; padding: 9px 12px; font-size: 14.5px; }
.lf .lf-sol .cq-t .th.o { font-size: 13px; }
.lf-sol .lf-body .en { font-size: 15.5px; }
.lf-varlbl { margin: 14px 0 6px; font-size: 12.5px; font-weight: 700; color: var(--ink-3); }
.lf-varlbl:first-child { margin-top: 2px; }
.lf-solfoot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.lf-solmeta { font-size: 12.5px; color: var(--ink-3); }
.lf-tablewrap { margin: 2px 0 6px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; }
.lf .lf-mtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.lf .lf-mtable th { padding: 8px 12px; text-align: left; font-size: 12.5px; background: var(--bg-sunken); }
.lf .lf-mtable td { padding: 9px 12px; vertical-align: top; border-top: 1px solid var(--line); border-bottom: 0; }
.lf .lf-mtable td:last-child { width: 42%; }
.lf .lf-mtable td b { font-weight: 600; color: var(--lab-ink); }
.lf .lf-mtable .th { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-3); }
.lf .lf-mtable tr.none td:first-child { color: var(--ink-3); }
.lf-none { padding: 1px 8px; border: 1px dashed var(--line-strong); border-radius: 99px; font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.lf-spare { margin: 6px 0 0; font-size: 13px; color: var(--ink-3); }
.lf-empty { padding: 30px 16px; text-align: center; color: var(--ink-3); }
.lf-empty svg.i { width: 26px; height: 26px; }
.lf-empty p { margin: 8px 0 14px; }

/* ---------- lightbox ---------- */
.lf-lb { position: fixed; inset: 0; z-index: 200; background: rgba(8, 10, 14, .92); animation: lfFade .15s ease; }
@keyframes lfFade { from { opacity: 0; } to { opacity: 1; } }
.lf-lb-sc {
  position: absolute; inset: 0; display: flex; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: calc(60px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) calc(44px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.lf-lb-sc img { display: block; margin: auto; max-width: none; height: auto; background: #fff; border-radius: 8px; cursor: zoom-in; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.lf-lb.zoomed .lf-lb-sc img { cursor: zoom-out; }
.lf-lb-x {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); display: grid; place-items: center; width: 44px; height: 44px; cursor: pointer;
  color: #fff; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .22); border-radius: 12px;
}
.lf-lb-x svg.i { width: 22px; height: 22px; }
.lf-lb-hint { position: absolute; left: 0; right: 0; bottom: calc(10px + env(safe-area-inset-bottom)); margin: 0; text-align: center; font-size: 12.5px; color: rgba(255, 255, 255, .62); pointer-events: none; }

/* toast */
.lf-toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 150; padding: 8px 15px; border-radius: 99px; white-space: nowrap; pointer-events: none;
  font-size: 13.5px; font-weight: 600; color: var(--bg-elev); background: var(--ink); box-shadow: var(--shadow-lg);
  opacity: 0; transform: translate(-50%, 10px); transition: opacity .18s, transform .18s;
}
.lf-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* =========================================================
   จอใหญ่ (> 860px): แถบบนเป็นการ์ดลอยใต้แถบเว็บ, ปุ่มลอยติดขอบล่างเฉพาะตอนคำอธิบายยาว
   ========================================================= */
@media (min-width: 861px) {
  .lf-bar {
    top: calc(var(--lf-top) + 10px); margin: 0 0 14px; min-height: 58px; padding: 7px 10px 7px 7px;
    background: color-mix(in srgb, var(--bg-elev) 94%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
    border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  }
  /* ปิดช่องว่างระหว่างแถบเว็บกับแถบนี้ ไม่ให้เนื้อหาโผล่ตอนเลื่อน */
  .lf-bar::before { content: ''; position: absolute; left: -2px; right: -2px; bottom: calc(100% + 1px); height: 12px; background: var(--bg); }
  .lf-hb { height: 40px; min-width: 40px; padding: 0 12px; border: 1px solid var(--line); background: var(--bg-elev); }
  .lf-hb svg.i { width: 18px; height: 18px; }
  .lf-hnav { gap: 6px; margin-left: 2px; }
  .lf-hnav .lf-hb { padding: 0; }
  .lf-hprog { padding: 0 6px; }
  .lf-qgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  /* ปุ่มลอยติดขอบล่างตอนคำอธิบายยาวเกินจอ — ลอยเฉพาะตัวปุ่ม ไม่มีแถบทับเนื้อหา */
  .lf-actbar { position: sticky; bottom: 16px; z-index: 25; pointer-events: none; }
  .lf-actbar.is-hint { display: none; }
  .lf-drow > * { pointer-events: auto; }
  .lf-drow > .lf-sp { pointer-events: none; }
  .lf-actbar .btn { transition: box-shadow .15s; }
  .lf-actbar.stuck .btn { box-shadow: 0 2px 4px rgba(16,24,40,.08), 0 12px 28px -8px rgba(16,24,40,.35); }
  .lf-actbar.stuck .btn.ghost { background: var(--bg-elev); border-color: var(--line-strong); }
  .lf-resbtns { flex-direction: row; }
  .lf-rb-main { flex: 1.25 1 0; }
  .lf-rb-2 { flex: 2 1 0; }
  .lf-sheet .lf-ncount { display: flex; }
}

/* =========================================================
   มือถือ / แท็บเล็ต (≤ 860px)
   ========================================================= */
@media (max-width: 860px) {
  .lf { --lf-qfs: 17px; --lf-qth: 15.5px; --lf-ofs: 16px; --lf-oth: 14px; }
  .lf.fs-l { --lf-qfs: 19px; --lf-qth: 17px; --lf-ofs: 17.5px; --lf-oth: 15.5px; }
  .lf-head h1 { font-size: 23px; margin-bottom: 0; }
  .lf .lf-head .eyebrow { margin-bottom: 8px; }
  .lf-home .lf-head { margin-bottom: 14px; }
  .lf-home .lf-head .lead { display: none; }   /* ให้ปุ่มเริ่มขึ้นมาในจอแรก */
  .lf-tipgrid, .lf-dgrid { grid-template-columns: 1fr; }
  .lf .lf-tip { display: grid; grid-template-columns: 34px minmax(0, 1fr); column-gap: 12px; align-items: start; padding: 14px 16px; }
  .lf-tip-ic { grid-row: span 2; margin: 2px 0 0; }
  .lf-dgrid { gap: 22px; }

  /* ---------- แถบบนของหน้าทำข้อสอบ (แทนแถบเว็บ) ---------- */
  .lf-bar {
    margin: 0 calc(-1 * var(--lf-gr)) 0 calc(-1 * var(--lf-gl));
    height: calc(50px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) calc(var(--lf-gr) - 8px) 0 calc(var(--lf-gl) - 10px);
    gap: 8px;
    background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
    -webkit-backdrop-filter: saturate(1.5) blur(14px); backdrop-filter: saturate(1.5) blur(14px);
    border-bottom: 1px solid var(--line);
  }
  .lf-hb-t, .lf-score, .lf .lf-bar .lf-hsub, .lf-prog .lf-pre, .lf-thbtn .l { display: none; }
  .lf-single .lf-prog .lf-pre { display: inline; }
  .lf-single .lf-prog { padding-left: 2px; }
  .lf-timer { padding: 3px 8px; font-size: 14px; }
  .lf-timer svg.i { width: 14px; height: 14px; }

  /* การ์ดโจทย์เต็มความกว้าง (ไม่มีกรอบ) ; ตัวเลือกเป็นพื้นขาวบนพื้นเทา */
  .lf-play { --lf-opt-bg: var(--bg-elev); --lf-chip-bg: var(--bg); padding-bottom: calc(var(--lf-dock-h) + 28px); }
  .lf-play .lf-card { margin: 0; padding: 14px 0 4px; background: none; border: 0; border-radius: 0; box-shadow: none; }
  .lf-play .lf-qhead { margin-bottom: 10px; }
  .lf .cq-opt { min-height: 52px; padding: 13px 14px; gap: 12px; }
  .lf .cq-opts { gap: 10px; }
  .lf .cq-mark { width: 28px; height: 28px; }
  /* "ที่เลือก" เป็นป้ายเล็กบนขอบบนของตัวเลือก — ไม่กินที่ข้อความ */
  .lf .cq-opt .lf-you { position: absolute; top: -9px; right: 12px; padding: 0 8px; font-size: 11px; line-height: 16px; }
  .lf-play:not(.is-exam) .lf-pend { display: none; }   /* คำบอกอยู่ที่แถบล่างแทน */
  .lf-palwrap { display: none; }                      /* ผังข้อเปิดเป็น sheet */

  /* ---------- แถบล่างเดียว: คำบอก / ปุ่มตรวจ / ผลตรวจ / เดินหน้า-ถอยหลัง ---------- */
  .lf-actbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; margin: 0;
    padding: 10px var(--lf-gr) calc(10px + env(safe-area-inset-bottom)) var(--lf-gl);
    background: color-mix(in srgb, var(--bg-elev) 95%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid var(--line); box-shadow: 0 -8px 24px -18px rgba(16, 24, 40, .4);
  }
  .lf-actbar.lf-up { animation: lfUp .28s cubic-bezier(.2, .8, .2, 1) both; }
  .lf-drow { min-height: 50px; }
  .lf-drow .lf-sp, .lf .lf-drow .lf-hide-m { display: none; }
  .lf-drow .btn.lg { flex: 1 1 0; min-width: 0; min-height: 52px; padding: 8px 14px; font-size: 16px; border-radius: 14px; }
  .lf-drow .btn.lg svg.i { width: 18px; height: 18px; }
  .lf-dhint { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0; font-size: 15px; font-weight: 600; color: var(--ink-2); }
  .lf-dhint.warn { color: var(--warn-ink); }
  .lf-actbar.is-hint .lf-drow { min-height: 30px; }
  .lf-actbar.is-hint .lf-dhint { justify-content: center; }
  .lf-actbar.is-check .lf-dhint { flex: 0 1 auto; font-size: 14px; color: var(--ink-3); }
  .lf-pips { display: inline-flex; gap: 6px; }
  .lf-pips i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--line-strong); }
  .lf-pips i.on { background: var(--final); border-color: var(--final); }

  /* ผลตรวจ (sheet สีตามผล): ถูก = เขียวอ่อน, ผิด = แดงอ่อน */
  .lf-actbar.is-fb {
    padding-top: 14px; border-top: 0; border-radius: 22px 22px 0 0;
    -webkit-backdrop-filter: none; backdrop-filter: none;
    box-shadow: 0 -1px 0 color-mix(in srgb, var(--ink) 8%, transparent), 0 -16px 36px -18px rgba(16, 24, 40, .4);
  }
  .lf-actbar.is-fb.ok { background: color-mix(in srgb, var(--lab-soft) 88%, var(--bg-elev)); }
  .lf-actbar.is-fb.bad { background: color-mix(in srgb, var(--exam-soft) 88%, var(--bg-elev)); }
  .lf-dfb { display: block; margin-bottom: 12px; }
  .lf-dv { display: flex; align-items: center; gap: 9px; min-height: 38px; }
  .lf-dv-ic { display: grid; place-items: center; flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; color: var(--on-lab); background: var(--lab); }
  .bad .lf-dv-ic { color: var(--on-exam); background: var(--exam); }
  .lf-dv-ic svg.i { width: 17px; height: 17px; stroke-width: 2.8; }
  .lf-dv b { flex: 0 0 auto; font-size: 19px; font-weight: 700; color: var(--lab-ink); }
  .bad .lf-dv b { color: var(--exam-ink); }
  .lf-dv-a { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 15.5px; font-weight: 600; color: var(--ink); }
  .lf-dv-a::before { content: '— '; color: var(--ink-3); }
  .lf .lf-drow .lf-dexp { display: inline-flex; flex: 0 0 auto; padding: 8px 16px; font-size: 15px; background: var(--bg-elev); }
  .lf .lf-drow .lf-dretry { flex: 0 0 52px; padding: 0; }
  .lf-dretry span { display: none; }
  .lf-dk {
    display: flex; align-items: flex-start; gap: 9px; margin-top: 10px; padding: 10px 12px; border-radius: 13px;
    font-size: 14.5px; line-height: 1.6; color: var(--ink); background: var(--bg-elev);
    border: 1px solid color-mix(in srgb, var(--ink) 7%, transparent);
  }
  .lf-dk svg.i { width: 18px; height: 18px; margin-top: 2px; color: var(--final-ink); }
  .lf-dk span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  /* ย่อเหลือบรรทัดเดียวตอนผลตรวจในหน้าโผล่ขึ้นมาแล้ว */
  .lf-actbar.is-fb.is-mini { display: flex; align-items: center; gap: 12px; padding-top: 10px; border-radius: 18px 18px 0 0; }
  .is-mini .lf-dfb { flex: 1 1 auto; min-width: 0; margin: 0; }
  .is-mini .lf-dk, .is-mini .lf-dv-pre, .lf .is-mini .lf-drow .lf-dexp { display: none; }
  .is-mini .lf-dv b { font-size: 17px; }
  .is-mini .lf-drow { flex: 0 0 auto; }
  .is-mini .lf-drow .btn.lg.lf-dnext { flex: 0 0 auto; padding: 8px 18px; }

  /* จำลองสอบ: ก่อนหน้า · ข้อ 3/50 (เปิดผังข้อ) · ถัดไป */
  .lf-actbar.is-nav .lf-drow { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .lf-dpal {
    display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 96px; height: 52px; padding: 0 12px;
    font-family: var(--font); color: var(--ink); background: var(--bg); border: 1px solid var(--line-strong); border-radius: 14px; cursor: pointer;
  }
  .lf-dpal b { font-size: 15.5px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
  .lf-dpal small { display: inline-flex; align-items: center; gap: 2px; font-size: 11.5px; line-height: 1.25; color: var(--ink-3); }
  .lf-dpal small svg.i { width: 13px; height: 13px; }
  .lf-dpal:active { background: var(--bg-sunken); }

  .lf-toast { bottom: max(calc(var(--lf-dock-h) + 14px), calc(20px + env(safe-area-inset-bottom))); }

  /* browse: ตัวกรองแถวเดียว เลื่อนข้างได้ (ซ่อน scrollbar มีขอบจางบอกว่าเลื่อนได้) */
  .lf-bchips { margin-left: calc(-1 * var(--lf-gl)); margin-right: calc(-1 * var(--lf-gr)); }
  .lf-bfil { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; padding: 2px var(--lf-gr) 4px var(--lf-gl); scroll-padding: 0 var(--lf-gr) 0 var(--lf-gl); }
  .lf-bfil::-webkit-scrollbar { display: none; }
  .lf-bchips::before, .lf-bchips::after {
    content: ''; position: absolute; top: 0; bottom: 0; z-index: 1; width: 28px; pointer-events: none; opacity: 0; transition: opacity .15s;
  }
  .lf-bchips::before { left: 0; background: linear-gradient(90deg, var(--bg), transparent); }
  .lf-bchips::after { right: 0; background: linear-gradient(270deg, var(--bg), transparent); }
  .lf-bchips.fl::before, .lf-bchips.fr::after { opacity: 1; }
  .lf-browse .lf-head .lead { font-size: 15px; line-height: 1.6; }
}
/* มือถือแนวนอน (จอเตี้ย): แถบผลตรวจเหลือบรรทัดเดียว ไม่บังทั้งจอ — จุดจำยังอยู่ในหน้า */
@media (max-width: 860px) and (max-height: 520px) {
  .lf-bar { height: calc(46px + env(safe-area-inset-top)); }
  .lf-actbar.is-fb { display: flex; align-items: center; gap: 12px; padding-top: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; }
  .lf-actbar.is-fb .lf-dfb { flex: 1 1 auto; min-width: 0; margin: 0; }
  .lf-actbar.is-fb .lf-dk { display: none; }
  .lf-actbar.is-fb .lf-drow { flex: 0 0 auto; min-height: 44px; }
  .lf-actbar .lf-drow .btn.lg { min-height: 44px; }
  .lf-actbar.is-fb .lf-drow .btn.lg.lf-dnext { flex: 0 0 auto; padding: 6px 18px; }
  .lf-actbar.is-nav .lf-drow, .lf-actbar.is-check .lf-drow { min-height: 44px; }
  .lf-dpal { height: 44px; }
  /* หน้าแรก: ให้ปุ่มเริ่มยังอยู่ในจอแรก ; sheet: หัว/ท้ายเตี้ยลง ให้เหลือที่ให้ตัวเลือก */
  .lf-home .lf-head .eyebrow { display: none; }
  .lf-home .lf-head { margin-bottom: 10px; }
  .lf-sheet { max-height: calc(100% - 10px - env(safe-area-inset-top)); }
  .lf-sh { padding-top: 16px; padding-bottom: 6px; }
  .lf-ssub, .lf-sf .lf-info { display: none; }
  .lf .lf-sgo { min-height: 46px; }
  .lf-sf { padding-top: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
}
/* มือถือแนวนอน: การ์ดวันนี้ + ปุ่มเริ่มวางคู่กัน ให้ปุ่มเริ่มอยู่ในจอแรก */
@media (min-width: 600px) and (max-width: 860px) and (max-height: 520px) {
  .lf-home { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); column-gap: 14px; align-items: start; }
  .lf-home > * { grid-column: 1 / -1; }
  .lf-home > .lf-today { grid-column: 1; }
  .lf-home > .lf-cta { grid-column: 2; }
}
@media (max-width: 560px) {
  .lf .card { padding: 16px; }
  .lf .lf-today { padding: 14px 16px 11px; gap: 12px 16px; }
  .lf-cd { min-width: 0; padding-right: 16px; }
  .lf-cd-n { font-size: 40px; }
  .lf-ring { width: 60px; height: 60px; }
  .lf-head .lead { font-size: 15.5px; line-height: 1.7; }
  .lf-frow { grid-template-columns: 1fr; gap: 8px; padding: 12px 0; }
  .lf-flbl { padding-top: 0; }
  .lf-flbl-empty { display: none; }
  .lf-seg { display: flex; flex-wrap: nowrap; width: 100%; }
  .lf-segb { flex: 1 1 0; min-width: 0; padding: 6px 10px; }
  .lf-ncount { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lf-ncus { grid-column: 1 / -1; justify-content: space-between; }
  .lf-pools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lf-pools .chip { justify-content: space-between; }
  .lf-modgrid { grid-template-columns: 1fr; }
  .lf-mapc .lf-legend { display: grid; grid-template-columns: repeat(2, max-content); gap: 4px 18px; }
  .lf-map { grid-template-columns: repeat(auto-fill, minmax(32px, 1fr)); gap: 4px; }
  .lf-cell { min-height: 30px; font-size: 11.5px; border-radius: 7px; }
  .lf-review .lf-card, .lf-rightlist .lf-card { padding: 15px 14px 16px; }
  .lf .lf-tile { padding: 8px; }
  .lf-mrow { padding: 11px 12px; }
  .lf-mchips, .lf-mfix { margin-left: 0; }
  .lf-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lf-rowbtn { gap: 10px; padding: 12px; }
  .lf-rid { min-width: 34px; }
  .lf-rowbody { padding: 0 12px 14px; }
}
@media (max-width: 380px) {
  .lf-qt { padding: 11px 11px 12px; }
  .lf-qt-t { font-size: 14.5px; }
  .lf-go { font-size: 17px; }
  .lf-bar { gap: 6px; }
  .is-exam .lf-thbtn .lf-thv { display: none; }
  .is-exam .lf-thbtn { padding: 2px 9px; }
}
/* iOS ซูมเข้าเองถ้าช่องกรอกตัวเล็กกว่า 16px */
@media (pointer: coarse) {
  .lf input, .lf textarea, .lf select,
  .lf .lf-ta, .lf .lf-search input, .lf .lf-ncus input { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .lf *, .lf *::before, .lf *::after { animation: none !important; transition: none !important; }
}
@media print {
  .lf-bar, .lf-actbar, .lf-kbdline, .lf-toast, .lf-sw { display: none !important; }
}
