.triplea-answer-media-control {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 8px;
}

.triplea-answer-media-control.is-loading {
	opacity: .65;
	pointer-events: none;
}

.triplea-answer-media-preview {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	overflow: hidden;
	border: 1px solid #dcdcde;
	border-radius: 4px;
	background: #f6f7f7;
}

.triplea-answer-media-preview:empty {
	display: none;
}

.triplea-answer-media-preview img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.triplea-answer-media-choose {
	min-height: 30px;
}

.triplea-answer-media-remove {
	font-size: 12px;
	line-height: 30px;
}

/*
 * LearnPress's modern question editor renders the answer row as a single
 * flex row. Use a small grid instead so the media controls sit below the
 * answer title and the correct-answer checkbox stays at the top of the row.
 */
.lp-question-answer-item {
	display: grid !important;
	grid-template-columns: 24px minmax(0, 1fr) 32px 28px;
	grid-template-areas:
		'drag title delete correct'
		'. media media .'
		'. math math .';
	align-items: start !important;
	column-gap: 5px;
	row-gap: 5px;
}

/*
 * LearnPress keeps one hidden answer row as a clone for creating new rows.
 * The grid rule above has !important, so explicitly preserve the hidden
 * state or the clone's delete icon can be clicked with answer ID 0.
 */
.lp-question-answer-item.clone,
.lp-question-answer-item.lp-hidden {
	display: none !important;
}

.lp-question-answer-item > .drag {
	grid-area: drag;
	align-self: center;
}

.lp-question-answer-item > .lp-icon-spinner {
	grid-area: drag;
	align-self: center;
}

.lp-question-answer-item > .lp-question-answer-title-input {
	grid-area: title;
	width: 100%;
	min-width: 0;
	margin: 0;
	align-self: start;
}

.lp-question-answer-item .triplea-answer-media-control {
	grid-area: media;
	min-width: 0;
	width: 100%;
	margin: 0 0 8px;
	box-sizing: border-box;
}

.lp-question-answer-item > .triplea-answer-math-preview {
	grid-area: math;
	}

.lp-question-answer-item > .lp-icon-trash-o {
	grid-area: delete;
	align-self: center;
}

.lp-question-answer-item > input.lp-input-answer-set-true {
	grid-area: correct;
	align-self: center;
	margin-top: 0;
}

.answer-option .triplea-answer-media-control {
	margin-left: 0;
}

/*
 * LearnPress hides the answer-row delete action until the row is hovered.
 * Keep that action column at a fixed width so revealing the icon never
 * changes the answer text/media layout.
 */
#admin-editor-lp_quiz .quiz-question-data table.lp-list-options,
#admin-editor-lp_question table.lp-list-options {
	table-layout: fixed;
}

#admin-editor-lp_quiz .quiz-question-data table.lp-list-options th.actions,
#admin-editor-lp_quiz .quiz-question-data table.lp-list-options td.actions.lp-toolbar-buttons,
#admin-editor-lp_question table.lp-list-options th.actions,
#admin-editor-lp_question table.lp-list-options td.actions.lp-toolbar-buttons {
	width: 46px !important;
	min-width: 46px;
	max-width: 46px;
	box-sizing: border-box;
	padding-right: 8px !important;
	padding-left: 8px !important;
}

#admin-editor-lp_quiz .quiz-question-data table.lp-list-options td.actions.lp-toolbar-buttons .lp-toolbar-btn,
#admin-editor-lp_question table.lp-list-options td.actions.lp-toolbar-buttons .lp-toolbar-btn {
	visibility: visible;
	opacity: 0;
	transition: opacity 120ms ease;
}

#admin-editor-lp_quiz .quiz-question-data table.lp-list-options tbody tr:hover td.actions.lp-toolbar-buttons .lp-toolbar-btn,
#admin-editor-lp_quiz .quiz-question-data table.lp-list-options tbody tr:focus-within td.actions.lp-toolbar-buttons .lp-toolbar-btn,
#admin-editor-lp_question table.lp-list-options tbody tr:hover td.actions.lp-toolbar-buttons .lp-toolbar-btn,
#admin-editor-lp_question table.lp-list-options tbody tr:focus-within td.actions.lp-toolbar-buttons .lp-toolbar-btn {
	opacity: 1;
}

.triplea-question-answer-media {
	display: block;
	width: 100%;
	margin-top: 10px;
}

.triplea-question-answer-image {
	display: block;
	width: auto;
	max-width: 100%;
	max-height: 180px;
	height: auto;
	object-fit: contain;
}

.triplea-question-answer-title {
	display: block;
	width: 100%;
}

/*
 * LearnPress renders each answer as a flex row and vertically centers its
 * checkbox. Keep the checkbox at the top for long answers, and stack the
 * answer text and optional image so the image always starts on a new line.
 */
.question .answer-option {
	align-items: flex-start;
}

.question .answer-option input[type='radio'],
.question .answer-option input[type='checkbox'] {
	position: absolute !important;
	top: 12px !important;
	transform: none !important;
	margin-top: 0 !important;
}

.question .answer-options .answer-option > input.option-check {
	position: absolute !important;
	top: 12px !important;
	left: 10px !important;
	margin: 0 !important;
	transform: none !important;
	inset-block-start: 12px !important;
	inset-inline-start: 10px !important;
}

.question .answer-option .option-title {
	/* Keep text nodes and MathJax inline containers in one normal flow. */
	display: block;
}

/* Keep answer labels and formula variables exactly as authored, even when
 * the active theme applies a global text-transform to labels/buttons. */
body .question .answer-options .answer-option .option-title,
body .question .answer-options .answer-option .option-title * {
	text-transform: none !important;
}
