.iap-assessment {
	margin: 1.5em 0;
}

.iap-status {
	display: inline-block;
	margin: 0 0 1em;
	padding: 0.15em 0.6em;
	border: 1px solid currentColor;
	border-radius: 999px;
	font-size: 0.8em;
	opacity: 0.8;
}

.iap-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 1em;
	margin: 1em 0;
}

.iap-grid--wide {
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.iap-card {
	display: flex;
	flex-direction: column;
	gap: 0.5em;
	min-width: 0;
	padding: 0.75em;
	border: 1px solid rgba(127, 127, 127, 0.35);
	border-radius: 6px;
}

.iap-slot {
	border-style: dashed;
}

.iap-slot--filled,
.iap-slot--pending {
	border-style: solid;
}

.iap-card__media {
	display: flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	border-radius: 4px;
	background: rgba(127, 127, 127, 0.12);
}

.iap-card__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.iap-slot__label {
	font-weight: 600;
}

.iap-slot__empty,
.iap-empty {
	font-size: 0.9em;
	opacity: 0.7;
}

.iap-slot input[type="file"] {
	max-width: 100%;
	font-size: 0.9em;
}

.iap-field {
	display: flex;
	flex-direction: column;
	gap: 0.2em;
	font-size: 0.9em;
}

.iap-field input,
.iap-comment-field textarea {
	width: 100%;
	box-sizing: border-box;
}

.iap-slot__remove {
	font-size: 0.9em;
}

.iap-entry__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5em;
	font-size: 0.9em;
}

.iap-entry__number {
	font-weight: 600;
}

.iap-entry__author {
	opacity: 0.8;
}

.iap-entry__title {
	margin: 0;
	font-size: 1em;
}

.iap-entry--own {
	border-style: dashed;
}

.iap-badge {
	padding: 0.1em 0.5em;
	border-radius: 999px;
	background: rgba(127, 127, 127, 0.18);
	font-size: 0.85em;
}

.iap-comments {
	margin: 0;
	padding: 0;
	list-style: none;
	display: flex;
	flex-direction: column;
	gap: 0.5em;
}

.iap-comment {
	padding: 0.5em 0.65em;
	border-radius: 4px;
	background: rgba(127, 127, 127, 0.08);
	font-size: 0.92em;
	overflow-wrap: anywhere;
}

.iap-comment__meta {
	font-size: 0.85em;
	opacity: 0.75;
	margin-bottom: 0.2em;
}

.iap-comment__delete {
	margin-top: 0.25em;
}

.iap-comment-field {
	display: flex;
	flex-direction: column;
	gap: 0.4em;
	margin-top: auto;
}

.iap-link-button {
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font-size: 0.85em;
	text-decoration: underline;
	cursor: pointer;
	opacity: 0.75;
}

.iap-hint {
	font-size: 0.9em;
	opacity: 0.8;
}

.iap-notice {
	padding: 0.6em 0.9em;
	border-left: 4px solid;
	background: rgba(127, 127, 127, 0.08);
}

.iap-notice--success {
	border-color: #2e7d32;
}

.iap-notice--error {
	border-color: #c62828;
	color: #c62828;
}

.iap-entry__status {
	margin: 0;
	min-height: 1.2em;
	font-size: 0.85em;
}

.iap-entry__status--success {
	color: #2e7d32;
}

.iap-entry__status--error {
	color: #c62828;
}

/*
 * Primary button. Scoped to the plugin's wrappers (the lightbox dialog lives
 * on <body>, outside .iap-assessment) so these two-class selectors beat theme
 * rules such as Astra's, which can leave the button transparent until hover.
 * Uses the theme's accent color when Astra exposes it.
 */
.iap-assessment .iap-button,
.iap-lightbox .iap-button {
	display: inline-block;
	align-self: flex-start;
	padding: 0.5em 1.1em;
	border: 1px solid var(--ast-global-color-0, #2271b1);
	border-radius: 4px;
	background: var(--ast-global-color-0, #2271b1);
	color: #fff;
	font-size: 0.95em;
	line-height: 1.4;
	text-decoration: none;
	/* Astra uppercases and letter-spaces buttons. */
	text-transform: none;
	letter-spacing: normal;
	opacity: 1;
	visibility: visible;
	cursor: pointer;
}

.iap-assessment .iap-button:hover,
.iap-assessment .iap-button:focus,
.iap-lightbox .iap-button:hover,
.iap-lightbox .iap-button:focus {
	border-color: var(--ast-global-color-1, #135e96);
	background: var(--ast-global-color-1, #135e96);
	color: #fff;
}

.iap-assessment .iap-button:focus-visible,
.iap-lightbox .iap-button:focus-visible {
	outline: 2px solid var(--ast-global-color-0, #2271b1);
	outline-offset: 2px;
}

.iap-assessment .iap-button:disabled,
.iap-lightbox .iap-button:disabled,
.iap-link-button:disabled {
	opacity: 0.5;
	cursor: wait;
}

/* ---------- Lightbox (completed view) ---------- */

.iap-lightbox-open {
	overflow: hidden;
}

.iap-lightbox {
	width: min(1280px, calc(100vw - 2rem));
	height: min(860px, calc(100vh - 2rem));
	max-width: none;
	max-height: none;
	padding: 0;
	border: 0;
	border-radius: 8px;
	background: Canvas;
	color: CanvasText;
	overflow: hidden;
}

.iap-lightbox::backdrop {
	background: rgba(0, 0, 0, 0.8);
}

.iap-lightbox__inner {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 360px;
	grid-template-rows: minmax(0, 1fr) auto;
	height: 100%;
}

.iap-lightbox__media {
	grid-row: 1 / 3;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	min-height: 0;
	background: #111;
}

.iap-lightbox__media img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}

.iap-lightbox__panel {
	min-height: 0;
	overflow-y: auto;
	padding: 1em 1.1em;
}

.iap-lightbox__panel .iap-entry__details {
	display: flex;
	flex-direction: column;
	gap: 0.6em;
}

.iap-lightbox__panel .iap-entry__title {
	font-size: 1.15em;
}

.iap-lightbox__bar {
	display: flex;
	align-items: center;
	gap: 0.5em;
	padding: 0.6em 1.1em;
	border-top: 1px solid rgba(127, 127, 127, 0.3);
}

.iap-lightbox__position {
	flex: 1;
	text-align: center;
	font-size: 0.9em;
	opacity: 0.8;
}

.iap-lightbox__btn {
	min-width: 2.5em;
	min-height: 2.5em;
	padding: 0 0.6em;
	border: 1px solid rgba(127, 127, 127, 0.4);
	border-radius: 4px;
	background: transparent;
	color: inherit;
	font-size: 1.1em;
	line-height: 1;
	cursor: pointer;
}

.iap-lightbox__btn:hover,
.iap-lightbox__btn:focus-visible {
	background: rgba(127, 127, 127, 0.15);
}

.iap-lightbox__btn[hidden] {
	display: none;
}

/* Themes (e.g. Astra) uppercase and letter-space every button. */
.iap-lightbox .iap-lightbox__btn,
.iap-lightbox .iap-lightbox__tool {
	text-transform: none;
	letter-spacing: normal;
	box-shadow: none;
}

.iap-lightbox__position {
	white-space: nowrap;
}

/* Composition overlay from assets/js/rule-of-thirds.js, drawn over the image,
   and its control in the image's top-left corner. */
.iap-lightbox__media {
	position: relative;
	overflow: hidden;
}

.iap-lightbox__tools {
	position: absolute;
	top: 0.75em;
	left: 0.75em;
	z-index: 2;
	display: flex;
	align-items: center;
	gap: 0.5em;
	max-width: calc(100% - 1.5em);
}

.iap-lightbox__tools[hidden],
.iap-lightbox__grid-name[hidden] {
	display: none;
}

/* Two-class selectors so theme button styles don't win. */
.iap-lightbox .iap-lightbox__tool {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: none;
	width: 2.5em;
	height: 2.5em;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, 0.35);
	border-radius: 4px;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	line-height: 1;
	cursor: pointer;
}

.iap-lightbox .iap-lightbox__tool:hover,
.iap-lightbox .iap-lightbox__tool:focus {
	border-color: rgba(255, 255, 255, 0.7);
	background: rgba(0, 0, 0, 0.75);
	color: #fff;
}

.iap-lightbox .iap-lightbox__tool:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.iap-lightbox .iap-lightbox__tool[aria-pressed="true"] {
	border-color: #fff;
	background: rgba(0, 0, 0, 0.8);
}

.iap-lightbox__tool svg {
	display: block;
}

.iap-lightbox__grid-name {
	overflow: hidden;
	padding: 0.3em 0.65em;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	font-size: 0.85em;
	line-height: 1.3;
	white-space: nowrap;
	text-overflow: ellipsis;
	pointer-events: none;
}

/* The script wraps an image that fills the width in an inline-block; without
   this the image sits on the text baseline and the overlay overshoots it. */
.iap-lightbox__media .rule-of-thirds-wrapper > img {
	display: block;
}

.iap-lightbox__media .rule-of-thirds svg {
	display: block;
	width: 100%;
	height: 100%;
	overflow: visible;
}

@media (max-width: 760px) {
	.iap-lightbox {
		width: 100vw;
		height: 100vh;
		height: 100dvh;
		border-radius: 0;
	}

	.iap-lightbox__inner {
		grid-template-columns: minmax(0, 1fr);
		grid-template-rows: minmax(0, 45vh) minmax(0, 1fr) auto;
	}

	.iap-lightbox__media {
		grid-row: auto;
	}
}

.iap-section {
	margin-top: 2em;
	padding-top: 1.25em;
	border-top: 1px solid rgba(127, 127, 127, 0.3);
}

.iap-section__title {
	margin: 0 0 0.5em;
}
