/* Touch / coarse pointer: no sticky :hover — use :active for tap feedback instead */

@media (hover: none), (pointer: coarse) {
	/* —— Hover resets (match default / selected state) —— */

	.rm-rail-btn:hover:not(.is-active) {
		background: transparent;
		color: var(--rm-color-muted);
		border-radius: 10px;
	}

	.rm-rail-btn-logout:hover:not(.is-active) {
		background: transparent;
		color: var(--rm-color-muted);
	}

	.rm-panel-collapse-btn:hover,
	.rm-panel-close-btn:hover {
		background: var(--rm-surface-subtle);
		color: var(--rm-color-muted);
	}

	.rm-room-item:hover:not(.is-active) {
		background: transparent;
	}

	.rm-mention-item:hover {
		background: var(--rm-surface-subtle);
		box-shadow: inset 0 0 0 1px var(--rm-border-subtle);
	}

	.rm-mention-item.is-unread:hover {
		box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rm-color-accent) 45%, transparent);
		background: color-mix(in srgb, var(--rm-color-accent) 8%, var(--rm-surface-subtle));
	}

	.rm-theme-option:hover:not(.is-active) {
		background: var(--rm-surface-subtle);
		color: var(--rm-color-muted);
		box-shadow: inset 0 0 0 1px var(--rm-border-subtle);
	}

	.rm-theme-option:hover:not(.is-active) i {
		color: var(--rm-color-muted);
	}

	.rm-theme-option.is-active:hover i {
		color: var(--rm-color-accent);
	}

	.rm-filter-panel .rm-filter-row:hover,
	.rm-app-panel .rm-filter-row:hover {
		background: transparent;
	}

	.rm-filter-panel .rm-filter-row--zone:hover .rm-zone-stats-bar,
	.rm-app-panel .rm-filter-row--zone:hover .rm-zone-stats-bar {
		opacity: 0.75;
	}

	.rm-filter-panel .rm-filter-action-link:hover,
	.rm-app-panel .rm-filter-action-link:hover {
		color: var(--rm-link-color);
	}

	.rm-filter-panel .form-check.form-switch:hover,
	.rm-app-panel .rm-filter-display-section .form-check.form-switch:hover,
	.rm-app-panel .form-check.form-switch:hover {
		background: transparent;
	}

	.rm-panel-section[data-panel="settings"] .form-check.form-switch:hover {
		background: var(--rm-surface-subtle);
	}

	.rm-filter-panel .rm-filter-row--option:hover,
	.rm-app-panel .rm-filter-row--option:hover {
		background: transparent;
	}

	.rm-input-info-btn:hover,
	.rm-input-info-btn:focus-visible {
		color: var(--rm-color-subtle, #6c757d);
		background: transparent;
	}

	.rm-panel-section[data-panel="users"] #usersList .rm-users-item.has-location:hover,
	#usersList .rm-users-item.has-location:hover {
		background-color: transparent;
	}

	.rm-app-shell .btn-check:not(:checked) + .btn-outline-primary:hover,
	#searchModal .btn-check:not(:checked) + .btn-outline-primary:hover {
		background: transparent;
		border-color: rgba(88, 101, 242, 0.55);
		color: #aeb6ff;
	}

	.rm-app-shell button.rm-search-result:hover,
	button.rm-search-result:hover {
		background: transparent;
		background-color: transparent;
		box-shadow: none;
	}

	.rm-app-shell button.rm-search-result:hover .rm-search-result-meta,
	button.rm-search-result:hover .rm-search-result-meta {
		color: var(--rm-color-muted, #6c757d);
	}

	.rm-app-shell .rm-search-result:hover .rm-search-result-chevron,
	button.rm-search-result:hover .rm-search-result-chevron {
		color: var(--rm-color-subtle, #949ba4);
	}

	.rm-search-panel .search-container > .input-group .btn:hover {
		background: transparent;
		color: inherit;
	}

	.rm-panel-section[data-edit-mode="edges"] .rm-panel-subline-actions .edge-edit-fit-map-btn:hover,
	.rm-panel-section[data-edit-mode="edges"] .rm-panel-subline-actions .edge-edit-deselect-btn:hover {
		background: var(--rm-surface-subtle);
		color: var(--rm-color-muted);
	}

	.rm-app-shell .edge-edit-status-option:hover:not(.is-current),
	.rm-panel-section[data-edit-mode="edges"] .edge-edit-status-option:hover:not(.is-current) {
		background: transparent;
		box-shadow: inset 0 0 0 1px var(--rm-border-subtle);
	}

	.rm-panel-section[data-edit-mode="edges"] [data-edge-edit-root] .chat-mention-picker button:hover:not(.is-active),
	.rm-panel-section[data-edit-mode="edges"] [data-edge-edit-root] .chat-channel-picker button:hover:not(.is-active) {
		background: transparent;
	}

	.rm-app-shell .chat-window--shell .chat-header-btn:hover:not(.active) {
		background: var(--rm-surface-subtle);
		color: var(--rm-color-muted);
	}

	.rm-app-shell .chat-window--shell .chat-composer-btn:hover,
	.rm-app-shell .rm-panel-section[data-edit-mode="edges"] [data-edge-edit-root] .chat-composer-btn:hover,
	.chat-composer-btn:hover:not(.active):not(.chat-composer-btn--send) {
		background: transparent !important;
		color: var(--rm-color-muted);
	}

	.rm-app-shell .chat-window--shell .chat-composer-btn.active:hover,
	.rm-app-shell .rm-panel-section[data-edit-mode="edges"] [data-edge-edit-root] .chat-composer-btn.active:hover,
	.chat-composer-btn.active:hover {
		background: color-mix(in srgb, var(--rm-color-accent, #5865f2) 14%, transparent);
		color: var(--rm-color-accent, #5865f2);
	}

	.rm-app-shell .chat-window--shell .rm-message-edge-chip:hover {
		background: var(--rm-message-edge-chip-bg);
	}

	.rm-app-shell .chat-window--shell .chat-mention-picker button:hover:not(.is-active),
	.rm-app-shell .chat-window--shell .chat-channel-picker button:hover:not(.is-active),
	.rm-app-shell .chat-mention-picker button:hover:not(.is-active),
	.rm-app-shell .chat-channel-picker button:hover:not(.is-active) {
		background: transparent;
	}

	.chat-mention-picker button:hover:not(.is-active),
	.chat-channel-picker button:hover:not(.is-active) {
		background: transparent;
	}

	.rm-app-shell .chat-window--shell .rm-message-menu-btn:hover {
		color: var(--rm-color-subtle);
		background: transparent;
	}

	.rm-app-shell .chat-window--shell .rm-message-dropdown__item:hover,
	.rm-message-dropdown__item:hover {
		background: transparent;
	}

	.rm-app-shell .chat-window--shell .chat-channel-ref:hover,
	.chat-channel-ref:hover {
		color: inherit;
	}

	.chat-header-btn:hover:not(.active) {
		background: rgba(255, 255, 255, 0.2);
	}

	.rm-message-edge-chip:hover {
		background: var(--rm-message-edge-chip-bg, #eef0f2);
	}

	.chat-composer-btn--send.is-ready:hover,
	.rm-app-shell .chat-window--shell .chat-composer-btn--send.is-ready:hover,
	.rm-app-shell .rm-panel-section[data-edit-mode="edges"] [data-edge-edit-root] .chat-composer-btn--send.is-ready:hover {
		background: var(--rm-color-accent, #5865f2);
		color: #fff;
	}

	.chat-composer-btn--cancel:hover {
		background: transparent;
		color: inherit;
	}

	.chat-composer-btn--send:disabled:hover,
	.rm-app-shell .chat-window--shell .chat-composer-btn--send:disabled:not(.is-ready):hover,
	.rm-app-shell .rm-panel-section[data-edit-mode="edges"] [data-edge-edit-root] .chat-composer-btn--send:disabled:not(.is-ready):hover {
		background: color-mix(in srgb, var(--rm-color-muted) 10%, transparent);
		color: var(--rm-color-muted);
	}

	.maplibregl-ctrl-attrib-button:hover {
		background-color: transparent !important;
	}

	.maplibregl-ctrl-attrib-button:hover::before {
		background-color: var(--rm-map-ctrl-attrib-icon);
	}

	.chat-composer-ref-remove:hover,
	.chat-referenced-edge-remove:hover {
		background: transparent;
		opacity: inherit;
	}

	.maplibregl-ctrl-group button:hover {
		background-color: transparent;
	}

	.maplibregl-ctrl-group button:hover .maplibregl-ctrl-icon {
		opacity: 1;
	}

	#toastContainer .toast .btn-close:hover,
	#toastContainer .toast .btn-close:focus {
		opacity: 0.45;
		background: transparent;
	}

	html.rm-theme-light #toastContainer .toast .btn-close:hover,
	html.rm-theme-light #toastContainer .toast .btn-close:focus {
		opacity: 0.38;
		background: transparent;
	}

	/* First message in a group: menu button stays visible on touch.
	   Continued messages (2+) have no actions menu (see chat.js). */
	.rm-message:not(.rm-message--continued) .rm-message-menu-btn,
	.rm-app-shell .chat-window--shell .rm-message:not(.rm-message--continued) .rm-message-menu-btn {
		opacity: 1;
		pointer-events: auto;
	}

	/* Continued messages (2+ in stack): menu button visually hidden on touch.
	   Long-press opens menu; toggle must stay in layout for Bootstrap/Popper. */
	.rm-message--continued .rm-message__actions--floated,
	.rm-app-shell .chat-window--shell .rm-message--continued .rm-message__actions--floated {
		opacity: 0;
		visibility: hidden;
		pointer-events: none;
	}

	.rm-message--continued .rm-message-menu-btn,
	.rm-app-shell .chat-window--shell .rm-message--continued .rm-message-menu-btn {
		opacity: 0;
		visibility: hidden;
		pointer-events: none;
	}

	.rm-message--continued .rm-message-menu-btn.rm-message-menu-btn--longpress-anchor,
	.rm-app-shell .chat-window--shell .rm-message--continued .rm-message-menu-btn.rm-message-menu-btn--longpress-anchor {
		visibility: visible;
		opacity: 0;
		pointer-events: none;
	}

	.rm-message--continued.rm-message--action-focus,
	.rm-message--continued.rm-msg-lp-armed {
		background: var(--rm-message-hover);
	}

	.rm-message--continued.rm-message--action-focus .rm-message__timestamp--inline,
	.rm-message--continued.rm-msg-lp-armed .rm-message__timestamp--inline {
		opacity: 1;
		pointer-events: auto;
	}

	/* Sync item remove: no hover on touch — keep it reachable */
	.rm-sync-panel-item-remove {
		opacity: 0.6;
	}

	.rm-sync-panel-item-remove:active {
		opacity: 1;
	}

	/* —— :active tap feedback —— */

	.rm-panel-collapse-btn:active {
		transform: scale(0.96);
		background: var(--rm-surface-hover);
		color: var(--rm-heading-color);
	}

	.rm-room-item:active:not(.is-active) {
		background: var(--rm-surface-hover);
	}

	.rm-app-panel .rm-filter-row:active {
		background: var(--rm-surface-hover);
	}

	.rm-app-panel .form-check.form-switch:active,
	.rm-filter-panel .form-check.form-switch:active {
		background: var(--rm-surface-subtle);
	}

	.rm-panel-section[data-panel="users"] #usersList .rm-users-item.has-location:active,
	#usersList .rm-users-item.has-location:active {
		background: var(--rm-surface-hover);
	}

	#usersList .rm-users-item.has-location:active {
		background-color: rgba(0, 0, 0, 0.06);
	}

	.rm-app-shell .chat-window--shell .rm-message:active {
		background: var(--rm-message-hover);
	}

	.rm-message-menu-btn:active,
	.rm-app-shell .chat-window--shell .rm-message-menu-btn:active {
		opacity: 1;
		transform: scale(0.96);
		background: var(--rm-message-hover);
		color: var(--rm-message-name);
	}

	.rm-message-dropdown__item:active,
	.rm-app-shell .chat-window--shell .rm-message-dropdown__item:active {
		background: var(--rm-surface-hover, rgba(0, 0, 0, 0.06));
	}

	.rm-app-shell .chat-window--shell .chat-channel-ref:active,
	.chat-channel-ref:active {
		transform: scale(0.98);
	}

	.rm-filter-panel .rm-filter-action-link:active,
	.rm-app-panel .rm-filter-action-link:active {
		color: var(--rm-link-hover-color);
	}

	.rm-input-info-btn:active {
		color: var(--rm-color-text, #212529);
		background: var(--rm-surface-hover, rgba(255, 255, 255, 0.06));
	}

	.rm-app-shell .chat-window--shell .chat-composer-btn:active:not(:disabled):not(.chat-composer-btn--send),
	.rm-app-shell .rm-panel-section[data-edit-mode="edges"] [data-edge-edit-root] .chat-composer-btn:active:not(:disabled):not(.chat-composer-btn--send),
	.chat-composer-btn:active:not(:disabled):not(.chat-composer-btn--send) {
		transform: scale(0.96);
		background: var(--rm-surface-hover, rgba(255, 255, 255, 0.08));
		color: var(--rm-color-text, #374151);
	}

	.rm-app-shell .chat-window--shell .chat-composer-btn.active:active:not(:disabled),
	.rm-app-shell .rm-panel-section[data-edit-mode="edges"] [data-edge-edit-root] .chat-composer-btn.active:active:not(:disabled),
	.chat-composer-btn.active:active:not(:disabled) {
		background: color-mix(in srgb, var(--rm-color-accent, #5865f2) 22%, transparent);
		color: var(--rm-color-accent, #5865f2);
	}

	.rm-app-shell .chat-window--shell .chat-composer-btn--send.is-ready:active:not(:disabled),
	.rm-app-shell .rm-panel-section[data-edit-mode="edges"] [data-edge-edit-root] .chat-composer-btn--send.is-ready:active:not(:disabled),
	.chat-composer-btn--send.is-ready:active:not(:disabled) {
		transform: scale(0.96);
		background: color-mix(in srgb, var(--rm-color-accent, #5865f2) 82%, #000);
		color: #fff;
	}

	.rm-app-shell .chat-window--shell .chat-composer-btn--cancel:active:not(:disabled),
	.chat-composer-btn--cancel:active:not(:disabled) {
		transform: scale(0.96);
		background: rgba(220, 53, 69, 0.14);
		color: var(--rm-color-danger, #dc3545);
	}

	.rm-app-shell .chat-window--shell .chat-header-btn:active:not(.active) {
		transform: scale(0.96);
		background: var(--rm-surface-hover);
		color: var(--rm-heading-color);
	}

	.rm-app-shell .chat-window--shell .chat-mention-picker button:active:not(.is-active),
	.rm-app-shell .chat-window--shell .chat-channel-picker button:active:not(.is-active),
	.chat-mention-picker button:active:not(.is-active),
	.chat-channel-picker button:active:not(.is-active) {
		background: var(--rm-chat-picker-hover, rgba(255, 255, 255, 0.08));
	}

	.rm-rail-btn:active:not(.is-active) {
		background: var(--rm-surface-hover);
		color: var(--rm-color-text);
	}

	.rm-auth-submit:hover {
		background: #2563eb;
	}

	.rm-auth-submit:active {
		transform: scale(0.96);
		background: #1d4ed8;
	}

	.chat-composer-ref-remove:active,
	.chat-pending-chip__remove:active,
	.chat-referenced-edge-remove:active {
		transform: scale(0.96);
		background: rgba(0, 0, 0, 0.08);
		color: var(--rm-color-danger-soft, #ed4245);
	}

	.maplibregl-ctrl-group button:active {
		background-color: var(--rm-map-ctrl-bg-hover, rgba(255, 255, 255, 0.08)) !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	@media (hover: none), (pointer: coarse) {
		.rm-panel-collapse-btn:active,
		.rm-app-shell .chat-window--shell .chat-header-btn:active,
		.rm-app-shell .chat-window--shell .rm-message-menu-btn:active,
		.rm-message-menu-btn:active,
		.rm-app-shell .chat-window--shell .chat-composer-btn:active:not(:disabled),
		.rm-app-shell .rm-panel-section[data-edit-mode="edges"] [data-edge-edit-root] .chat-composer-btn:active:not(:disabled),
		.chat-composer-btn:active:not(:disabled),
		.rm-app-shell .chat-window--shell .chat-channel-ref:active,
		.chat-channel-ref:active,
		.rm-auth-submit:active {
			transform: none;
		}
	}
}
