.hi-training-calendar-wrap {
	--hi-border: #d6d6d6;
	--hi-border-soft: #e6e6e6;
	--hi-text: #4d6f97;
	--hi-heading: #333;
	--hi-muted: #9aa8ba;
	--hi-bg: #fff;
	--hi-lane-height: 22px;
	font-size: 15px;
}

.hi-calendar {
	background: #fff;
}

.hi-calendar-header {
	display: grid;
	grid-template-columns: 140px 1fr 140px;
	align-items: center;
	gap: 12px;
	margin: 0 0 10px;
}

.hi-calendar-header h2 {
	margin: 0;
	text-align: center;
	font-size: 18px;
	line-height: 1.2;
	font-weight: 700;
	color: var(--hi-heading);
	letter-spacing: 0.01em;
}

.hi-calendar-nav {
	background: #f7f7f7;
	border: 1px solid var(--hi-border);
	border-radius: 3px;
	padding: 8px 10px;
	cursor: pointer;
	font: inherit;
	font-size: 14px;
	color: #444;
}

.hi-calendar-nav:first-child {
	justify-self: start;
}

.hi-calendar-nav:last-child {
	justify-self: end;
}

.hi-calendar-weekdays,
.hi-calendar-week-date-row,
.hi-calendar-week-grid,
.hi-calendar-week-multiday {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
}

.hi-calendar-weekdays {
	border: 1px solid var(--hi-border);
	border-bottom: 0;
	background: #f7f7f7;
}

.hi-calendar-weekdays > div {
	padding: 7px 8px;
	border-right: 1px solid var(--hi-border);
	text-align: center;
	font-size: 13px;
	font-weight: 500;
	color: #8a8a8a;
}

.hi-calendar-weekdays > div:last-child {
	border-right: 0;
}

.hi-calendar-week {
	position: relative;
	border-left: 1px solid var(--hi-border);
	border-right: 1px solid var(--hi-border);
}

.hi-calendar-week + .hi-calendar-week {
	border-top: 0;
}

.hi-calendar-week-date-row {
	background: #edf6fd;
	border-bottom: 1px solid var(--hi-border);
}

.hi-calendar-week-date {
	min-height: 22px;
	padding: 3px 7px 2px;
	border-right: 1px solid var(--hi-border);
	box-sizing: border-box;
	text-align: right;
	font-size: 12px;
	line-height: 16px;
	color: #4e7db0;
}

.hi-calendar-week-date:last-child {
	border-right: 0;
}

.hi-calendar-week-date--muted {
	background: #f4f4f4;
	color: #aaa;
}

.hi-calendar-week-multiday {
	position: relative;
	z-index: 2;
	grid-auto-rows: var(--hi-lane-height);
	min-height: calc(var(--hi-lanes) * var(--hi-lane-height));
	pointer-events: none;
	padding: 0 3px;
	box-sizing: border-box;
}

.hi-calendar-multi-event {
	min-width: 0;
	margin: 1px 2px;
	pointer-events: auto;
}

.hi-calendar-multi-event a,
.hi-calendar-multi-event button {
	display: block;
	width: 100%;
	height: calc(var(--hi-lane-height) - 2px);
	padding: 2px 8px;
	border: 0;
	border-radius: 3px;
	background: var(--hi-event-colour);
	color: #fff;
	text-align: left;
	font: inherit;
	font-size: 12px;
	line-height: 18px;
	text-decoration: none;
	cursor: pointer;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	box-sizing: border-box;
}

.hi-calendar-week-grid {
	position: relative;
	z-index: 1;
}

.hi-calendar-day {
	position: relative;
	min-height: 145px;
	padding: 8px 6px;
	border-right: 1px solid var(--hi-border);
	border-bottom: 1px solid var(--hi-border);
	background: #fff;
	box-sizing: border-box;
}

.hi-calendar-week-grid .hi-calendar-day:last-child {
	border-right: 0;
}

.hi-calendar-day--muted {
	background: #fbfbfb;
}


.hi-calendar-events {
	display: grid;
	gap: 6px;
}

.hi-calendar-event-line a,
.hi-calendar-event-line button {
	display: block;
	width: 100%;
	padding: 0;
	background: transparent;
	border: 0;
	text-align: left;
	font: inherit;
	text-decoration: none;
	cursor: pointer;
	color: var(--hi-text);
	line-height: 1.2;
}

.hi-calendar-day-title,
.hi-calendar-day-time {
	display: block;
}

.hi-calendar-day-title {
	font-size: 12px;
	font-weight: 400;
}

.hi-calendar-day-time {
	font-size: 11px;
	font-weight: 700;
	margin-top: 2px;
}

.hi-mobile-event-list {
	display: none;
}

.hi-mobile-event {
	border-bottom: 1px solid var(--hi-border-soft);
	padding: 12px 0;
	display: grid;
	grid-template-columns: 125px 1fr;
	gap: 12px;
}

.hi-mobile-event-date {
	font-weight: 600;
	color: var(--hi-heading);
}

.hi-mobile-event-time {
	font-size: 13px;
	color: #666;
	margin-top: 3px;
}

.hi-calendar-modal[hidden] {
	display: none;
}

.hi-calendar-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
	background: rgba(0, 0, 0, 0.45);
	display: grid;
	place-items: center;
	padding: 20px;
}

.hi-calendar-modal-card {
	position: relative;
	width: min(520px, 100%);
	background: #fff;
	padding: 28px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.hi-calendar-modal-close {
	position: absolute;
	top: 8px;
	right: 10px;
	border: 0;
	background: transparent;
	font-size: 28px;
	cursor: pointer;
}

@media (max-width: 980px) {
	.hi-calendar-header {
		grid-template-columns: 100px 1fr 100px;
	}

	.hi-calendar-nav {
		font-size: 13px;
		padding: 7px 8px;
	}
}

@media (max-width: 760px) {
	.hi-calendar-weekdays,
	.hi-calendar-desktop {
		display: none;
	}

	.hi-mobile-event-list {
		display: block;
	}

	.hi-calendar-header {
		grid-template-columns: auto 1fr auto;
	}

	.hi-calendar-header h2 {
		font-size: 17px;
	}

	.hi-calendar-nav {
		padding: 6px 8px;
	}
}

/* Refined hover states. Strong specificity prevents theme button hover styles from turning events black. */
.hi-training-calendar-wrap .hi-calendar-event-line a,
.hi-training-calendar-wrap .hi-calendar-event-line button {
	padding: 3px 5px;
	border-radius: 3px;
	box-sizing: border-box;
	transition: background-color .15s ease, color .15s ease;
}

.hi-training-calendar-wrap .hi-calendar-event-line a:hover,
.hi-training-calendar-wrap .hi-calendar-event-line a:focus,
.hi-training-calendar-wrap .hi-calendar-event-line button:hover,
.hi-training-calendar-wrap .hi-calendar-event-line button:focus {
	background: #eef5fb !important;
	color: #315f8d !important;
}

.hi-training-calendar-wrap .hi-calendar-multi-event a,
.hi-training-calendar-wrap .hi-calendar-multi-event button {
	background: var(--hi-event-colour) !important;
	color: #fff !important;
	transition: filter .15s ease, opacity .15s ease;
}

.hi-training-calendar-wrap .hi-calendar-multi-event a:hover,
.hi-training-calendar-wrap .hi-calendar-multi-event a:focus,
.hi-training-calendar-wrap .hi-calendar-multi-event button:hover,
.hi-training-calendar-wrap .hi-calendar-multi-event button:focus {
	background: var(--hi-event-colour) !important;
	color: #fff !important;
	filter: brightness(.9);
}

.hi-training-calendar-wrap .hi-calendar-event-line a:focus-visible,
.hi-training-calendar-wrap .hi-calendar-event-line button:focus-visible,
.hi-training-calendar-wrap .hi-calendar-multi-event a:focus-visible,
.hi-training-calendar-wrap .hi-calendar-multi-event button:focus-visible {
	outline: 2px solid #4e7db0;
	outline-offset: 2px;
}

/* Popup */
.hi-training-calendar-wrap + .hi-calendar-modal .hi-calendar-modal-card,
.hi-calendar-modal .hi-calendar-modal-card {
	width: min(620px, 100%);
	padding: 0 28px 28px;
	border-radius: 4px;
	overflow: hidden;
}

.hi-calendar-modal-image {
	display: block;
	width: calc(100% + 56px);
	max-width: none;
	height: 220px;
	margin: 0 -28px 24px;
	object-fit: cover;
	background: #f2f2f2;
}

.hi-calendar-modal-image[hidden] {
	display: none;
}

.hi-calendar-modal-card h3#hi-calendar-modal-title {
	margin: 24px 34px 12px 0 !important;
	font-size: 25px !important;
	line-height: 1.25 !important;
	font-weight: 600 !important;
	color: #333 !important;
}

.hi-calendar-modal-card .hi-calendar-modal-time {
	margin: 0 0 18px !important;
	font-size: 15px !important;
	line-height: 1.4 !important;
	color: #555 !important;
}

.hi-calendar-modal-card .hi-calendar-modal-summary {
	margin: 0 !important;
	font-size: 15px !important;
	line-height: 1.6 !important;
	color: #555 !important;
}

.hi-calendar-modal .hi-calendar-modal-close,
.hi-calendar-modal .hi-calendar-modal-close:hover,
.hi-calendar-modal .hi-calendar-modal-close:focus {
	top: 10px;
	right: 12px;
	width: 38px;
	height: 38px;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 50%;
	background: rgba(255,255,255,.92) !important;
	color: #444 !important;
	font-size: 28px;
	line-height: 38px;
	box-shadow: 0 1px 5px rgba(0,0,0,.12);
}

@media (max-width: 760px) {
	.hi-calendar-modal .hi-calendar-modal-card {
		padding: 0 20px 22px;
	}

	.hi-calendar-modal-image {
		width: calc(100% + 40px);
		height: 180px;
		margin: 0 -20px 20px;
	}

	.hi-calendar-modal-card h3#hi-calendar-modal-title {
		font-size: 21px !important;
		margin-top: 20px !important;
	}

	.hi-calendar-modal-card .hi-calendar-modal-time,
	.hi-calendar-modal-card .hi-calendar-modal-summary {
		font-size: 14px !important;
	}
}
