.medex-detail-workspace {
	--md-blue: #2d8fe8;
	--md-blue-dark: #176ebb;
	--md-blue-soft: #eaf5ff;
	--md-green: #80d401;
	--md-green-soft: #effbdc;
	--md-ink: #13243a;
	--md-text: #34485f;
	--md-muted: #66758a;
	--md-line: #dce5ee;
	--md-surface: #ffffff;
	--md-bg: #f5f8fb;
	width: 100%;
	color: var(--md-ink);
	font-family: "Noto Sans Thai", "IBM Plex Sans Thai", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.medex-detail-workspace,
.medex-detail-workspace * { box-sizing: border-box; }

.medex-detail-workspace a { text-decoration: none; }

.medex-detail-shell {
	width: min(1220px, 100%);
	margin: 0 auto;
}

.medex-detail-back {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	margin-bottom: 18px;
	color: var(--md-blue-dark);
	font-size: 13px;
	font-weight: 800;
}

.medex-detail-back:hover { color: #0f568f; }

.medex-detail-hero {
	overflow: hidden;
	background: var(--md-surface);
	border: 1px solid var(--md-line);
	border-radius: 24px;
	box-shadow: 0 18px 48px rgba(25, 53, 84, .10);
}

.medex-detail-stage {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: #081f35;
}

.medex-detail-stage iframe,
.medex-detail-stage video,
.medex-detail-stage .wp-video,
.medex-detail-stage .wp-video-shortcode {
	width: 100% !important;
	height: 100% !important;
}

.medex-detail-stage__fallback {
	display: grid;
	place-items: center;
	width: 100%;
	height: 100%;
	padding: 24px;
	text-align: center;
	background: linear-gradient(135deg, #10283e, #176ebb);
}

.medex-detail-stage__fallback a {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	padding: 12px 18px;
	color: #fff;
	background: var(--md-blue);
	border-radius: 12px;
	font-weight: 800;
}

.medex-detail-header {
	padding: clamp(22px, 4vw, 38px);
}

.medex-detail-badges,
.medex-detail-meta,
.medex-detail-specialties {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.medex-detail-badge {
	display: inline-flex;
	align-items: center;
	min-height: 30px;
	padding: 6px 10px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 850;
	line-height: 1;
	letter-spacing: .025em;
}

.medex-detail-badge--format {
	color: var(--md-blue-dark);
	background: var(--md-blue-soft);
	border: 1px solid rgba(45, 143, 232, .20);
}

.medex-detail-badge--cme {
	color: #365314;
	background: var(--md-green-soft);
	border: 1px solid rgba(128, 212, 1, .32);
}

.medex-detail-title {
	max-width: 1020px;
	margin: 16px 0 0;
	color: var(--md-ink);
	font-size: clamp(30px, 4.5vw, 52px);
	font-weight: 850;
	line-height: 1.18;
	letter-spacing: -.035em;
}

.medex-detail-lead {
	max-width: 920px;
	margin: 15px 0 0;
	color: var(--md-muted);
	font-size: 16px;
	line-height: 1.75;
}

.medex-detail-meta { margin-top: 18px; }

.medex-detail-meta span {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: #536579;
	font-size: 12px;
	font-weight: 700;
}

.medex-detail-tabs {
	position: sticky;
	top: 10px;
	z-index: 20;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 24px 0;
	padding: 10px;
	background: rgba(255,255,255,.94);
	border: 1px solid var(--md-line);
	border-radius: 16px;
	box-shadow: 0 10px 28px rgba(25,53,84,.08);
	backdrop-filter: blur(14px);
}

.medex-detail-tab {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 40px;
	padding: 9px 14px;
	color: var(--md-text);
	background: #f6f8fa;
	border: 1px solid transparent;
	border-radius: 10px;
	font-size: 12px;
	font-weight: 800;
}

.medex-detail-tab:hover,
.medex-detail-tab.is-active {
	color: #fff;
	background: var(--md-blue-dark);
}

.medex-detail-layout {
	display: grid;
	grid-template-columns: minmax(0, 1.45fr) minmax(290px, .55fr);
	gap: 22px;
	align-items: start;
}

.medex-detail-main,
.medex-detail-side-card,
.medex-detail-test,
.medex-related-section {
	background: var(--md-surface);
	border: 1px solid var(--md-line);
	border-radius: 20px;
	box-shadow: 0 10px 28px rgba(25,53,84,.055);
}

.medex-detail-main { padding: clamp(22px, 4vw, 34px); }

.medex-detail-section-label {
	display: block;
	margin-bottom: 7px;
	color: var(--md-blue-dark);
	font-size: 11px;
	font-weight: 900;
	letter-spacing: .08em;
	text-transform: uppercase;
}

.medex-detail-main h2,
.medex-detail-test h2,
.medex-related-heading h2 {
	margin: 0;
	color: var(--md-ink);
	font-size: clamp(23px, 3vw, 32px);
	line-height: 1.3;
}

.medex-detail-content {
	margin-top: 18px;
	color: var(--md-text);
	font-size: 15px;
	line-height: 1.8;
}

.medex-detail-content > :first-child { margin-top: 0; }
.medex-detail-content > :last-child { margin-bottom: 0; }

.medex-detail-side {
	display: grid;
	gap: 16px;
}

.medex-detail-side-card { padding: 20px; }

.medex-detail-side-card h3 {
	margin: 0 0 13px;
	color: var(--md-ink);
	font-size: 16px;
}

.medex-detail-speakers {
	display: grid;
	gap: 12px;
}

.medex-detail-speaker + .medex-detail-speaker {
	padding-top: 12px;
	border-top: 1px dashed #e2e8ee;
}

.medex-detail-speaker strong,
.medex-detail-speaker span { display: block; }
.medex-detail-speaker strong { color: #253b52; font-size: 14px; line-height: 1.5; }
.medex-detail-speaker span { margin-top: 2px; color: var(--md-muted); font-size: 12px; line-height: 1.5; }

.medex-detail-specialties { gap: 7px; }

.medex-detail-specialty {
	display: inline-flex;
	min-height: 29px;
	align-items: center;
	padding: 6px 10px;
	color: var(--md-blue-dark);
	background: var(--md-blue-soft);
	border: 1px solid rgba(45,143,232,.18);
	border-radius: 999px;
	font-size: 10px;
	font-weight: 800;
}

.medex-detail-cme-panel {
	background: linear-gradient(135deg, #f5ffe6, #eef9d9);
	border-color: rgba(128,212,1,.34);
}

.medex-detail-cme-value {
	display: block;
	color: #365314;
	font-size: 24px;
	font-weight: 900;
}

.medex-detail-cme-code {
	display: block;
	margin-top: 7px;
	color: #5b6f3c;
	font-size: 11px;
}

.medex-detail-test-link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 46px;
	margin-top: 14px;
	padding: 11px 15px;
	color: #fff;
	background: var(--md-blue-dark);
	border-radius: 11px;
	font-size: 12px;
	font-weight: 850;
}

.medex-detail-test {
	margin-top: 26px;
	padding: clamp(20px, 4vw, 32px);
	scroll-margin-top: 90px;
}

.medex-detail-test__heading {
	display: flex;
	align-items: end;
	justify-content: space-between;
	gap: 18px;
	margin-bottom: 18px;
}

.medex-detail-test__heading p {
	max-width: 690px;
	margin: 7px 0 0;
	color: var(--md-muted);
	font-size: 13px;
	line-height: 1.65;
}

.medex-detail-test__tools {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.medex-detail-test__tools button,
.medex-detail-test__tools a {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 38px;
	padding: 8px 12px;
	color: var(--md-blue-dark);
	background: var(--md-blue-soft);
	border: 1px solid rgba(45,143,232,.22);
	border-radius: 9px;
	cursor: pointer;
	font-size: 11px;
	font-weight: 800;
}

.medex-detail-form-frame {
	overflow: hidden;
	background: #f7f9fb;
	border: 1px solid #e1e7ed;
	border-radius: 14px;
}

.medex-detail-form-frame iframe {
	display: block;
	width: 100%;
	height: 980px;
	border: 0;
	background: #fff;
}

.medex-detail-test.is-expanded .medex-detail-form-frame iframe { height: 1500px; }

.medex-detail-test__external {
	display: grid;
	place-items: center;
	min-height: 250px;
	padding: 30px;
	text-align: center;
	background: linear-gradient(135deg, #f5f8fb, #eaf5ff);
	border-radius: 14px;
}

.medex-detail-test__external p { max-width: 560px; margin: 0 0 14px; color: var(--md-muted); }
.medex-detail-test__external a { display: inline-flex; min-height: 44px; align-items: center; padding: 10px 16px; color: #fff; background: var(--md-blue-dark); border-radius: 10px; font-weight: 800; }

.medex-related-section {
	margin-top: 26px;
	padding: clamp(20px, 4vw, 32px);
	scroll-margin-top: 90px;
}

.medex-related-heading {
	display: flex;
	align-items: end;
	justify-content: space-between;
	gap: 18px;
	margin-bottom: 18px;
}

.medex-related-heading p {
	max-width: 700px;
	margin: 7px 0 0;
	color: var(--md-muted);
	font-size: 13px;
}

.medex-related-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 16px;
}

.medex-related-card {
	display: flex;
	min-width: 0;
	flex-direction: column;
	overflow: hidden;
	background: #fff;
	border: 1px solid var(--md-line);
	border-radius: 16px;
	box-shadow: 0 8px 20px rgba(25,53,84,.05);
	transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

.medex-related-card:hover {
	transform: translateY(-4px);
	border-color: rgba(45,143,232,.35);
	box-shadow: 0 16px 32px rgba(25,53,84,.11);
}

.medex-related-card__media {
	position: relative;
	display: block;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: linear-gradient(135deg, #2d8fe8, #176ebb);
}

.medex-related-card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.medex-related-card:hover .medex-related-card__media img { transform: scale(1.03); }

.medex-related-card__badges {
	position: absolute;
	top: 11px;
	left: 11px;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.medex-related-card__badges span {
	display: inline-flex;
	min-height: 25px;
	align-items: center;
	padding: 5px 8px;
	color: #fff;
	background: rgba(16,40,62,.86);
	border-radius: 999px;
	font-size: 9px;
	font-weight: 850;
	backdrop-filter: blur(8px);
}

.medex-related-card__badges .is-cme { color: #365314; background: rgba(230,255,190,.95); }

.medex-related-card__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	padding: 16px;
}

.medex-related-card__reason {
	display: inline-flex;
	width: fit-content;
	margin-bottom: 8px;
	padding: 4px 8px;
	color: var(--md-blue-dark);
	background: var(--md-blue-soft);
	border-radius: 999px;
	font-size: 9px;
	font-weight: 850;
}

.medex-related-card h3 {
	display: -webkit-box;
	margin: 0;
	overflow: hidden;
	color: var(--md-ink);
	font-size: 16px;
	line-height: 1.45;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
}

.medex-related-card h3 a { color: inherit; }

.medex-related-card__meta,
.medex-related-card__speaker {
	margin-top: 8px;
	color: var(--md-muted);
	font-size: 11px;
	line-height: 1.55;
}

.medex-related-card__action {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 40px;
	margin-top: auto;
	padding: 10px 12px;
	color: #fff;
	background: var(--md-blue-dark);
	border-radius: 10px;
	font-size: 11px;
	font-weight: 850;
}

@media (max-width: 980px) {
	.medex-detail-layout { grid-template-columns: 1fr; }
	.medex-detail-side { grid-template-columns: repeat(2, minmax(0,1fr)); }
	.medex-related-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 680px) {
	.medex-detail-hero,
	.medex-detail-main,
	.medex-detail-side-card,
	.medex-detail-test,
	.medex-related-section { border-radius: 15px; }
	.medex-detail-header { padding: 20px 17px 22px; }
	.medex-detail-title { font-size: clamp(27px, 9vw, 38px); }
	.medex-detail-tabs { top: 6px; overflow-x: auto; flex-wrap: nowrap; }
	.medex-detail-tab { flex: 0 0 auto; }
	.medex-detail-side { grid-template-columns: 1fr; }
	.medex-detail-test__heading,
	.medex-related-heading { align-items: flex-start; flex-direction: column; }
	.medex-detail-form-frame iframe { height: 850px; }
	.medex-detail-test.is-expanded .medex-detail-form-frame iframe { height: 1400px; }
	.medex-related-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
	.medex-detail-workspace *,
	.medex-detail-workspace *::before,
	.medex-detail-workspace *::after { transition: none !important; scroll-behavior: auto !important; }
}
