/* ข้อสอบแปลบาลีพื้นฐาน (หลักสูตร พม.โดนี่)
   หน้าจอ = เครื่องมือจัดชุดข้อสอบ · กระดาษสอบจริงออกทาง PDF (js/pdf.js) ไม่ใช่ @media print
   ดีไซน์ (๘ ต.ค. ๒๕๖๙): ภาษาเดียวกับ /exam-bank — พื้นสว่าง ธีมคราม indigo ฟอนต์ Sarabun
   จอใหญ่ ๒ คอลัมน์ (หัวข้อ+รายการ | แผงสรุป+ปุ่มออก PDF ติดจอ) · มือถือปุ่มออก PDF เป็นแถบล่างติดจอ
   ตัวบาลี/เฉลยยังใช้ THSarabunPali เหมือนเดิม (ญ ฐ ไม่มีเชิง) — UI ใช้ Sarabun */
@font-face {
	font-family: 'THSarabunPali';
	src: url('/assets/fonts/THSarabunPali.ttf') format('truetype');
	font-display: swap;
}

:root {
	--ed-primary: #4f46e5;
	--ed-primary-dim: #4338ca;
	--ed-primary-soft: #e0e7ff;
	--ed-primary-wash: #eef2ff;
	--ed-accent: #047857;          /* สีเฉลย — โทนเขียวเดียวกับใบเฉลย */
	--ed-accent-soft: #ecfdf5;
	--ed-text: #1e293b;
	--ed-text-soft: #475569;
	--ed-text-muted: #64748b;
	--ed-line: #e2e8f0;
	--ed-surface: #f8fafc;
	--ed-surface-2: #f1f5f9;
	--ed-warn: #b45309;
	--ed-warn-soft: #fffbeb;
	--ed-bg: #f8fafc;
	--ed-pali: 'THSarabunPali', 'Sarabun', system-ui, sans-serif;
}
[v-cloak] { display: none !important; }

/* ⚠ ขนาดฐานต้องตั้งที่ `:root` ไม่ใช่ `html` หรือ `body` — เทมเพลตมี
   `:root { font-size: var(--bs-root-font-size) }` (specificity 0,1,0) ชนะ `html` เสมอ */
:root { font-size: 16px; }

.ed-body {
	margin: 0; background: var(--ed-bg); color: var(--ed-text);
	font-family: 'Sarabun', system-ui, sans-serif;
	font-size: 1rem; line-height: 1.55;
}
.ed-body button, .ed-body input { font-family: inherit; }

/* ── แถบย้อนกลับ (ลอกหน้าตา eb-backbar ของ /exam-bank) ── */
.ed-backbar { background: rgba(255,255,255,.75); border-bottom: 1px solid #e0e7ff; }
.ed-backbar-inner { max-width: 1040px; margin: 0 auto; padding: .55rem 1rem;
	display: flex; align-items: center; gap: .75rem; min-width: 0; }
.ed-back-link { display: inline-flex; align-items: center; gap: .45rem; flex-shrink: 0;
	padding: .38rem .8rem; border-radius: 999px; border: 1px solid #c7d2fe; background: #fff;
	color: var(--ed-primary); font-size: .85rem; font-weight: 700; text-decoration: none; transition: all .15s; }
.ed-back-link:hover { background: var(--ed-primary-wash); border-color: var(--ed-primary); color: var(--ed-primary); }
.ed-backbar-sub { color: var(--ed-text-soft); font-size: .85rem; font-weight: 600; white-space: nowrap;
	overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.ed-shell { max-width: 1040px; margin: 0 auto; padding: 1.1rem 1rem 3rem; }

/* ── หัวหน้า ── */
.ed-head { margin: .2rem 0 1.1rem; }
.ed-head h1 { margin: 0; font-size: clamp(1.5rem, 4.4vw, 2rem); font-weight: 800; color: var(--ed-text);
	letter-spacing: -.01em; line-height: 1.25; }
.ed-head h1 span { color: var(--ed-primary); }
.ed-head p { margin: .3rem 0 0; font-size: .9rem; color: var(--ed-text-soft); line-height: 1.6; }
.ed-head p b { font-weight: 700; color: var(--ed-text); }

.ed-loading { text-align: center; padding: 3.5rem 1rem; color: var(--ed-primary); font-size: 1rem; }
.ed-error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; padding: 1rem 1.2rem;
	border-radius: 14px; font-weight: 600; margin: 0; }
.ed-empty { color: var(--ed-text-muted); text-align: center; padding: 1.4rem .5rem; margin: 0; font-size: .9rem; }

/* ── โครง ๒ คอลัมน์ ── */
.ed-layout { display: grid; gap: 1.25rem; align-items: start; }
@media (min-width: 900px) { .ed-layout { grid-template-columns: minmax(0, 1fr) 300px; } }
.ed-main { display: grid; gap: 1.1rem; min-width: 0; }
.ed-label { margin: 0 0 .5rem; font-size: .8rem; font-weight: 800; color: var(--ed-text-soft); letter-spacing: .02em; }

.ed-card { background: #fff; border: 1px solid var(--ed-line); border-radius: 16px; padding: 1rem; }

/* ── หัวข้อสอบ ๘ หัวข้อ: แถวกะทัดรัด ── */
.ed-exams { display: grid; gap: .45rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.ed-exam { display: flex; align-items: center; gap: .65rem; text-align: left; cursor: pointer;
	background: #fff; border: 1.5px solid var(--ed-line); border-radius: 12px; padding: .5rem .75rem;
	min-height: 48px; font: inherit; color: inherit; transition: border-color .12s, background .12s; }
.ed-exam:hover { border-color: #a5b4fc; }
.ed-exam.on { border-color: var(--ed-primary); background: var(--ed-primary-wash);
	box-shadow: 0 0 0 1px var(--ed-primary) inset; }
.ed-exam-no { flex: none; width: 1.9rem; height: 1.9rem; display: grid; place-items: center; border-radius: 8px;
	font-weight: 800; font-size: .95rem; color: var(--ed-primary); background: var(--ed-primary-wash); }
.ed-exam.on .ed-exam-no { background: var(--ed-primary); color: #fff; }
.ed-exam-title { flex: 1; min-width: 0; font-family: var(--ed-pali); font-size: 1.35rem; line-height: 1.2; color: var(--ed-text); }
.ed-exam-meta { flex: none; font-size: .78rem; color: var(--ed-text-muted); font-variant-numeric: tabular-nums; }

/* ── การ์ดรายการโจทย์ ── */
.ed-listcard { padding: .9rem 1rem 1rem; }
.ed-list-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .75rem; }
.ed-list-title { margin: 0; flex: 1 1 auto; min-width: 0; font-family: var(--ed-pali); font-size: 1.45rem;
	font-weight: 700; line-height: 1.2; color: var(--ed-text); display: flex; align-items: center; gap: .5rem; }
.ed-list-no { flex: none; font-family: 'Sarabun', sans-serif; font-size: .78rem; font-weight: 800; color: #fff;
	background: var(--ed-primary); padding: .15rem .55rem; border-radius: 999px; }
.ed-count { flex: none; font-size: .8rem; font-weight: 700; color: var(--ed-primary); background: var(--ed-primary-wash);
	border: 1px solid #c7d2fe; border-radius: 999px; padding: .15rem .65rem; font-variant-numeric: tabular-nums; }

.ed-quick { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .6rem; }
.ed-quick-k { font-size: .8rem; font-weight: 800; color: var(--ed-text-soft); }
.ed-seg { display: flex; flex: 1 1 18rem; background: var(--ed-surface-2); border: 1px solid var(--ed-line);
	border-radius: 12px; padding: 3px; gap: 2px; max-width: 28rem; }
.ed-seg button { flex: 1 1 0; min-width: 0; font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer;
	white-space: nowrap; border: 0; background: transparent; color: var(--ed-text-soft); border-radius: 9px;
	padding: .42rem .35rem; }
.ed-seg button:hover { background: #fff; color: var(--ed-primary); box-shadow: 0 1px 3px rgba(15,23,42,.1); }

.ed-chaps { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .6rem; }
.ed-chap { font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; border-radius: 999px;
	padding: .25rem .7rem; background: #fff; border: 1px solid var(--ed-line); color: var(--ed-text-soft); }
.ed-chap b { font-weight: 800; color: var(--ed-primary); margin-left: .15rem; font-variant-numeric: tabular-nums; }
.ed-chap:hover { border-color: #a5b4fc; }
.ed-chap.on { background: var(--ed-primary); border-color: var(--ed-primary); color: #fff; }
.ed-chap.on b { color: #fff; }

.ed-list-bar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap;
	padding: .45rem 0; border-top: 1px solid var(--ed-line); font-size: .8rem; color: var(--ed-text-muted); }
.ed-hint i { color: #a5b4fc; margin-right: .15rem; }
.ed-switch { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; font-size: .85rem;
	font-weight: 600; color: var(--ed-text-soft); margin: 0; }
.ed-switch input { width: 1rem; height: 1rem; accent-color: var(--ed-primary); margin: 0; }

/* ── รายการโจทย์ (แถวแน่น) ── */
.ed-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ed-line); }
/* แถวเป็นกริด: เนื้อข้อใช้ display:contents ให้บาลีอยู่บรรทัดเดียวกับปุ่ม −/+ ส่วนเฉลยและป้ายกินเต็มความกว้าง */
.ed-item { display: grid; grid-template-columns: auto auto 1.6rem minmax(0, 1fr) auto; column-gap: .5rem;
	align-items: start; padding: .5rem .25rem; border-bottom: 1px solid var(--ed-line); background: #fff; }
.ed-item:last-child { border-bottom: none; }
.ed-item:hover { background: var(--ed-surface); }
.ed-item.off .ed-pali, .ed-item.off .ed-answer, .ed-item.off .ed-item-meta, .ed-item.off .ed-item-no { opacity: .45; }
.ed-item.sortable-chosen { background: var(--ed-primary-wash); border-radius: 10px; }
.ed-drag { grid-column: 1; grid-row: 1; color: #c7d2fe; cursor: grab; padding: .45rem .1rem 0; touch-action: none; font-size: .9rem; }
.ed-drag:hover { color: var(--ed-primary); }
.ed-check { grid-column: 2; grid-row: 1; margin: .5rem 0 0; width: 1.05rem; height: 1.05rem; accent-color: var(--ed-primary); cursor: pointer; }
.ed-item-no { grid-column: 3; grid-row: 1; text-align: right; color: var(--ed-primary); font-size: .9rem; font-weight: 800;
	padding-top: .32rem; font-variant-numeric: tabular-nums; }
.ed-item-body { display: contents; }
.ed-pali { grid-column: 4; grid-row: 1; font-family: var(--ed-pali); font-size: 1.6rem; line-height: 1.25; color: var(--ed-text);
	word-break: keep-all; overflow-wrap: anywhere; padding-top: .1rem; }  /* ตัดบรรทัดที่ช่องว่างเท่านั้น — คำบาลีห้ามตัดกลางคำ */
.ed-answer { grid-column: 4 / -1; grid-row: 2; font-family: var(--ed-pali); font-size: 1.3rem; line-height: 1.3; color: var(--ed-accent); }
.ed-answer-tag { font-family: 'Sarabun', sans-serif; font-size: .68rem; font-weight: 700; color: var(--ed-accent);
	background: var(--ed-accent-soft); border: 1px solid #a7f3d0; border-radius: 6px; padding: 0 .3rem;
	margin-right: .25rem; vertical-align: .2em; }
.hide-answer .ed-answer { display: none; }
.ed-item-meta { grid-column: 4 / -1; grid-row: 3; display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .2rem; }
.ed-tag { font-size: .72rem; line-height: 1.5; color: var(--ed-text-muted); background: var(--ed-surface-2);
	border-radius: 999px; padding: 0 .5rem; }
.ed-tag-pali { font-family: var(--ed-pali); font-size: 1.25em; }
.ed-tag-pdf { color: var(--ed-primary); background: var(--ed-primary-wash); }
.ed-tag-warn, .ed-tag-ed { color: var(--ed-warn); background: var(--ed-warn-soft); }
.ed-tag-yok  { color: var(--ed-accent); background: var(--ed-accent-soft); }

.ed-item-tools { grid-column: 5; grid-row: 1; padding-top: .2rem; }
.ed-lines { display: inline-flex; align-items: center; border: 1px solid var(--ed-line);
	border-radius: 999px; overflow: hidden; background: #fff; }
.ed-lines b { min-width: 1.3rem; text-align: center; font-size: .85rem; font-weight: 700;
	color: var(--ed-text-soft); font-variant-numeric: tabular-nums; }
.ed-step { border: none; background: none; cursor: pointer; font: inherit; font-size: 1rem; font-weight: 700;
	line-height: 1; color: var(--ed-primary); padding: .3rem .5rem; }
.ed-step:hover:not(:disabled) { background: var(--ed-primary-wash); }
.ed-step:disabled { opacity: .3; cursor: not-allowed; }

/* ── ตัวเลือกพับเก็บ ── */
.ed-more { background: #fff; border: 1px solid var(--ed-line); border-radius: 12px; margin-top: .8rem; }
.ed-more > summary { list-style: none; cursor: pointer; padding: .6rem .85rem; font-size: .86rem; font-weight: 700;
	color: var(--ed-text-soft); display: flex; align-items: center; gap: .5rem; }
.ed-more > summary::-webkit-details-marker { display: none; }
.ed-more > summary small { font-weight: 500; color: var(--ed-text-muted); }
.ed-more > summary::after { content: '\f078'; font-family: 'Font Awesome 6 Free', 'Font Awesome 5 Free', 'FontAwesome';
	font-weight: 900; font-size: .7rem; margin-left: auto; transition: transform .15s; }
.ed-more[open] > summary::after { transform: rotate(180deg); }
.ed-more-body { padding: 0 .85rem .85rem; display: grid; gap: .6rem; justify-items: start; }
.ed-mini { border: 1px solid var(--ed-line); background: #fff; color: var(--ed-primary); border-radius: 999px;
	padding: .3rem .8rem; cursor: pointer; font: inherit; font-size: .84rem; font-weight: 700; }
.ed-mini small { font-weight: 500; color: var(--ed-text-muted); }
.ed-mini:hover { background: var(--ed-primary-wash); border-color: #a5b4fc; }

/* ── แผงสรุป ── */
.ed-side { display: grid; gap: .8rem; }
@media (min-width: 900px) { .ed-side { position: sticky; top: 1rem; } }
.ed-panel { background: #fff; border: 1px solid var(--ed-line); border-radius: 16px; padding: 1rem; }
.ed-panel-k { font-size: .78rem; font-weight: 700; color: var(--ed-text-muted); }
.ed-panel-v { font-size: 2.2rem; font-weight: 800; color: var(--ed-text); line-height: 1.1; font-variant-numeric: tabular-nums; }
.ed-panel-v small { font-size: 1rem; font-weight: 600; color: var(--ed-text-soft); }
.ed-panel-note { margin: .25rem 0 .85rem; font-size: .84rem; color: var(--ed-text-soft); }
.ed-panel-note b { color: var(--ed-text); }
.ed-panel-note.is-warn { color: var(--ed-warn); font-weight: 600; }

.ed-actbar { display: grid; gap: .5rem; }
.ed-actbar-sum { display: none; }
.ed-btn { font: inherit; font-size: .95rem; font-weight: 700; border-radius: 12px; padding: .7rem 1rem; cursor: pointer;
	border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
	white-space: nowrap; transition: background .15s, transform .15s; }
.ed-btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.ed-btn-primary { background: var(--ed-primary); color: #fff; box-shadow: 0 6px 16px rgba(79,70,229,.25); }
.ed-btn-primary:hover:not(:disabled) { background: var(--ed-primary-dim); transform: translateY(-1px); }
.ed-btn-answer { background: #fff; border-color: #a7f3d0; color: var(--ed-accent); }
.ed-btn-answer:hover:not(:disabled) { background: var(--ed-accent-soft); }
.ed-btn-ghost { background: #fff; border-color: var(--ed-line); color: var(--ed-primary); }
.ed-btn-ghost:hover:not(:disabled) { background: var(--ed-primary-wash); }

.ed-score-policy { margin-top: 0; }
.ed-score-policy .ed-more-body { font-size: .84rem; line-height: 1.6; color: var(--ed-text-soft); justify-items: stretch; gap: .35rem; }
.ed-score-policy strong { color: var(--ed-text); }
.ed-score-policy strong, .ed-score-policy .ed-more-body span { display: block; overflow-wrap: anywhere; }
.ed-score-policy code { font-family: inherit; font-size: 1em; color: var(--ed-primary); background: var(--ed-primary-wash);
	border-radius: 5px; padding: 0 .25rem; white-space: normal; overflow-wrap: anywhere; }

/* ── มือถือ: ปุ่มออก PDF เป็นแถบล่างติดจอ ── */
@media (max-width: 899px) {
	.ed-shell { padding-bottom: calc(6rem + env(safe-area-inset-bottom)); }
	.ed-actbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
		padding: .6rem 1rem calc(.6rem + env(safe-area-inset-bottom));
		background: rgba(255,255,255,.95); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
		border-top: 1px solid var(--ed-line); box-shadow: 0 -4px 16px rgba(15,23,42,.06);
		display: flex; align-items: center; gap: .45rem; }
	.ed-actbar-sum { display: block; flex: 1 1 auto; min-width: 0; font-size: .9rem; font-weight: 800; color: var(--ed-text);
		white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
	.ed-actbar-sum small { font-weight: 600; color: var(--ed-text-muted); font-size: .78rem; }
	.ed-actbar .ed-btn { flex: none; padding: .65rem .8rem; font-size: .9rem; box-shadow: none; }
	.ed-hide-sm { display: none; }
	.ed-panel-note { margin-bottom: 0; }
}
@media (max-width: 560px) {
	.ed-shell { padding-left: .75rem; padding-right: .75rem; }
	.ed-backbar-inner { padding-left: .75rem; padding-right: .75rem; }
	.ed-exams { grid-template-columns: 1fr; gap: .35rem; }
	.ed-exam { min-height: 40px; padding: .3rem .65rem; }
	.ed-exam-no { width: 1.65rem; height: 1.65rem; font-size: .85rem; }
	.ed-exam-title { font-size: 1.25rem; }
	.ed-listcard { padding: .8rem .7rem .9rem; }
	.ed-item { column-gap: .35rem; grid-template-columns: auto auto 1.3rem minmax(0, 1fr) auto; padding-left: 0; padding-right: 0; }
	.ed-pali { font-size: 1.5rem; }
	.ed-answer { font-size: 1.22rem; }
	.ed-seg { flex-basis: 100%; max-width: none; }
	.ed-step { padding: .3rem .4rem; }
	.ed-more > summary small { display: none; }
}
@media (max-width: 380px) {
	.ed-actbar { gap: .35rem; padding-left: .75rem; padding-right: .75rem; }
	.ed-actbar .ed-btn { padding: .6rem .65rem; }
	.ed-actbar-sum small { display: none; }
}

@media print { .no-print { display: none !important; } }
