/* ออกข้อสอบบาลีไวยากรณ์ (อัตนัย)
   หน้าจอ = เครื่องมือจัดชุด · ตอนพิมพ์ = กระดาษสอบ A4 อย่างเดียว
   ดีไซน์ (๘ ต.ค. ๒๕๖๙): ภาษาเดียวกับ /exam-bank — พื้นสว่าง ธีมคราม indigo ฟอนต์ Sarabun
   จอใหญ่ ๒ คอลัมน์ (ตั้งค่า+รายการ | แผงสรุป+ปุ่มออก PDF ติดจอ) · มือถือปุ่ม PDF เป็นแถบล่างติดจอ */
@font-face {
	font-family: 'THSarabunPali';
	src: url('/assets/fonts/THSarabunPali.ttf') format('truetype');
	font-display: swap;
}

:root {
	--em-primary: #4f46e5;
	--em-primary-dim: #4338ca;
	--em-primary-soft: #e0e7ff;
	--em-primary-wash: #eef2ff;
	--em-text: #1e293b;
	--em-text-soft: #475569;
	--em-text-muted: #64748b;
	--em-line: #e2e8f0;
	--em-surface: #f8fafc;
	--em-surface-2: #f1f5f9;
	--em-accent: #047857;
	--em-accent-soft: #ecfdf5;
	--em-danger: #dc2626;
	--em-warn: #b45309;
	--em-warn-soft: #fffbeb;
	--em-bg: #f8fafc;
	--em-pali: 'THSarabunPali', 'Sarabun', system-ui, sans-serif;
}
[v-cloak] { display: none; }

/* ⚠ ฟอนต์/ขนาดของ .em-body ต้องคงเดิม — กระดาษสอบ (.em-paper) สืบค่าจากตรงนี้ตอนสร้าง PDF แบบภาพ/พิมพ์ */
.em-body { margin: 0; background: var(--em-bg); color: var(--em-text);
	font-family: 'THSarabunPali', 'Sarabun', system-ui, sans-serif; font-size: 20px; }

/* ── แถบย้อนกลับ (ลอกหน้าตา eb-backbar ของ /exam-bank) ── */
.em-backbar { background: rgba(255,255,255,.75); border-bottom: 1px solid #e0e7ff;
	font-family: 'Sarabun', system-ui, sans-serif; font-size: 16px; line-height: 1.5; }
.em-backbar-inner { max-width: 1040px; margin: 0 auto; padding: .55rem 1rem;
	display: flex; align-items: center; gap: .75rem; min-width: 0; }
.em-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(--em-primary); font-size: .85rem; font-weight: 700; text-decoration: none; transition: all .15s; }
.em-back-link:hover { background: var(--em-primary-wash); border-color: var(--em-primary); color: var(--em-primary); }
.em-backbar-sub { color: var(--em-text-soft); font-size: .85rem; font-weight: 600; white-space: nowrap;
	overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.em-shell { max-width: 1040px; margin: 0 auto; padding: 1.1rem 1rem 3rem;
	font-family: 'Sarabun', system-ui, sans-serif; font-size: 16px; line-height: 1.55; }
.em-shell button, .em-shell input, .em-shell select { font-family: inherit; }
.em-loading { text-align: center; padding-top: 4rem; color: var(--em-text-soft); }
.em-loading i { font-size: 2rem; color: var(--em-primary); }
.em-loading p { margin-top: 1rem; }
.em-error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; padding: 1rem 1.2rem;
	border-radius: 14px; font-weight: 600; }

/* ── หัวหน้า ── */
.em-head { margin: .2rem 0 1.1rem; }
.em-head h1 { margin: 0; font-size: clamp(1.5rem, 4.4vw, 2rem); font-weight: 800; color: var(--em-text);
	letter-spacing: -.01em; line-height: 1.25; }
.em-head h1 span { color: var(--em-primary); }
.em-head p { margin: .3rem 0 0; font-size: .9rem; color: var(--em-text-soft); line-height: 1.6; }

/* ── โครง ๒ คอลัมน์ ── */
.em-layout { display: grid; gap: 1.25rem; align-items: start; }
@media (min-width: 900px) {
	.em-layout { grid-template-columns: minmax(0, 1fr) 300px; }
	.em-side { grid-column: 2; grid-row: 1 / span 2; align-self: start; }
	.em-saved { grid-column: 1; }
}
.em-layout { row-gap: 1rem; }
.em-main { display: grid; gap: 1rem; min-width: 0; }

.em-card { background: #fff; border: 1px solid var(--em-line); border-radius: 16px; padding: 1rem 1.1rem; min-width: 0; }
.em-card-title { font-size: 1rem; font-weight: 800; color: var(--em-text); margin: 0 0 .85rem;
	display: flex; align-items: center; gap: .5rem; }
.em-card-title > i { color: var(--em-primary); font-size: .9rem; }

.em-field { margin-bottom: .9rem; min-width: 0; }
.em-field > label { display: block; font-size: .8rem; font-weight: 800; color: var(--em-text-soft);
	letter-spacing: .02em; margin-bottom: .4rem; }
.em-field > label small { font-weight: 500; color: var(--em-text-muted); letter-spacing: 0; }
.em-row2 { display: grid; gap: 0 1rem; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr); }

.em-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.em-chip { border: 1px solid var(--em-line); background: #fff; color: var(--em-text-soft);
	border-radius: 9px; padding: .3rem .7rem; cursor: pointer; font: inherit; font-size: .85rem; font-weight: 600;
	transition: border-color .12s, background .12s; }
.em-chip:hover { border-color: #a5b4fc; color: var(--em-primary); }
.em-chip.on { background: var(--em-primary); border-color: var(--em-primary); color: #fff; }
.em-mini { border: none; background: none; color: var(--em-primary); cursor: pointer; font: inherit;
	font-size: .84rem; font-weight: 700; padding: .1rem .3rem; }
.em-mini-r { margin-left: auto; }
.em-link { border: 0; background: none; cursor: pointer; font: inherit; font-size: .82rem; font-weight: 700;
	color: var(--em-primary); padding: .25rem .4rem; border-radius: 8px; white-space: nowrap; }
.em-link:hover { background: var(--em-primary-wash); }

.em-select { width: 100%; box-sizing: border-box; padding: .45rem .65rem; border: 1px solid var(--em-line); border-radius: 10px;
	font: inherit; font-size: .92rem; background: #fff; color: var(--em-text); min-height: 40px; }
.em-select:focus { outline: 2px solid var(--em-primary-soft); border-color: var(--em-primary); }
.em-check { display: flex; align-items: flex-start; gap: .45rem; margin: 0; font-size: .88rem; color: var(--em-text);
	cursor: pointer; line-height: 1.5; }
.em-check input { width: 1rem; height: 1rem; margin-top: .2rem; accent-color: var(--em-primary); flex: none; }
.em-check small { color: var(--em-text-muted); }
.em-warn { color: var(--em-warn); }

/* ปุ่มแบ่งช่อง (segmented) */
.em-seg { display: flex; background: var(--em-surface-2); border: 1px solid var(--em-line); border-radius: 12px; padding: 3px; gap: 2px; }
.em-seg-btn { flex: 1 1 0; min-width: 0; font: inherit; font-size: .86rem; font-weight: 700; cursor: pointer; white-space: nowrap;
	border: 0; background: transparent; color: var(--em-text-soft); border-radius: 9px; padding: .45rem .5rem; min-height: 36px; }
.em-seg-btn small { font-weight: 600; color: var(--em-text-muted); font-size: .76rem; }
.em-seg-btn:hover { color: var(--em-primary); }
.em-seg-btn.on { background: #fff; color: var(--em-primary); box-shadow: 0 1px 3px rgba(15,23,42,.12); }
.em-seg-btn.on small { color: var(--em-primary); }
.em-seg-wrap { flex-wrap: wrap; }
.em-seg-wrap .em-seg-btn { flex: 1 1 auto; }
.em-seg-fit { max-width: 22rem; }

.em-count { display: flex; align-items: stretch; border: 1px solid var(--em-line); border-radius: 12px; overflow: hidden; background: #fff; }
.em-count .em-select { border: 0; border-radius: 0; text-align: center; font-weight: 800; min-width: 0; -moz-appearance: textfield; }
.em-count .em-select::-webkit-inner-spin-button, .em-count .em-select::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.em-step { flex: none; width: 2.6rem; border: 0; background: var(--em-surface-2); color: var(--em-primary); font: inherit;
	font-size: 1.1rem; font-weight: 800; cursor: pointer; }
.em-step:hover:not(:disabled) { background: var(--em-primary-wash); }
.em-step:disabled { opacity: .35; cursor: not-allowed; }

/* ── ตัวเลือกพับเก็บ ── */
.em-more { background: #fff; border: 1px solid var(--em-line); border-radius: 12px; }
.em-more > summary { list-style: none; cursor: pointer; padding: .6rem .85rem; font-size: .86rem; font-weight: 700;
	color: var(--em-text-soft); display: flex; align-items: center; gap: .5rem; min-width: 0; white-space: nowrap; }
.em-more > summary::-webkit-details-marker { display: none; }
.em-more > summary > i { color: var(--em-text-muted); font-size: .8rem; }
.em-more > summary small { font-weight: 500; color: var(--em-text-muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-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; padding-left: .3rem; transition: transform .15s; }
.em-more[open] > summary::after { transform: rotate(180deg); }
.em-more-body { padding: 0 .85rem .85rem; display: grid; gap: .7rem; }
.em-more-body .em-field { margin-bottom: 0; }

.em-draw { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
	margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--em-line); }
.em-pool { font-size: .9rem; color: var(--em-text-soft); }
.em-pool b { font-size: 1.15rem; font-weight: 800; color: var(--em-text); }
.em-pool small { color: var(--em-text-muted); }
.em-pool .em-warn { display: block; font-size: .82rem; font-weight: 600; }

.em-btn { border: 1px solid transparent; border-radius: 12px; padding: .65rem 1.1rem; font: inherit; font-size: .95rem;
	font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
	white-space: nowrap; text-decoration: none; transition: background .15s, transform .15s; }
.em-btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.em-btn-primary { background: var(--em-primary); color: #fff; box-shadow: 0 6px 16px rgba(79,70,229,.25); }
.em-btn-primary:hover:not(:disabled) { background: var(--em-primary-dim); color: #fff; transform: translateY(-1px); }
.em-btn-answer { background: #fff; border-color: #a7f3d0; color: var(--em-accent); }
.em-btn-answer:hover:not(:disabled) { background: var(--em-accent-soft); }
.em-btn-ghost { background: #fff; color: var(--em-primary); border-color: var(--em-line); }
.em-btn-ghost:hover:not(:disabled) { background: var(--em-primary-wash); color: var(--em-primary); }

/* ── รายการข้อ (แถวแน่น) ── */
.em-list-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .35rem; }
.em-list-title { flex: 1 1 12rem; min-width: 0; margin: 0; }
.em-list-title span { min-width: 0; overflow-wrap: anywhere; }
.em-badge { flex: none; font-size: .78rem; font-weight: 700; color: var(--em-primary); background: var(--em-primary-wash);
	border: 1px solid #c7d2fe; border-radius: 999px; padding: .1rem .6rem; }
.em-list-hint { display: flex; flex-wrap: wrap; gap: .2rem .9rem; margin: 0 0 .5rem; font-size: .76rem; color: var(--em-text-muted); }
.em-list-hint i { color: #a5b4fc; margin-right: .15rem; }

.em-list { list-style: none; margin: 0; padding: 0; }
.em-item { display: flex; gap: .55rem; align-items: flex-start; padding: .55rem .25rem; border-top: 1px solid var(--em-line); background: #fff; }
.em-list > .em-item[draggable="true"] { cursor: grab; }
.em-item:hover { background: var(--em-surface); }
.em-item.on { background: var(--em-primary-wash); }
.em-grip { color: #c7d2fe; font-size: .85rem; padding-top: .3rem; }
.em-item:hover .em-grip { color: var(--em-primary); }
.em-item-no { flex: none; min-width: 1.7rem; height: 1.7rem; display: grid; place-items: center; border-radius: 8px;
	font-size: .85rem; font-weight: 800; color: var(--em-primary); background: var(--em-primary-wash); padding: 0 .25rem; }
.em-item-body { flex: 1; min-width: 0; }
.em-item-q { font-family: var(--em-pali); font-size: 1.3rem; line-height: 1.3; color: var(--em-text); overflow-wrap: anywhere; }
.em-item-meta { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .25rem; font-size: .72rem; color: var(--em-text-muted); }
.em-tag { line-height: 1.5; background: var(--em-surface-2); border-radius: 999px; padding: 0 .5rem; }
.em-tag-topic { color: var(--em-primary); background: var(--em-primary-wash); font-weight: 700; }
.em-tag-warn { color: var(--em-warn); background: var(--em-warn-soft); font-weight: 600; }
.em-item-tools { flex: none; display: flex; gap: .2rem; }
.em-icon { border: 1px solid var(--em-line); background: #fff; border-radius: 9px; width: 2rem; height: 2rem;
	cursor: pointer; color: var(--em-text-soft); font-size: .8rem; display: inline-grid; place-items: center; padding: 0; }
.em-icon:hover { border-color: #a5b4fc; color: var(--em-primary); background: var(--em-primary-wash); }
.em-icon-danger { color: var(--em-danger); }
.em-icon-danger:hover { border-color: #fecaca; color: var(--em-danger); background: #fef2f2; }

.em-sets .em-item { cursor: default; }
.em-set-owner { margin: 0 0 .5rem; font-size: .8rem; color: var(--em-text-muted); }
.em-set-owner i { color: #a5b4fc; margin-right: .2rem; }
.em-set-name { font-size: .95rem; font-weight: 700; color: var(--em-text); }
.em-set-meta { display: block; font-size: .76rem; margin-top: .05rem; }

.em-empty { color: var(--em-text-muted); text-align: center; padding: 1rem .5rem; margin: 0; font-size: .9rem; }
.em-empty a { color: var(--em-primary); font-weight: 700; }
.em-empty-card .em-empty i { color: #a5b4fc; margin-right: .3rem; }

/* ── แผงสรุป ── */
.em-side { display: grid; gap: .8rem; min-width: 0; }
@media (min-width: 900px) { .em-side { position: sticky; top: 1rem; } }
.em-panel { background: #fff; border: 1px solid var(--em-line); border-radius: 16px; padding: 1rem; display: grid; gap: .65rem; }
.em-panel-k { font-size: .78rem; font-weight: 700; color: var(--em-text-muted); }
.em-panel-v { font-size: 2.2rem; font-weight: 800; color: var(--em-text); line-height: 1.1; margin-top: -.55rem; }
.em-panel-v small { font-size: 1rem; font-weight: 600; color: var(--em-text-soft); }
.em-panel-name { margin: -.35rem 0 0; font-size: .9rem; font-weight: 700; color: var(--em-text); overflow-wrap: anywhere; }
.em-panel-note { margin: -.45rem 0 0; font-size: .8rem; color: var(--em-text-muted); }
.em-panel-note .fa-circle-check { color: var(--em-accent); }
.em-panel .em-more { border-radius: 10px; }
.em-panel .em-more > summary { padding: .5rem .7rem; }
.em-panel .em-more-body { padding: 0 .7rem .7rem; gap: .45rem; }
.em-panel .em-check { flex-wrap: wrap; }
.em-panel .em-check small { flex-basis: 100%; padding-left: 1.45rem; line-height: 1.45; }
.em-actbar { display: grid; gap: .5rem; }
.em-actbar-sum { display: none; }
.em-side-actions { display: grid; gap: .45rem; }
.em-side-actions .em-btn { padding: .55rem .9rem; font-size: .88rem; }

/* ── เลือกข้อเอง (หน้าต่าง) ── */
.em-modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; z-index: 60; padding: 1rem; }
.em-modal-box { background: #fff; border-radius: 16px; padding: 1rem 1.1rem; max-width: 720px; width: 100%; max-height: 80vh;
	display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(15,23,42,.25); box-sizing: border-box; }
.em-modal-box h3 { margin: 0 0 .7rem; display: flex; align-items: center; font-size: 1.05rem; font-weight: 800; color: var(--em-text); }
.em-picker-list { list-style: none; margin: .6rem 0 0; padding: 0; overflow: auto; }
.em-picker-list li { padding: .5rem .5rem; border-top: 1px solid var(--em-line); cursor: pointer; border-radius: 8px; }
.em-picker-list li:hover { background: var(--em-primary-wash); }
.em-picker-meta { display: block; font-size: .76rem; font-weight: 600; color: var(--em-text-muted); }
.em-picker-q { display: block; font-family: var(--em-pali); font-size: 1.25rem; line-height: 1.3; color: var(--em-text); }

/* ── กระดาษสอบ ── (⚠ ไม่ได้แก้ตอนปรับดีไซน์ ๘ ต.ค. ๒๕๖๙ — กระดาษสืบฟอนต์ THSarabunPali 20px จาก .em-body
   จึงคง .em-body ไว้ตามเดิม แล้วตั้ง Sarabun ที่ .em-shell / .em-backbar แทน)
   สไตล์อยู่นอก @media print เพราะใช้ 2 ทาง: พิมพ์ผ่านเบราว์เซอร์ กับสร้าง PDF ด้วย html2pdf
   ถ้าเก็บไว้ใน @media print ตอนสร้าง PDF จะได้กระดาษเปล่า (เคยพลาดมาแล้ว) */
.em-paper { display: none; background: #fff; color: #000; font-size: 16pt; }
/* ⚠ ห้ามใช้ position:fixed หรือ left:-9999px ตอนสร้าง PDF
   html2canvas จะได้กระดาษเปล่า (วัดแล้ว 3 KB เทียบกับ 388 KB)
   ต้องอยู่ในโฟลว์ปกติ แล้วใช้ .em-veil บังตาแทน
   ⚠ และต้องซ่อน UI ทั้งหมดด้วย (body.pdf-mode) ไม่งั้นกระดาษอยู่ท้ายโฟลว์
   จะได้หน้าว่างนำหน้าและเนื้อหาเลื่อนกลางหน้า
   ความกว้าง 184mm = A4 210mm ลบระยะขอบซ้ายขวา 13mm ที่ตั้งไว้ใน html2pdf */
.em-paper.showing { display: block; width: 184mm; }
.pdf-mode .em-shell, .pdf-mode .em-appbar, .pdf-mode .em-backbar { display: none !important; }
.pdf-mode { margin: 0; }

.em-paper-head { text-align: center; margin-bottom: 1rem; }
.em-paper-head h1 { font-size: 20pt; margin: 0 0 .2rem; }
.em-paper-org { font-size: 15pt; color: #444; }
.em-paper-fields { display: flex; justify-content: space-between; gap: 1rem; margin-top: .8rem; font-size: 14pt; }
.em-paper-note { margin-top: .6rem; text-align: left; border-top: 1px solid #000;
	border-bottom: 1px solid #000; padding: .25rem 0; font-size: 14pt; }
.em-paper-key { font-weight: bold; }

.em-paper-list { list-style: none; margin: 0; padding: 0; }
/* ห้ามให้ข้อหนึ่งถูกตัดคนละหน้า ครูตรวจแล้วสับสน */
.em-paper-item { break-inside: avoid; page-break-inside: avoid; margin-bottom: .9rem; }
.em-paper-q { display: flex; gap: .4rem; line-height: 1.45; }
.em-paper-num { min-width: 1.6rem; }
.em-paper-ctx { display: block; font-style: italic; color: #333; white-space: pre; }
.em-paper-qbody { display: block; }
/* แต่ละบรรทัดเป็นบล็อกและห้ามตัดซ้ำ — กันตัวอักษรทับกันตอนแปลงเป็นภาพ */
.em-paper-ln { display: block; white-space: pre; }

.em-paper-lines { margin: .35rem 0 0 2rem; }
.em-paper-line { border-bottom: 1px dotted #999; height: 1.55em; }

/* "เฉลย" เป็นบล็อกของตัวเอง — html2canvas วาด inline ปนข้อความยาวหลายบรรทัดผิด
   (ตัวอักษรบรรทัดถัดไปทับบรรทัดก่อนหน้า) */
.em-paper-a { margin: .3rem 0 0 2rem; line-height: 1.45; }
.em-paper-a-tag { display: block; font-weight: bold; }

.em-paper-src { font-size: 12pt; color: #555; margin-top: .1rem; }

/* ม่านบังตอนสร้าง PDF — กระดาษต้องอยู่ในจอจริง html2canvas ถึงจะวาดออก */
.em-veil { position: fixed; inset: 0; background: rgba(248,250,252,.96); z-index: 60;
	display: grid; place-items: center; font-family: 'Sarabun', system-ui, sans-serif; font-size: 16px; font-weight: 700;
	color: var(--em-primary); }


@media print {
	@page { size: A4; margin: 16mm 15mm 18mm; }
	.no-print, .em-appbar, .em-backbar { display: none !important; }
	.em-body { background: #fff; }
	.em-paper { display: block; width: auto; }
}

/* กล่อง SweetAlert2 ให้เข้ากับหน้า — ฟอนต์บาลีด้วย เผื่อชื่อชุดมีศัพท์บาลี */
.em-swal { font-family: 'THSarabunPali', 'Sarabun', system-ui, sans-serif; border-radius: 16px; }
.em-swal .swal2-title { font-size: 1.35rem; color: var(--em-text); }
.em-swal .swal2-html-container { font-size: 1.05rem; color: var(--em-text-soft); }
.em-swal .swal2-input { font: inherit; font-size: 1.05rem; }
.em-swal .swal2-confirm, .em-swal .swal2-cancel { font: inherit; font-size: 1.02rem; border-radius: 10px; }

/* ── ปี: ปุ่มช่วงปี + ตั้งแต่–ถึง + รายปีแบบแถวทศวรรษ ── */
.em-range { display: flex; align-items: center; gap: .5rem; margin-top: .55rem; flex-wrap: wrap; font-size: .88rem; }
.em-range .em-select { width: auto; min-width: 7rem; }
.em-range span { color: var(--em-text-soft); }
.em-year-sum { display: flex; align-items: center; justify-content: space-between; gap: .5rem .75rem; flex-wrap: wrap;
	margin-top: .55rem; padding: .4rem .7rem; border-radius: 10px; background: var(--em-primary-wash); font-size: .86rem; color: var(--em-text); }
.em-year-sum i.fa-calendar-days { color: var(--em-primary); margin-right: .3rem; }
.em-year-sum .em-mini { white-space: nowrap; }
.em-decades { margin-top: .55rem; border: 1px solid var(--em-line); border-radius: 12px; padding: .35rem .7rem; }
.em-decade { display: flex; align-items: center; gap: .6rem; padding: .3rem 0; }
.em-decade + .em-decade { border-top: 1px dashed var(--em-line); }
.em-decade-label { flex: 0 0 3rem; font-size: .8rem; color: var(--em-text-muted); font-weight: 700; }
.em-chip-yr { min-width: 2.4rem; padding: .2rem .45rem; text-align: center; font-variant-numeric: tabular-nums; }

/* ── มือถือ: ปุ่ม PDF เป็นแถบล่างติดจอ · แผงสรุปอยู่ใต้รายการ ── */
@media (max-width: 899px) {
	.em-shell { padding-bottom: calc(6rem + env(safe-area-inset-bottom)); }
	.em-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(--em-line); box-shadow: 0 -4px 16px rgba(15,23,42,.06);
		display: flex; align-items: center; gap: .45rem; }
	.em-actbar-sum { display: block; flex: 1 1 auto; min-width: 0; font-size: .9rem; font-weight: 800; color: var(--em-text); white-space: nowrap; }
	.em-actbar .em-btn { flex: none; padding: .65rem .85rem; font-size: .9rem; box-shadow: none; }
	.em-hide-sm { display: none; }
	.em-side-actions { grid-template-columns: 1fr 1fr; }
	.em-side-actions .em-btn { white-space: normal; text-align: center; }
}
@media (max-width: 560px) {
	.em-shell { padding-left: .75rem; padding-right: .75rem; }
	.em-backbar-inner { padding-left: .75rem; padding-right: .75rem; }
	.em-card { padding: .85rem .8rem; }
	.em-row2 { grid-template-columns: 1fr; }
	.em-count { max-width: 12rem; }
	/* แถวข้อ: โจทย์เต็มความกว้าง · ป้ายกับปุ่มอยู่บรรทัดเดียวกัน */
	.em-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: .45rem; padding-left: 0; padding-right: 0; }
	.em-grip { display: none; }
	.em-item-no { grid-column: 1; grid-row: 1; }
	.em-item-body { display: contents; }
	.em-item-q, .em-set-name { grid-column: 2 / -1; grid-row: 1; }
	.em-item-meta { grid-column: 2; grid-row: 2; align-self: center; }
	.em-item-tools { grid-column: 3; grid-row: 2; align-self: start; margin-top: .2rem; }
	.em-seg-wrap { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.em-seg-wrap .em-seg-btn { font-size: .82rem; padding: .4rem .3rem; }
	.em-list-hint { display: none; }
	.em-side-actions { grid-template-columns: 1fr; }
	.em-decade { align-items: flex-start; }
	.em-decade-label { flex-basis: 2.6rem; padding-top: .25rem; }
	.em-draw .em-btn { flex: 1 1 100%; }
}
@media (max-width: 380px) {
	.em-actbar { gap: .35rem; padding-left: .75rem; padding-right: .75rem; }
	.em-actbar .em-btn { padding: .6rem .7rem; }
}
