.wphd-wrap {
	max-width: 760px;
	margin: 0 auto;
	font-family: inherit;
}
.wphd-form .wphd-field {
	margin-bottom: 1em;
}
.wphd-form label {
	display: block;
	font-weight: 600;
	margin-bottom: 0.35em;
}
.wphd-form input[type="text"],
.wphd-form textarea,
.wphd-form select {
	width: 100%;
	padding: 0.5em;
	box-sizing: border-box;
}
.wphd-button {
	padding: 0.6em 1.4em;
	cursor: pointer;
}
.wphd-button-secondary {
	background: transparent;
	border: 1px solid currentColor;
}
.wphd-form-message {
	margin-top: 0.75em;
	font-weight: 600;
}
.wphd-search-field input {
	width: 100%;
	max-width: 320px;
	padding: 0.5em;
	box-sizing: border-box;
}
.wphd-hp-field {
	position: absolute;
	left: -9999px;
	top: -9999px;
}
.wphd-new-reply-badge {
	background: #d63638;
	color: #fff;
	font-size: 0.75em;
	font-weight: 600;
	padding: 0.15em 0.6em;
	border-radius: 10px;
	margin-left: 0.5em;
}
.wphd-activity-section {
	margin: 1em 0;
	padding: 0.75em 1em;
	background: #f6f7f7;
	border-radius: 4px;
}
.wphd-activity-item {
	font-size: 0.9em;
	padding: 0.35em 0;
	border-bottom: 1px solid #e2e4e7;
}
.wphd-activity-item:last-child {
	border-bottom: none;
}
.wphd-activity-meta {
	color: #666;
	font-size: 0.9em;
}
.wphd-activity-empty {
	color: #666;
	font-style: italic;
}
.wphd-presence-banner {
	background: #fff8e5;
	border: 1px solid #f0c33c;
	color: #674600;
	padding: 0.6em 1em;
	border-radius: 4px;
	margin-bottom: 1em;
	font-size: 0.9em;
}
.wphd-draft-notice {
	background: #e5f5fa;
	border: 1px solid #72aee6;
	color: #0a4b78;
	padding: 0.5em 1em;
	border-radius: 4px;
	margin-bottom: 0.75em;
	font-size: 0.9em;
}
.wphd-draft-discard {
	background: none;
	border: none;
	color: #0a4b78;
	text-decoration: underline;
	cursor: pointer;
	padding: 0;
	font-size: inherit;
}
.wphd-form-message.wphd-error {
	color: #b32d2e;
}
.wphd-form-message.wphd-success {
	color: #1e7e34;
}
.wphd-notice {
	padding: 1em;
	background: #f6f7f7;
	border-left: 4px solid #999;
}
.wphd-on-behalf-field {
	background: #f0f4f8;
	padding: 0.75em;
	border-radius: 4px;
}
.wphd-on-behalf-results {
	display: block;
	position: relative;
	max-width: 400px;
}
.wphd-on-behalf-result {
	padding: 0.4em 0.6em;
	background: #fff;
	border: 1px solid #ddd;
	border-top: none;
	cursor: pointer;
	font-size: 0.9em;
}
.wphd-on-behalf-result:hover {
	background: #f0f4f8;
}
.wphd-on-behalf-selected {
	display: block;
	font-weight: 600;
	font-size: 0.9em;
	color: #1e7e34;
	margin-top: 0.25em;
}
.wphd-ticket-list {
	display: flex;
	flex-direction: column;
	gap: 0.5em;
}
.wphd-ticket-row {
	display: flex;
	gap: 1em;
	padding: 0.75em 1em;
	border: 1px solid #ddd;
	border-radius: 4px;
	text-decoration: none;
	color: inherit;
}
.wphd-ticket-row:hover {
	background: #f6f7f7;
}
.wphd-ticket-id {
	color: #646970; /* 5.5:1 on white (was #777 = 4.48:1) */
	min-width: 3em;
}
.wphd-ticket-title {
	flex: 1;
}
.wphd-ticket-status {
	padding: 0.15em 0.6em;
	border-radius: 3px;
	font-size: 0.85em;
	background: #eee;
	color: #1d2327; /* explicit: pill backgrounds are fixed, so the text must not inherit a light theme colour */
	text-transform: capitalize;
}
.wphd-status-open { background: #d9edf7; }
.wphd-status-pending { background: #fcf8e3; }
.wphd-status-resolved,
.wphd-status-closed { background: #dff0d8; }
.wphd-agent-controls {
	display: flex;
	flex-wrap: wrap;
	gap: 1em;
	padding: 1em;
	background: #f6f7f7;
	margin: 1em 0;
}
.wphd-agent-controls label {
	display: flex;
	flex-direction: column;
	font-size: 0.85em;
}
.wphd-note {
	flex-basis: 100%;
	font-size: 0.8em;
	color: #646970; /* 5.15:1 on #f6f7f7 (was #777 = 4.17:1) */
	margin: 0;
}
.wphd-merge-control {
	flex-basis: 100%;
	display: flex;
	align-items: center;
	gap: 0.5em;
	padding-top: 0.75em;
	border-top: 1px dashed #ccc;
	font-size: 0.9em;
}
.wphd-reply {
	padding: 0.75em 1em;
	border-radius: 4px;
	margin-bottom: 0.75em;
}
.wphd-reply-agent {
	background: #eef4ff;
}
.wphd-reply-customer {
	background: #f6f7f7;
}
.wphd-notes-section {
	margin: 1em 0;
}
.wphd-notes-section h4 {
	margin-bottom: 0.5em;
}
.wphd-note-badge {
	font-size: 0.7em;
	background: #fcf3cf;
	color: #7d6608;
	padding: 0.1em 0.5em;
	border-radius: 3px;
	font-weight: normal;
	vertical-align: middle;
}
.wphd-sla-breach {
	background: #f8d7da;
	color: #842029;
	padding: 0.1em 0.6em;
	border-radius: 3px;
	font-weight: 600;
	font-size: 0.85em;
}
.wphd-sla-ok {
	background: #d1ecf1;
	color: #0c5460;
	padding: 0.1em 0.6em;
	border-radius: 3px;
	font-size: 0.85em;
}
.wphd-note-item {
	padding: 0.75em 1em;
	border-radius: 4px;
	margin-bottom: 0.75em;
	background: #fffbea;
	border: 1px dashed #e6d68a;
}
.wphd-reply-mode-toggle {
	display: flex;
	gap: 1.5em;
	margin-bottom: 0.5em;
	font-size: 0.9em;
}
.wphd-reply-mode-toggle label {
	display: inline-flex;
	align-items: center;
	gap: 0.3em;
	font-weight: normal;
}
.wphd-reply-author {
	font-weight: 600;
	margin-bottom: 0.25em;
}
.wphd-dashboard-tabs {
	display: flex;
	gap: 0.5em;
	margin-bottom: 1em;
}
.wphd-tab-btn {
	padding: 0.4em 1em;
	background: transparent;
	border: 1px solid #8c8f94; /* 3.24:1 on white (was #ccc = 1.61:1) */
	cursor: pointer;
}
.wphd-tab-btn.active {
	background: #2271b1;
	color: #fff;
	border-color: #2271b1;
}

/* ================================================================== */
/* Accessibility helpers (WCAG 2.1 AA)                                */
/* ================================================================== */
.wphd-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}
.wphd-required {
	color: #b32d2e; /* 6.3:1 on white */
	font-weight: 700;
}
.wphd-required-note {
	font-size: 0.85em;
	color: #646970;
	margin: 0 0 1em;
}
.wphd-block {
	display: block;
}
.wphd-merge-input {
	width: 100px;
}

/* Visible keyboard focus. Two-tone (outline + white halo) so it shows on light and mid-tone backgrounds. */
.wphd-wrap a:focus-visible,
.wphd-wrap button:focus-visible,
.wphd-wrap input:focus-visible,
.wphd-wrap select:focus-visible,
.wphd-wrap textarea:focus-visible,
.wphd-wrap [tabindex]:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
	box-shadow: 0 0 0 4px #fff;
}
.wphd-wrap .wphd-ticket-row:focus-visible {
	background: #f6f7f7;
}

/* Customer lookup (combobox) */
.wphd-on-behalf-results[hidden] {
	display: none;
}
.wphd-on-behalf-result.is-active,
.wphd-on-behalf-result[aria-selected="true"] {
	background: #dcdcde;
	outline: 2px solid #2271b1;
	outline-offset: -2px;
}
.wphd-on-behalf-none {
	cursor: default;
	color: #646970;
}

/* Ticket list rendered as a real list */
.wphd-ticket-rows {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.5em;
}
.wphd-ticket-rows > li {
	margin: 0;
	padding: 0;
}
.wphd-ticket-rows > li::marker {
	content: "";
}
.wphd-activity-list {
	list-style: none;
	margin: 0;
	padding: 0;
}
.wphd-activity-list > li {
	margin: 0;
}

/* Content coming from the server (replies, notes) must never widen the page. */
.wphd-reply,
.wphd-note-item,
.wphd-ticket-meta {
	overflow-wrap: anywhere;
}
.wphd-reply-content img,
.wphd-reply-content video,
.wphd-reply-content iframe {
	max-width: 100%;
	height: auto;
}
.wphd-reply-content pre {
	max-width: 100%;
	overflow-x: auto;
}
.wphd-table-scroll {
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	margin: 0 0 1em;
}
.wphd-table-scroll:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}
.wphd-table-scroll > table {
	margin: 0;
}

@media (prefers-reduced-motion: reduce) {
	.wphd-wrap *,
	.wphd-wrap *::before,
	.wphd-wrap *::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}

/* ================================================================== */
/* Responsive (mobile-first additions, 320px - 768px)                 */
/* Only additive: nothing above is rewritten.                         */
/* ================================================================== */
.wphd-wrap {
	box-sizing: border-box;
	width: 100%;
	max-width: 760px;
}
.wphd-form input[type="email"],
.wphd-form input[type="search"],
.wphd-form input[type="number"],
.wphd-search-field input,
.wphd-agent-controls select,
.wphd-canned-field select {
	box-sizing: border-box;
}
.wphd-form input[type="email"],
.wphd-form input[type="search"],
.wphd-form input[type="number"] {
	width: 100%;
	max-width: 100%;
	padding: 0.5em;
}
.wphd-search-field input {
	max-width: 100%;
}
.wphd-wrap .wp-editor-wrap,
.wphd-wrap .wp-editor-container,
.wphd-wrap textarea.wp-editor-area,
.wphd-wrap iframe {
	max-width: 100%;
}
.wphd-dashboard-tabs,
.wphd-reply-mode-toggle {
	flex-wrap: wrap;
}
.wphd-ticket-row {
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25em 1em;
	min-height: 44px;
}
.wphd-ticket-title {
	min-width: 0;
	overflow-wrap: anywhere;
}
.wphd-merge-control {
	flex-wrap: wrap;
}

@media (max-width: 768px), (pointer: coarse) {
	/* 16px stops iOS Safari zooming the page when a field is focused. */
	.wphd-wrap input[type="text"],
	.wphd-wrap input[type="email"],
	.wphd-wrap input[type="search"],
	.wphd-wrap input[type="number"],
	.wphd-wrap input[type="url"],
	.wphd-wrap input[type="date"],
	.wphd-wrap select,
	.wphd-wrap textarea {
		font-size: 16px;
		min-height: 44px;
	}
	.wphd-wrap textarea {
		min-height: 6em;
	}
	/* Touch targets >= 44x44 CSS px. */
	.wphd-wrap .wphd-button,
	.wphd-wrap .wphd-tab-btn,
	.wphd-wrap .wphd-organisations-scope-btn,
	.wphd-wrap .wp-switch-editor {
		min-height: 44px;
		min-width: 44px;
	}
	.wphd-wrap .wphd-draft-discard {
		min-height: 44px;
		display: inline-flex;
		align-items: center;
	}
	.wphd-reply-mode-toggle label {
		min-height: 44px;
	}
	.wphd-reply-mode-toggle input[type="radio"],
	.wphd-wrap .wphd-cf-choice input,
	.wphd-wrap .wphd-sv-share input {
		width: 20px;
		height: 20px;
	}
	.wphd-on-behalf-result {
		min-height: 44px;
		display: flex;
		align-items: center;
	}
}

@media (max-width: 600px) {
	.wphd-dashboard-tabs .wphd-tab-btn {
		flex: 1 1 auto;
	}
	.wphd-agent-controls {
		flex-direction: column;
		gap: 0.75em;
	}
	.wphd-agent-controls label,
	.wphd-agent-controls select {
		width: 100%;
	}
	.wphd-merge-control label {
		flex-basis: 100%;
	}
	.wphd-merge-control .wphd-button {
		flex: 1 1 auto;
	}
	.wphd-form .wphd-button,
	.wphd-form .wphd-button-secondary {
		width: 100%;
		margin-bottom: 0.5em;
	}
	.wphd-ticket-id {
		min-width: 0;
	}
	.wphd-ticket-title {
		flex: 1 1 100%;
	}
	.wphd-on-behalf-results {
		max-width: 100%;
	}
	.wphd-canned-field select {
		width: 100%;
	}
	.wphd-canned-field label,
	.wphd-attachment-field label {
		display: block;
	}
	.wphd-attachment-field input[type="file"] {
		max-width: 100%;
	}
}
