.ms {
	--rp-olive: #B2BB1E;
	--rp-olive-dark: #5E6608;
	--rp-tint: #F5F7DC;
	--rp-ink: #26301A;
	--rp-muted: #5B6350;
	--rp-line: #DDE0CC;
	padding: 32px 0 48px;
}

/* ---------- สารบัญ 2 ชั้น ---------- */
.ms-groups { display: flex; gap: 8px; margin-bottom: 12px; }
.ms-groups a {
	flex: 1;
	padding: 12px 16px;
	font-size: 1.1rem;
	font-weight: 600;
	text-align: center;
	color: var(--rp-ink);
	text-decoration: none;
	background: #fff;
	border: 1px solid var(--rp-line);
	border-radius: 12px;
	transition: background-color .15s ease, color .15s ease;
}
.ms-groups a:hover { color: var(--rp-olive-dark); text-decoration: none; background: var(--rp-tint); }
.ms-groups a.on { color: #fff; background: var(--rp-olive-dark); border-color: var(--rp-olive-dark); }

.ms-items { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.ms-items a {
	padding: 6px 16px;
	font-size: 1rem;
	color: var(--rp-ink);
	text-decoration: none;
	background: #fff;
	border: 1px solid var(--rp-line);
	border-radius: 999px;
	transition: background-color .15s ease;
}
.ms-items a:hover { color: var(--rp-olive-dark); text-decoration: none; background: var(--rp-tint); }
.ms-items a.on { color: var(--rp-olive-dark); background: var(--rp-tint); border-color: var(--rp-olive); }

.ms-groups a:focus-visible,
.ms-items a:focus-visible { outline: 3px solid var(--rp-olive-dark); outline-offset: 2px; }

/* ---------- กล่องเนื้อหา ---------- */
.ms-panel {
	padding: 20px 24px 24px;
	background: #fff;
	border: 1px solid var(--rp-line);
	border-radius: 14px;
	box-shadow: 0 1px 2px rgba(38, 48, 26, .06);
}
.ms-title {
	margin: 0 0 16px;
	padding-left: 14px;
	font-size: 1.5rem;
	font-weight: 600;
	line-height: 1.4;
	color: var(--rp-ink);
	border-left: 6px solid var(--rp-olive);
}

/* ---------- ค้นหา + กรองหมวด ---------- */
.ms-toolbar { margin-bottom: 16px; }
.ms-toolbar[hidden] { display: none; }
.ms-search {
	display: block;
	width: 100%;
	margin-bottom: 10px;
	padding: 10px 14px;
	font-size: 1rem;
	color: var(--rp-ink);
	border: 1px solid var(--rp-line);
	border-radius: 10px;
}
.ms-search:focus { outline: 3px solid var(--rp-olive); border-color: var(--rp-olive-dark); }
.ms-cats { display: flex; flex-wrap: wrap; gap: 8px; }
.ms-cats button {
	padding: 4px 14px;
	font-size: .95rem;
	color: var(--rp-ink);
	cursor: pointer;
	background: #fff;
	border: 1px solid var(--rp-line);
	border-radius: 999px;
}
.ms-cats button:hover { background: var(--rp-tint); }
.ms-cats button.on { color: #fff; background: var(--rp-olive-dark); border-color: var(--rp-olive-dark); }

/* ---------- รายการ (ซ้าย) + ตัวดู (ขวา) ---------- */
.ms-body {
	display: grid;
	grid-template-columns: minmax(260px, 1fr) minmax(0, 2fr);
	gap: 20px;
	align-items: start;
}
.ms-body.is-empty { grid-template-columns: 1fr; }
.ms-body.is-empty .ms-viewer { display: none; }

.ms-list { display: flex; flex-direction: column; gap: 8px; }
.ms-row {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	padding: 10px 12px;
	font-size: 1rem;
	line-height: 1.5;
	text-align: left;
	color: var(--rp-ink);
	cursor: pointer;
	background: #fff;
	border: 1px solid var(--rp-line);
	border-radius: 10px;
	transition: background-color .15s ease, border-color .15s ease;
}
.ms-row i { flex: none; width: 20px; font-size: 18px; text-align: center; color: var(--rp-olive-dark); }
.ms-row span { flex: 1; min-width: 0; }
.ms-row small { flex: none; color: var(--rp-muted); }
.ms-row:hover { background: var(--rp-tint); }
.ms-row.sel { background: var(--rp-tint); border-color: var(--rp-olive-dark); }
.ms-row:focus-visible,
.ms-more:focus-visible,
.ms-cats button:focus-visible,
.ms-btn:focus-visible,
.ms-back:focus-visible { outline: 3px solid var(--rp-olive-dark); outline-offset: 2px; }

.ms-more {
	padding: 8px;
	font-size: .95rem;
	color: var(--rp-olive-dark);
	cursor: pointer;
	background: transparent;
	border: 1px dashed var(--rp-olive-dark);
	border-radius: 10px;
}
.ms-more:hover { background: var(--rp-tint); }
.ms-empty { margin: 0; padding: 24px; text-align: center; color: var(--rp-muted); background: var(--rp-tint); border-radius: 10px; }

.ms-viewer {
	position: sticky;
	top: 16px;               /* ถ้าเมนูด้านบนเป็นแบบ fixed ให้เพิ่มตามความสูงเมนู */
	padding: 16px;
	border: 1px solid var(--rp-line);
	border-radius: 12px;
}
.ms-vhead { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.ms-vtitle { margin: 0; font-size: 1.1rem; font-weight: 600; line-height: 1.5; }
.ms-tag { padding: 2px 12px; font-size: .85rem; color: var(--rp-olive-dark); background: var(--rp-tint); border-radius: 999px; }
.ms-frame { height: clamp(420px, 70vh, 720px); }
.ms-frame iframe { display: block; width: 100%; height: 100%; border: 0; border-radius: 8px; background: #f4f4f4; }
.ms-img img { display: block; max-width: 100%; height: auto; border-radius: 8px; }
.ms-note { padding: 56px 24px; line-height: 1.7; text-align: center; color: var(--rp-muted); background: var(--rp-tint); border-radius: 10px; }
.ms-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ms-btn {
	display: inline-block;
	padding: 6px 18px;
	font-size: .95rem;
	color: var(--rp-olive-dark);
	text-decoration: none;
	border: 1px solid var(--rp-olive-dark);
	border-radius: 999px;
}
.ms-btn:hover { color: var(--rp-olive-dark); text-decoration: none; background: var(--rp-tint); }
.ms-btn--main { color: #fff; background: var(--rp-olive-dark); }
.ms-btn--main:hover { color: #fff; background: var(--rp-ink); }
.ms-back { display: none; }

/* ---------- มือถือ/แท็บเล็ต: กดรายการแล้วตัวดูแทนที่รายการ ---------- */
@media (max-width: 991.98px) {
	.ms-groups a { padding: 10px 8px; font-size: 1rem; }
	.ms-items { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
	.ms-items a { flex: none; white-space: nowrap; }
	.ms-panel { padding: 16px; }
	.ms-body { grid-template-columns: 1fr; }
	.ms .ms-viewer { display: none; position: static; padding: 12px; }
	.ms.is-viewing .ms-viewer { display: block; }
	.ms.is-viewing .ms-toolbar,
	.ms.is-viewing .ms-list { display: none; }
	.ms-back {
		display: inline-block;
		margin-bottom: 10px;
		padding: 6px 14px;
		font-size: .95rem;
		color: var(--rp-olive-dark);
		cursor: pointer;
		background: #fff;
		border: 1px solid var(--rp-olive-dark);
		border-radius: 999px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ms-groups a, .ms-items a, .ms-row { transition: none; }
}